Skip to content

Commit 7a025e9

Browse files
committed
mm/vmstat: Use preempt_[dis|en]able_nested()
Replace the open coded CONFIG_PREEMPT_RT conditional preempt_enable/disable() pairs with the new helper functions which hide the underlying implementation details. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Michal Hocko <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 93f6d4e commit 7a025e9

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

mm/vmstat.c

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ void __mod_zone_page_state(struct zone *zone, enum zone_stat_item item,
355355
* CPU migrations and preemption potentially corrupts a counter so
356356
* disable preemption.
357357
*/
358-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
359-
preempt_disable();
358+
preempt_disable_nested();
360359

361360
x = delta + __this_cpu_read(*p);
362361

@@ -368,8 +367,7 @@ void __mod_zone_page_state(struct zone *zone, enum zone_stat_item item,
368367
}
369368
__this_cpu_write(*p, x);
370369

371-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
372-
preempt_enable();
370+
preempt_enable_nested();
373371
}
374372
EXPORT_SYMBOL(__mod_zone_page_state);
375373

@@ -393,8 +391,7 @@ void __mod_node_page_state(struct pglist_data *pgdat, enum node_stat_item item,
393391
}
394392

395393
/* See __mod_node_page_state */
396-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
397-
preempt_disable();
394+
preempt_disable_nested();
398395

399396
x = delta + __this_cpu_read(*p);
400397

@@ -406,8 +403,7 @@ void __mod_node_page_state(struct pglist_data *pgdat, enum node_stat_item item,
406403
}
407404
__this_cpu_write(*p, x);
408405

409-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
410-
preempt_enable();
406+
preempt_enable_nested();
411407
}
412408
EXPORT_SYMBOL(__mod_node_page_state);
413409

@@ -441,8 +437,7 @@ void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
441437
s8 v, t;
442438

443439
/* See __mod_node_page_state */
444-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
445-
preempt_disable();
440+
preempt_disable_nested();
446441

447442
v = __this_cpu_inc_return(*p);
448443
t = __this_cpu_read(pcp->stat_threshold);
@@ -453,8 +448,7 @@ void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
453448
__this_cpu_write(*p, -overstep);
454449
}
455450

456-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
457-
preempt_enable();
451+
preempt_enable_nested();
458452
}
459453

460454
void __inc_node_state(struct pglist_data *pgdat, enum node_stat_item item)
@@ -466,8 +460,7 @@ void __inc_node_state(struct pglist_data *pgdat, enum node_stat_item item)
466460
VM_WARN_ON_ONCE(vmstat_item_in_bytes(item));
467461

468462
/* See __mod_node_page_state */
469-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
470-
preempt_disable();
463+
preempt_disable_nested();
471464

472465
v = __this_cpu_inc_return(*p);
473466
t = __this_cpu_read(pcp->stat_threshold);
@@ -478,8 +471,7 @@ void __inc_node_state(struct pglist_data *pgdat, enum node_stat_item item)
478471
__this_cpu_write(*p, -overstep);
479472
}
480473

481-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
482-
preempt_enable();
474+
preempt_enable_nested();
483475
}
484476

485477
void __inc_zone_page_state(struct page *page, enum zone_stat_item item)
@@ -501,8 +493,7 @@ void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
501493
s8 v, t;
502494

503495
/* See __mod_node_page_state */
504-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
505-
preempt_disable();
496+
preempt_disable_nested();
506497

507498
v = __this_cpu_dec_return(*p);
508499
t = __this_cpu_read(pcp->stat_threshold);
@@ -513,8 +504,7 @@ void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
513504
__this_cpu_write(*p, overstep);
514505
}
515506

516-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
517-
preempt_enable();
507+
preempt_enable_nested();
518508
}
519509

520510
void __dec_node_state(struct pglist_data *pgdat, enum node_stat_item item)
@@ -526,8 +516,7 @@ void __dec_node_state(struct pglist_data *pgdat, enum node_stat_item item)
526516
VM_WARN_ON_ONCE(vmstat_item_in_bytes(item));
527517

528518
/* See __mod_node_page_state */
529-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
530-
preempt_disable();
519+
preempt_disable_nested();
531520

532521
v = __this_cpu_dec_return(*p);
533522
t = __this_cpu_read(pcp->stat_threshold);
@@ -538,8 +527,7 @@ void __dec_node_state(struct pglist_data *pgdat, enum node_stat_item item)
538527
__this_cpu_write(*p, overstep);
539528
}
540529

541-
if (IS_ENABLED(CONFIG_PREEMPT_RT))
542-
preempt_enable();
530+
preempt_enable_nested();
543531
}
544532

545533
void __dec_zone_page_state(struct page *page, enum zone_stat_item item)

0 commit comments

Comments
 (0)