Skip to content

Commit 00a7829

Browse files
committed
Merge branch 'slab/for-6.1/slub_validation_locking' into slab/for-next
A fix for a regression in slub_debug caches that could cause slab page leaks and subsequent warnings on cache shutdown, by Feng Tang.
2 parents 445d41d + b731e35 commit 00a7829

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

mm/slub.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,22 +2881,25 @@ static noinline void free_debug_processing(
28812881
set_freepointer(s, tail, prior);
28822882
slab->freelist = head;
28832883

2884-
/* Do we need to remove the slab from full or partial list? */
2884+
/*
2885+
* If the slab is empty, and node's partial list is full,
2886+
* it should be discarded anyway no matter it's on full or
2887+
* partial list.
2888+
*/
2889+
if (slab->inuse == 0 && n->nr_partial >= s->min_partial)
2890+
slab_free = slab;
2891+
28852892
if (!prior) {
2893+
/* was on full list */
28862894
remove_full(s, n, slab);
2887-
} else if (slab->inuse == 0 &&
2888-
n->nr_partial >= s->min_partial) {
2895+
if (!slab_free) {
2896+
add_partial(n, slab, DEACTIVATE_TO_TAIL);
2897+
stat(s, FREE_ADD_PARTIAL);
2898+
}
2899+
} else if (slab_free) {
28892900
remove_partial(n, slab);
28902901
stat(s, FREE_REMOVE_PARTIAL);
28912902
}
2892-
2893-
/* Do we need to discard the slab or add to partial list? */
2894-
if (slab->inuse == 0 && n->nr_partial >= s->min_partial) {
2895-
slab_free = slab;
2896-
} else if (!prior) {
2897-
add_partial(n, slab, DEACTIVATE_TO_TAIL);
2898-
stat(s, FREE_ADD_PARTIAL);
2899-
}
29002903
}
29012904

29022905
if (slab_free) {

0 commit comments

Comments
 (0)