| From: | "Simon 'corecode' Schubert" <corecode@xxxxxxxxxxxx> |
| Date: | Thu, 9 Jun 2005 10:59:34 +0200 |
dillon 2005/06/08 15:22:59 PDT
DragonFly src repository
Modified files: sys/sys mbuf.h objcache.h sys/kern kern_objcache.c uipc_mbuf.c Log: Rollup mbuf/objcache fixes.
/* - * Both magazines empty. Get a full magazine from the depot. + * Both magazines empty. Get a full magazine from the depot and + * move one of the empty ones to the depot. Do this even if we + * block on the token to avoid a non-optimal corner case. + * + * Obtain the depot token. */ - - /* Obtain the depot token. */ depot = &oc->depot[myclusterid]; if (!lwkt_trytoken(&ilock, &depot->token)) { lwkt_gettoken(&ilock, &depot->token); ++depot->contested; - if (!MAGAZINE_EMPTY(cpucache->loaded_magazine) || - !MAGAZINE_EMPTY(cpucache->previous_magazine)) { - lwkt_reltoken(&ilock); - goto retry; - } }
+
+ /*
+ * Return emptymag to the depot. Due to blocking it may
+ * not be entirely empty.
+ */
+ if (MAGAZINE_EMPTY(emptymag)) {
+ SLIST_INSERT_HEAD(&depot->emptymagazines,
+ emptymag, nextmagazine);
+ } else {
+ /*
+ * NOTE: magazine is not necessarily entirely full
+ */
+ SLIST_INSERT_HEAD(&depot->fullmagazines,
+ emptymag, nextmagazine);
+ if (depot->waiting)
+ wakeup(depot);
+ }
/* - * Depot layer empty. + * The depot does not have any non-empty magazines. If we have + * not hit our object limit we can allocate a new object using + * the back-end allocator. + * + * note: unallocated_objects can be initialized to -1, which has + * the effect of removing any allocation limits. */ + if (depot->unallocated_objects) { + --depot->unallocated_objects; + lwkt_reltoken(&ilock); + crit_exit();
static int
mag_purge(struct objcache *oc, struct magazine *mag)
{
+ int ndeleted;
void *obj;
- int i;- for (i = 0; i < mag->rounds; i++) {
- obj = mag->objects[i];
+ ndeleted = 0;
+ crit_enter();
+ while (mag->rounds) {
+ obj = mag->objects[--mag->rounds];
+ crit_exit();
oc->dtor(obj, oc->private);
oc->free(obj, oc->allocator_args);
+ ++ndeleted;
+ crit_enter();
}
-
- return (mag->rounds);
+ crit_exit();
+ return(ndeleted);
}static void
depot_purge(struct magazinedepot *depot, struct objcache *oc)
{
- depot->cluster_balance -= maglist_purge(oc, &depot->fullmagazines,
- TRUE);
- maglist_purge(oc, &depot->emptymagazines, TRUE);
+ depot->unallocated_objects +=
+ maglist_purge(oc, &depot->fullmagazines, TRUE);
+ depot->unallocated_objects +=
+ maglist_purge(oc, &depot->emptymagazines, TRUE);
+ if (depot->unallocated_objects && depot->waiting)
+ wakeup(depot);
}
cheers simon
-- Serve - BSD +++ RENT this banner advert +++ ASCII Ribbon /"\ Work - Mac +++ space for low $$$ NOW!1 +++ Campaign \ / Party Enjoy Relax | http://dragonflybsd.org Against HTML \ Dude 2c 2 the max ! http://golden-apple.biz Mail + News / \
Attachment:
PGP.sig
Description: This is a digitally signed message part