Skip to content

Commit ff99b18

Browse files
Xiongwei Songtehcaster
authored andcommitted
mm/slub: simplify get_partial_node()
The break conditions for filling cpu partial can be more readable and simple. If slub_get_cpu_partial() returns 0, we can confirm that we don't need to fill cpu partial, then we should break from the loop. On the other hand, we also should break from the loop if we have added enough cpu partial slabs. Meanwhile, the logic above gets rid of the #ifdef and also fixes a weird corner case that if we set cpu_partial_slabs to 0 from sysfs, we still allocate at least one here. Signed-off-by: Xiongwei Song <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent 721a2f8 commit ff99b18

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

mm/slub.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,18 +2614,18 @@ static struct slab *get_partial_node(struct kmem_cache *s,
26142614
if (!partial) {
26152615
partial = slab;
26162616
stat(s, ALLOC_FROM_PARTIAL);
2617+
2618+
if ((slub_get_cpu_partial(s) == 0)) {
2619+
break;
2620+
}
26172621
} else {
26182622
put_cpu_partial(s, slab, 0);
26192623
stat(s, CPU_PARTIAL_NODE);
2620-
partial_slabs++;
2621-
}
2622-
#ifdef CONFIG_SLUB_CPU_PARTIAL
2623-
if (partial_slabs > s->cpu_partial_slabs / 2)
2624-
break;
2625-
#else
2626-
break;
2627-
#endif
26282624

2625+
if (++partial_slabs > slub_get_cpu_partial(s) / 2) {
2626+
break;
2627+
}
2628+
}
26292629
}
26302630
spin_unlock_irqrestore(&n->list_lock, flags);
26312631
return partial;

0 commit comments

Comments
 (0)