summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_malloc.c
diff options
context:
space:
mode:
authordyson <dyson@FreeBSD.org>1996-05-18 22:33:13 +0000
committerdyson <dyson@FreeBSD.org>1996-05-18 22:33:13 +0000
commit3130798e2b2e4152e1f8566a70736c3ca28fd94a (patch)
treedbf6eff759d3415dc087510db3e393a3d01f9ef2 /sys/kern/kern_malloc.c
parentf8b996982e0b37273c49a6010a01056d84512f79 (diff)
downloadFreeBSD-src-3130798e2b2e4152e1f8566a70736c3ca28fd94a.zip
FreeBSD-src-3130798e2b2e4152e1f8566a70736c3ca28fd94a.tar.gz
Minor performance improvement to kern_malloc.c that increases the
probability of reuse of recently freed memory. This improves cache hit stats on cached memory, and improves at least fork speed consistancy.
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index b348a3c..5375d6d 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94
- * $Id: kern_malloc.c,v 1.21 1996/05/02 14:20:20 phk Exp $
+ * $Id: kern_malloc.c,v 1.22 1996/05/10 19:28:48 wollman Exp $
*/
#include <sys/param.h>
@@ -351,12 +351,28 @@ free(addr, type)
wakeup((caddr_t)ksp);
ksp->ks_inuse--;
#endif
+#ifdef OLD_MALLOC_MEMORY_POLICY
if (kbp->kb_next == NULL)
kbp->kb_next = addr;
else
((struct freelist *)kbp->kb_last)->next = addr;
freep->next = NULL;
kbp->kb_last = addr;
+#else
+ /*
+ * Return memory to the head of the queue for quick reuse. This
+ * can improve performance by improving the probability of the
+ * item being in the cache when it is reused.
+ */
+ if (kbp->kb_next == NULL) {
+ kbp->kb_next = addr;
+ kbp->kb_last = addr;
+ freep->next = NULL;
+ } else {
+ freep->next = kbp->kb_next;
+ kbp->kb_next = addr;
+ }
+#endif
splx(s);
}
OpenPOWER on IntegriCloud