Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rcu/context-tracking: Remove unused and/or unecessary middle functions

Some eqs functions are now only used internally by context tracking, so
their public declarations can be removed.

Also middle functions such as rcu_user_*() and rcu_idle_*()
which now directly call to rcu_eqs_enter() and rcu_eqs_exit() can be
wiped out as well.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Nicolas Saenz Julienne <nsaenz@kernel.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Cc: Yu Liao <liaoyu15@huawei.com>
Cc: Phil Auld <pauld@redhat.com>
Cc: Paul Gortmaker<paul.gortmaker@windriver.com>
Cc: Alex Belits <abelits@marvell.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
Tested-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>

authored by

Frederic Weisbecker and committed by
Paul E. McKenney
c33ef43a 17211455

+28 -92
+1 -1
Documentation/RCU/stallwarn.rst
··· 97 97 which will include additional debugging information. 98 98 99 99 - A low-level kernel issue that either fails to invoke one of the 100 - variants of rcu_user_enter(), rcu_user_exit(), ct_idle_enter(), 100 + variants of rcu_eqs_enter(true), rcu_eqs_exit(true), ct_idle_enter(), 101 101 ct_idle_exit(), ct_irq_enter(), or ct_irq_exit() on the one 102 102 hand, or that invokes one of them too many times on the other. 103 103 Historically, the most frequent issue has been an omission
-8
include/linux/hardirq.h
··· 92 92 #define arch_nmi_exit() do { } while (0) 93 93 #endif 94 94 95 - #ifdef CONFIG_TINY_RCU 96 - static inline void rcu_nmi_enter(void) { } 97 - static inline void rcu_nmi_exit(void) { } 98 - #else 99 - extern void rcu_nmi_enter(void); 100 - extern void rcu_nmi_exit(void); 101 - #endif 102 - 103 95 /* 104 96 * NMI vs Tracing 105 97 * --------------
-8
include/linux/rcupdate.h
··· 104 104 static inline void rcu_sysrq_end(void) { } 105 105 #endif /* #else #ifdef CONFIG_RCU_STALL_COMMON */ 106 106 107 - #ifdef CONFIG_NO_HZ_FULL 108 - void rcu_user_enter(void); 109 - void rcu_user_exit(void); 110 - #else 111 - static inline void rcu_user_enter(void) { } 112 - static inline void rcu_user_exit(void) { } 113 - #endif /* CONFIG_NO_HZ_FULL */ 114 - 115 107 #if defined(CONFIG_NO_HZ_FULL) && (!defined(CONFIG_GENERIC_ENTRY) || !defined(CONFIG_KVM_XFER_TO_GUEST_WORK)) 116 108 void rcu_irq_work_resched(void); 117 109 #else
-2
include/linux/rcutiny.h
··· 76 76 static inline void rcu_virt_note_context_switch(int cpu) { } 77 77 static inline void rcu_cpu_stall_reset(void) { } 78 78 static inline int rcu_jiffies_till_stall_check(void) { return 21 * HZ; } 79 - static inline void rcu_idle_enter(void) { } 80 - static inline void rcu_idle_exit(void) { } 81 79 static inline void rcu_irq_exit_check_preempt(void) { } 82 80 #define rcu_is_idle_cpu(cpu) \ 83 81 (is_idle_task(current) && !in_nmi() && !in_hardirq() && !in_serving_softirq())
-2
include/linux/rcutree.h
··· 45 45 bool poll_state_synchronize_rcu(unsigned long oldstate); 46 46 void cond_synchronize_rcu(unsigned long oldstate); 47 47 48 - void rcu_idle_enter(void); 49 - void rcu_idle_exit(void); 50 48 bool rcu_is_idle_cpu(int cpu); 51 49 52 50 #ifdef CONFIG_PROVE_RCU
+27 -71
kernel/context_tracking.c
··· 189 189 } 190 190 191 191 /** 192 - * rcu_nmi_exit - inform RCU of exit from NMI context 192 + * ct_nmi_exit - inform RCU of exit from NMI context 193 193 * 194 194 * If we are returning from the outermost NMI handler that interrupted an 195 195 * RCU-idle period, update ct->dynticks and ct->dynticks_nmi_nesting 196 196 * to let the RCU grace-period handling know that the CPU is back to 197 197 * being RCU-idle. 198 198 * 199 - * If you add or remove a call to rcu_nmi_exit(), be sure to test 199 + * If you add or remove a call to ct_nmi_exit(), be sure to test 200 200 * with CONFIG_RCU_EQS_DEBUG=y. 201 201 */ 202 - void noinstr rcu_nmi_exit(void) 202 + void noinstr ct_nmi_exit(void) 203 203 { 204 204 struct context_tracking *ct = this_cpu_ptr(&context_tracking); 205 205 ··· 242 242 } 243 243 244 244 /** 245 - * rcu_nmi_enter - inform RCU of entry to NMI context 245 + * ct_nmi_enter - inform RCU of entry to NMI context 246 246 * 247 247 * If the CPU was idle from RCU's viewpoint, update ct->dynticks and 248 248 * ct->dynticks_nmi_nesting to let the RCU grace-period handling know ··· 250 250 * long as the nesting level does not overflow an int. (You will probably 251 251 * run out of stack space first.) 252 252 * 253 - * If you add or remove a call to rcu_nmi_enter(), be sure to test 253 + * If you add or remove a call to ct_nmi_enter(), be sure to test 254 254 * with CONFIG_RCU_EQS_DEBUG=y. 255 255 */ 256 - void noinstr rcu_nmi_enter(void) 256 + void noinstr ct_nmi_enter(void) 257 257 { 258 258 long incby = 2; 259 259 struct context_tracking *ct = this_cpu_ptr(&context_tracking); ··· 302 302 } 303 303 304 304 /** 305 - * rcu_idle_enter - inform RCU that current CPU is entering idle 305 + * ct_idle_enter - inform RCU that current CPU is entering idle 306 306 * 307 307 * Enter idle mode, in other words, -leave- the mode in which RCU 308 308 * read-side critical sections can occur. (Though RCU read-side 309 309 * critical sections can occur in irq handlers in idle, a possibility 310 310 * handled by irq_enter() and irq_exit().) 311 311 * 312 - * If you add or remove a call to rcu_idle_enter(), be sure to test with 312 + * If you add or remove a call to ct_idle_enter(), be sure to test with 313 313 * CONFIG_RCU_EQS_DEBUG=y. 314 314 */ 315 - void noinstr rcu_idle_enter(void) 315 + void noinstr ct_idle_enter(void) 316 316 { 317 317 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !raw_irqs_disabled()); 318 318 rcu_eqs_enter(false); 319 319 } 320 + EXPORT_SYMBOL_GPL(ct_idle_enter); 320 321 321 322 /** 322 - * rcu_idle_exit - inform RCU that current CPU is leaving idle 323 + * ct_idle_exit - inform RCU that current CPU is leaving idle 323 324 * 324 325 * Exit idle mode, in other words, -enter- the mode in which RCU 325 326 * read-side critical sections can occur. 326 327 * 327 - * If you add or remove a call to rcu_idle_exit(), be sure to test with 328 + * If you add or remove a call to ct_idle_exit(), be sure to test with 328 329 * CONFIG_RCU_EQS_DEBUG=y. 329 330 */ 330 - void noinstr rcu_idle_exit(void) 331 + void noinstr ct_idle_exit(void) 331 332 { 332 333 unsigned long flags; 333 334 334 335 raw_local_irq_save(flags); 335 336 rcu_eqs_exit(false); 336 337 raw_local_irq_restore(flags); 337 - } 338 - EXPORT_SYMBOL_GPL(rcu_idle_exit); 339 - 340 - noinstr void ct_idle_enter(void) 341 - { 342 - rcu_idle_enter(); 343 - } 344 - EXPORT_SYMBOL_GPL(ct_idle_enter); 345 - 346 - void ct_idle_exit(void) 347 - { 348 - rcu_idle_exit(); 349 338 } 350 339 EXPORT_SYMBOL_GPL(ct_idle_exit); 351 340 ··· 420 431 ct_irq_exit(); 421 432 local_irq_restore(flags); 422 433 } 423 - 424 - noinstr void ct_nmi_enter(void) 425 - { 426 - rcu_nmi_enter(); 427 - } 428 - 429 - noinstr void ct_nmi_exit(void) 430 - { 431 - rcu_nmi_exit(); 432 - } 434 + #else 435 + static __always_inline void rcu_eqs_enter(bool user) { } 436 + static __always_inline void rcu_eqs_exit(bool user) { } 433 437 #endif /* #ifdef CONFIG_CONTEXT_TRACKING_IDLE */ 434 - 435 - #ifdef CONFIG_NO_HZ_FULL 436 - /** 437 - * rcu_user_enter - inform RCU that we are resuming userspace. 438 - * 439 - * Enter RCU idle mode right before resuming userspace. No use of RCU 440 - * is permitted between this call and rcu_user_exit(). This way the 441 - * CPU doesn't need to maintain the tick for RCU maintenance purposes 442 - * when the CPU runs in userspace. 443 - * 444 - * If you add or remove a call to rcu_user_enter(), be sure to test with 445 - * CONFIG_RCU_EQS_DEBUG=y. 446 - */ 447 - noinstr void rcu_user_enter(void) 448 - { 449 - rcu_eqs_enter(true); 450 - } 451 - 452 - /** 453 - * rcu_user_exit - inform RCU that we are exiting userspace. 454 - * 455 - * Exit RCU idle mode while entering the kernel because it can 456 - * run a RCU read side critical section anytime. 457 - * 458 - * If you add or remove a call to rcu_user_exit(), be sure to test with 459 - * CONFIG_RCU_EQS_DEBUG=y. 460 - */ 461 - void noinstr rcu_user_exit(void) 462 - { 463 - rcu_eqs_exit(true); 464 - } 465 - #endif /* #ifdef CONFIG_NO_HZ_FULL */ 466 438 467 439 #ifdef CONFIG_CONTEXT_TRACKING_USER 468 440 ··· 492 542 * that will fire and reschedule once we resume in user/guest mode. 493 543 */ 494 544 rcu_irq_work_resched(); 495 - rcu_user_enter(); 545 + /* 546 + * Enter RCU idle mode right before resuming userspace. No use of RCU 547 + * is permitted between this call and rcu_eqs_exit(). This way the 548 + * CPU doesn't need to maintain the tick for RCU maintenance purposes 549 + * when the CPU runs in userspace. 550 + */ 551 + rcu_eqs_enter(true); 496 552 } 497 553 /* 498 554 * Even if context tracking is disabled on this CPU, because it's outside ··· 535 579 /* 536 580 * Some contexts may involve an exception occuring in an irq, 537 581 * leading to that nesting: 538 - * ct_irq_enter() rcu_user_exit() rcu_user_exit() ct_irq_exit() 582 + * ct_irq_enter() rcu_eqs_exit(true) rcu_eqs_enter(true) ct_irq_exit() 539 583 * This would mess up the dyntick_nesting count though. And rcu_irq_*() 540 584 * helpers are enough to protect RCU uses inside the exception. So 541 585 * just return immediately if we detect we are in an IRQ. ··· 587 631 if (__this_cpu_read(context_tracking.state) == state) { 588 632 if (__this_cpu_read(context_tracking.active)) { 589 633 /* 590 - * We are going to run code that may use RCU. Inform 591 - * RCU core about that (ie: we may need the tick again). 634 + * Exit RCU idle mode while entering the kernel because it can 635 + * run a RCU read side critical section anytime. 592 636 */ 593 - rcu_user_exit(); 637 + rcu_eqs_exit(true); 594 638 if (state == CONTEXT_USER) { 595 639 instrumentation_begin(); 596 640 vtime_user_exit(current);