I wrote a tiny malloc (libc-style) implementation over a small static storage (could be over stack or preallocated on the heap) without any external dependencies. Would it be useful for you? On 01.06.2020 01:34, Rin Okuyama wrote: > Module Name: src > Committed By: rin > Date: Sun May 31 23:34:34 UTC 2020 > > Modified Files: > src/sys/ddb: db_kernel.c > > Log Message: > Switch from kmem_intr_alloc(sz, KM_NOSLEEP) to kmem_alloc(sz, KM_SLEEP). > > Clearly document these functions are *not* for DDB session, but for > permanent data storage when initializing DDB. > > > To generate a diff of this commit: > cvs rdiff -u -r1.3 -r1.4 src/sys/ddb/db_kernel.c > > Please note that diffs are not public domain; they are subject to the > copyright notices on the relevant files. > > > Modified files: > > Index: src/sys/ddb/db_kernel.c > diff -u src/sys/ddb/db_kernel.c:1.3 src/sys/ddb/db_kernel.c:1.4 > --- src/sys/ddb/db_kernel.c:1.3 Sun May 31 09:42:46 2020 > +++ src/sys/ddb/db_kernel.c Sun May 31 23:34:34 2020 > @@ -1,4 +1,4 @@ > -/* $NetBSD: db_kernel.c,v 1.3 2020/05/31 09:42:46 rin Exp $ */ > +/* $NetBSD: db_kernel.c,v 1.4 2020/05/31 23:34:34 rin Exp $ */ > > /*- > * Copyright (c) 2009 The NetBSD Foundation, Inc. > @@ -30,7 +30,7 @@ > */ > > #include <sys/cdefs.h> > -__KERNEL_RCSID(0, "$NetBSD: db_kernel.c,v 1.3 2020/05/31 09:42:46 rin Exp $"); > +__KERNEL_RCSID(0, "$NetBSD: db_kernel.c,v 1.4 2020/05/31 23:34:34 rin Exp $"); > > #include <sys/param.h> > #include <sys/kmem.h> > @@ -39,28 +39,33 @@ __KERNEL_RCSID(0, "$NetBSD: db_kernel.c, > > /* > * XXX > - * DDB can be running in the interrupt context, e.g., when activated from > - * console. Therefore, we use kmem_intr_alloc(9) and friends here to avoid > - * assertion failure. > + * These routines are *not* intended for a DDB session: > + * > + * - It disturbes on-going debugged kernel datastructures. > + * > + * - DDB can be running in the interrupt context, e.g., when activated from > + * console. This results in assertion failures in the allocator. > + * > + * Use these only for permanent data storage when initializing DDB. > */ > > void * > db_alloc(size_t sz) > { > > - return kmem_intr_alloc(sz, KM_NOSLEEP); > + return kmem_alloc(sz, KM_SLEEP); > } > > void * > db_zalloc(size_t sz) > { > > - return kmem_intr_zalloc(sz, KM_NOSLEEP); > + return kmem_zalloc(sz, KM_SLEEP); > } > > void > db_free(void *p, size_t sz) > { > > - kmem_intr_free(p, sz); > + kmem_free(p, sz); > } >
Attachment:
signature.asc
Description: OpenPGP digital signature