Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Don't use malloc/free for fixed sized items, use a ...
details: https://anonhg.NetBSD.org/src/rev/bacdc0343e71
branches: trunk
changeset: 559791:bacdc0343e71
user: matt <matt%NetBSD.org@localhost>
date: Wed Mar 24 01:27:57 2004 +0000
description:
Don't use malloc/free for fixed sized items, use a pool instead.
diffstat:
sys/kern/kern_kcont.c | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diffs (81 lines):
diff -r 77d88d345a63 -r bacdc0343e71 sys/kern/kern_kcont.c
--- a/sys/kern/kern_kcont.c Wed Mar 24 00:59:40 2004 +0000
+++ b/sys/kern/kern_kcont.c Wed Mar 24 01:27:57 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_kcont.c,v 1.5 2004/03/23 13:22:32 junyoung Exp $ */
+/* $NetBSD: kern_kcont.c,v 1.6 2004/03/24 01:27:57 matt Exp $ */
/*
* Copyright 2003 Jonathan Stone.
@@ -37,13 +37,14 @@
/*
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_kcont.c,v 1.5 2004/03/23 13:22:32 junyoung Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: kern_kcont.c,v 1.6 2004/03/24 01:27:57 matt Exp $ ");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/errno.h>
#include <sys/malloc.h>
+#include <sys/pool.h>
#include <sys/kthread.h>
#include <sys/proc.h>
#include <lib/libkern/libkern.h>
@@ -54,9 +55,6 @@
#include <sys/kcont.h>
-MALLOC_DECLARE(M_KCONT);
-MALLOC_DEFINE(M_KCONT, "kcont", "Kernel non-process continuations");
-
/* Accessors for struct kc_queue */
static __inline struct kc * kc_set(struct kc *,
void (*func)(void *, void *, int),
@@ -83,6 +81,11 @@
#endif /* __HAVE_GENERIC_SOFT_INTERRUPTS */
/*
+ * Pool allocator strcuture.
+ */
+static struct pool kc_pool;
+
+/*
* Process-context continuation queue.
*/
static kcq_t kcq_process_ctxt;
@@ -165,9 +168,13 @@
void *env_arg, int continue_ipl)
{
struct kc *kc;
+ int pool_flags;
- kc = malloc(sizeof (*kc), M_KCONT, malloc_flags);
- if (kc == NULL)
+ pool_flags = (malloc_flags & M_NOWAIT) ? 0 : PR_WAITOK;
+ pool_flags |= (malloc_flags & M_CANFAIL) ? PR_LIMITFAIL : 0;
+
+ kc = pool_get(&kc_pool, pool_flags);
+ if (kc == NULL)
return kc;
return kc_set(kc, func, env_arg, continue_ipl);
}
@@ -295,7 +302,7 @@
* to test for auto-free.
*/
if (saved_flags & KC_AUTOFREE)
- free(kc, M_KCONT);
+ pool_put(&kc_pool, kc);
} else {
kcont_defer(kc, obj, status);
}
@@ -372,6 +379,8 @@
kcont_run_softserial, &kcq_softserial);
#endif /* __HAVE_GENERIC_SOFT_INTERRUPTS */
+ pool_init(&kc_pool, sizeof(struct kc), 0, 0, 0, "kcpl", NULL);
+
/*
* Create kc_queue for process-context continuations, and
* a worker kthread to process the queue. (Fine-grained SMP
Home |
Main Index |
Thread Index |
Old Index