From b23f72e98ae8164c07be4b3780a0b83e094844cf Mon Sep 17 00:00:00 2001 From: Brian Feldman Date: Mon, 2 Aug 2004 00:18:36 +0000 Subject: * Add a "how" argument to uma_zone constructors and initialization functions so that they know whether the allocation is supposed to be able to sleep or not. * Allow uma_zone constructors and initialation functions to return either success or error. Almost all of the ones in the tree currently return success unconditionally, but mbuf is a notable exception: the packet zone constructor wants to be able to fail if it cannot suballocate an mbuf cluster, and the mbuf allocators want to be able to fail in general in a MAC kernel if the MAC mbuf initializer fails. This fixes the panics people are seeing when they run out of memory for mbuf clusters. * Allow debug.nosleepwithlocks on WITNESS to be disabled, without changing the default. Both bmilekic and jeff have reviewed the changes made to make failable zone allocations work. --- sys/kern/kern_thread.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'sys/kern/kern_thread.c') diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index c5e950402b0e..7f6ef953a36a 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -143,8 +143,8 @@ MTX_SYSINIT(tid_lock, &tid_lock, "TID lock", MTX_DEF); /* * Prepare a thread for use. */ -static void -thread_ctor(void *mem, int size, void *arg) +static int +thread_ctor(void *mem, int size, void *arg, int flags) { struct thread *td; @@ -165,6 +165,7 @@ thread_ctor(void *mem, int size, void *arg) * next thread. */ td->td_critnest = 1; + return (0); } /* @@ -202,8 +203,8 @@ thread_dtor(void *mem, int size, void *arg) /* * Initialize type-stable parts of a thread (when newly created). */ -static void -thread_init(void *mem, int size) +static int +thread_init(void *mem, int size, int flags) { struct thread *td; struct tid_bitmap_part *bmp, *new; @@ -251,6 +252,7 @@ thread_init(void *mem, int size) td->td_sleepqueue = sleepq_alloc(); td->td_turnstile = turnstile_alloc(); td->td_sched = (struct td_sched *)&td[1]; + return (0); } /* @@ -287,25 +289,27 @@ thread_fini(void *mem, int size) /* * Initialize type-stable parts of a kse (when newly created). */ -static void -kse_init(void *mem, int size) +static int +kse_init(void *mem, int size, int flags) { struct kse *ke; ke = (struct kse *)mem; ke->ke_sched = (struct ke_sched *)&ke[1]; + return (0); } /* * Initialize type-stable parts of a ksegrp (when newly created). */ -static void -ksegrp_init(void *mem, int size) +static int +ksegrp_init(void *mem, int size, int flags) { struct ksegrp *kg; kg = (struct ksegrp *)mem; kg->kg_sched = (struct kg_sched *)&kg[1]; + return (0); } /* -- cgit v1.3