DragonFly kernel List (threaded) for 2008-01
DragonFly BSD
DragonFly kernel List (threaded) for 2008-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: objcache depot not used?


From: "Nicolas Thery" <nthery@xxxxxxxxx>
Date: Wed, 30 Jan 2008 22:12:19 +0100

2008/1/29, Matthew Dillon <dillon@apollo.backplane.com>:
>     Ok.  Well, I think your fix is correct.  Go ahead and spuce it up and
>     post it.

Here is it with your suggested calculation:

Index: src2/sys/kern/kern_objcache.c
===================================================================
--- src2.orig/sys/kern/kern_objcache.c	2008-01-23 07:30:38.000000000 +0100
+++ src2/sys/kern/kern_objcache.c	2008-01-23 08:39:44.000000000 +0100
@@ -186,6 +186,8 @@ objcache_create(const char *name, int cl
 	int cpuid;
 	int need;
 	int factor;
+	int nmagdepot;
+	int i;

 	/* allocate object cache structure */
 	oc = kmalloc(__offsetof(struct objcache, cache_percpu[ncpus]),
@@ -250,6 +252,29 @@ objcache_create(const char *name, int cl
 		cache_percpu->loaded_magazine = mag_alloc(mag_capacity);
 		cache_percpu->previous_magazine = mag_alloc(mag_capacity);
 	}
+
+	/* compute initial number of empty magazines in depot */
+	nmagdepot = 0;
+	if (cluster_limit > 0) {
+		/* max number of magazines in depot */
+		nmagdepot = (cluster_limit - ncpus * 2 * mag_capacity) /
+				mag_capacity;
+
+		/* retain at most 50% of the limit */
+		nmagdepot /= 2;
+	}
+	/* bound result to acceptable range */
+	if (nmagdepot < 2)
+		nmagdepot = 2;
+	if (nmagdepot > 10)
+		nmagdepot = 10;
+
+	/* put empty magazines in depot */
+	for (i = 0; i < nmagdepot; i++) {
+		struct magazine *mag = mag_alloc(mag_capacity);
+		SLIST_INSERT_HEAD(&depot->emptymagazines, mag, nextmagazine);
+	}
+
 	spin_lock_wr(&objcachelist_spin);
 	LIST_INSERT_HEAD(&allobjcaches, oc, oc_next);
 	spin_unlock_wr(&objcachelist_spin);

I intend to test it a bit more and submit it in a couple of days if
everybody is fine with it.



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]