Simplify keg_drain() a bit by using LIST_FOREACH_SAFE.
MFC after: 1 week
This commit is contained in:
parent
5c2ac5cf2a
commit
829be5168d
@ -845,8 +845,7 @@ static void
|
|||||||
keg_drain(uma_keg_t keg)
|
keg_drain(uma_keg_t keg)
|
||||||
{
|
{
|
||||||
struct slabhead freeslabs = { 0 };
|
struct slabhead freeslabs = { 0 };
|
||||||
uma_slab_t slab;
|
uma_slab_t slab, tmp;
|
||||||
uma_slab_t n;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't want to take pages from statically allocated kegs at this
|
* We don't want to take pages from statically allocated kegs at this
|
||||||
@ -862,15 +861,10 @@ keg_drain(uma_keg_t keg)
|
|||||||
if (keg->uk_free == 0)
|
if (keg->uk_free == 0)
|
||||||
goto finished;
|
goto finished;
|
||||||
|
|
||||||
slab = LIST_FIRST(&keg->uk_free_slab);
|
LIST_FOREACH_SAFE(slab, &keg->uk_free_slab, us_link, tmp) {
|
||||||
while (slab) {
|
/* We have nowhere to free these to. */
|
||||||
n = LIST_NEXT(slab, us_link);
|
if (slab->us_flags & UMA_SLAB_BOOT)
|
||||||
|
|
||||||
/* We have no where to free these to */
|
|
||||||
if (slab->us_flags & UMA_SLAB_BOOT) {
|
|
||||||
slab = n;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
LIST_REMOVE(slab, us_link);
|
LIST_REMOVE(slab, us_link);
|
||||||
keg->uk_pages -= keg->uk_ppera;
|
keg->uk_pages -= keg->uk_ppera;
|
||||||
@ -880,8 +874,6 @@ keg_drain(uma_keg_t keg)
|
|||||||
UMA_HASH_REMOVE(&keg->uk_hash, slab, slab->us_data);
|
UMA_HASH_REMOVE(&keg->uk_hash, slab, slab->us_data);
|
||||||
|
|
||||||
SLIST_INSERT_HEAD(&freeslabs, slab, us_hlink);
|
SLIST_INSERT_HEAD(&freeslabs, slab, us_hlink);
|
||||||
|
|
||||||
slab = n;
|
|
||||||
}
|
}
|
||||||
finished:
|
finished:
|
||||||
KEG_UNLOCK(keg);
|
KEG_UNLOCK(keg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user