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

Configure Feed

Select the types of activity you want to include in your feed.

sched/preempt: Simplify irqentry_exit_cond_resched() callers

Currently callers of irqentry_exit_cond_resched() need to be aware of
whether the function should be indirected via a static call, leading to
ugly ifdeffery in callers.

Save them the hassle with a static inline wrapper that does the right
thing. The raw_irqentry_exit_cond_resched() will also be useful in
subsequent patches which will add conditional wrappers for preemption
functions.

Note: in arch/x86/entry/common.c, xen_pv_evtchn_do_upcall() always calls
irqentry_exit_cond_resched() directly, even when PREEMPT_DYNAMIC is in
use. I believe this is a latent bug (which this patch corrects), but I'm
not entirely certain this wasn't deliberate.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20220214165216.2231574-4-mark.rutland@arm.com

authored by

Mark Rutland and committed by
Peter Zijlstra
4624a14f 8a69fe0b

+10 -11
+6 -3
include/linux/entry-common.h
··· 454 454 * 455 455 * Conditional reschedule with additional sanity checks. 456 456 */ 457 - void irqentry_exit_cond_resched(void); 457 + void raw_irqentry_exit_cond_resched(void); 458 458 #ifdef CONFIG_PREEMPT_DYNAMIC 459 - #define irqentry_exit_cond_resched_dynamic_enabled irqentry_exit_cond_resched 459 + #define irqentry_exit_cond_resched_dynamic_enabled raw_irqentry_exit_cond_resched 460 460 #define irqentry_exit_cond_resched_dynamic_disabled NULL 461 - DECLARE_STATIC_CALL(irqentry_exit_cond_resched, irqentry_exit_cond_resched); 461 + DECLARE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched); 462 + #define irqentry_exit_cond_resched() static_call(irqentry_exit_cond_resched)() 463 + #else 464 + #define irqentry_exit_cond_resched() raw_irqentry_exit_cond_resched() 462 465 #endif 463 466 464 467 /**
+4 -8
kernel/entry/common.c
··· 380 380 return ret; 381 381 } 382 382 383 - void irqentry_exit_cond_resched(void) 383 + void raw_irqentry_exit_cond_resched(void) 384 384 { 385 385 if (!preempt_count()) { 386 386 /* Sanity check RCU and thread stack */ ··· 392 392 } 393 393 } 394 394 #ifdef CONFIG_PREEMPT_DYNAMIC 395 - DEFINE_STATIC_CALL(irqentry_exit_cond_resched, irqentry_exit_cond_resched); 395 + DEFINE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched); 396 396 #endif 397 397 398 398 noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state) ··· 420 420 } 421 421 422 422 instrumentation_begin(); 423 - if (IS_ENABLED(CONFIG_PREEMPTION)) { 424 - #ifdef CONFIG_PREEMPT_DYNAMIC 425 - static_call(irqentry_exit_cond_resched)(); 426 - #else 423 + if (IS_ENABLED(CONFIG_PREEMPTION)) 427 424 irqentry_exit_cond_resched(); 428 - #endif 429 - } 425 + 430 426 /* Covers both tracing and lockdep */ 431 427 trace_hardirqs_on(); 432 428 instrumentation_end();