Skip to content

Commit f3ab8b6

Browse files
committed
mm, slub: move irq control into unfreeze_partials()
unfreeze_partials() can be optimized so that it doesn't need irqs disabled for the whole time. As the first step, move irq control into the function and remove it from the put_cpu_partial() caller. Signed-off-by: Vlastimil Babka <[email protected]>
1 parent cfdf836 commit f3ab8b6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

mm/slub.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,16 +2350,18 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page,
23502350
/*
23512351
* Unfreeze all the cpu partial slabs.
23522352
*
2353-
* This function must be called with interrupts disabled
2354-
* for the cpu using c (or some other guarantee must be there
2355-
* to guarantee no concurrent accesses).
2353+
* This function must be called with preemption or migration
2354+
* disabled with c local to the cpu.
23562355
*/
23572356
static void unfreeze_partials(struct kmem_cache *s,
23582357
struct kmem_cache_cpu *c)
23592358
{
23602359
#ifdef CONFIG_SLUB_CPU_PARTIAL
23612360
struct kmem_cache_node *n = NULL, *n2 = NULL;
23622361
struct page *page, *discard_page = NULL;
2362+
unsigned long flags;
2363+
2364+
local_irq_save(flags);
23632365

23642366
while ((page = slub_percpu_partial(c))) {
23652367
struct page new;
@@ -2412,6 +2414,8 @@ static void unfreeze_partials(struct kmem_cache *s,
24122414
discard_slab(s, page);
24132415
stat(s, FREE_SLAB);
24142416
}
2417+
2418+
local_irq_restore(flags);
24152419
#endif /* CONFIG_SLUB_CPU_PARTIAL */
24162420
}
24172421

@@ -2439,14 +2443,11 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
24392443
pobjects = oldpage->pobjects;
24402444
pages = oldpage->pages;
24412445
if (drain && pobjects > slub_cpu_partial(s)) {
2442-
unsigned long flags;
24432446
/*
24442447
* partial array is full. Move the existing
24452448
* set to the per node partial list.
24462449
*/
2447-
local_irq_save(flags);
24482450
unfreeze_partials(s, this_cpu_ptr(s->cpu_slab));
2449-
local_irq_restore(flags);
24502451
oldpage = NULL;
24512452
pobjects = 0;
24522453
pages = 0;

0 commit comments

Comments
 (0)