preempt/dynamic: Provide irqentry_exit_cond_resched() static call
authorPeter Zijlstra (Intel) <peterz@infradead.org>
Mon, 18 Jan 2021 14:12:22 +0000 (15:12 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 17 Feb 2021 13:12:42 +0000 (14:12 +0100)
Provide static call to control IRQ preemption (called in CONFIG_PREEMPT)
so that we can override its behaviour when preempt= is overriden.

Since the default behaviour is full preemption, its call is
initialized to provide IRQ preemption when preempt= isn't passed.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lkml.kernel.org/r/20210118141223.123667-8-frederic@kernel.org
include/linux/entry-common.h
kernel/entry/common.c

index a104b298019ae4630ea5e39f06d8eeee327ef853..883acef895bc4d222c86075974cc55fc23119e02 100644 (file)
@@ -2,6 +2,7 @@
 #ifndef __LINUX_ENTRYCOMMON_H
 #define __LINUX_ENTRYCOMMON_H
 
+#include <linux/static_call_types.h>
 #include <linux/tracehook.h>
 #include <linux/syscalls.h>
 #include <linux/seccomp.h>
@@ -454,6 +455,9 @@ irqentry_state_t noinstr irqentry_enter(struct pt_regs *regs);
  * Conditional reschedule with additional sanity checks.
  */
 void irqentry_exit_cond_resched(void);
+#ifdef CONFIG_PREEMPT_DYNAMIC
+DECLARE_STATIC_CALL(irqentry_exit_cond_resched, irqentry_exit_cond_resched);
+#endif
 
 /**
  * irqentry_exit - Handle return from exception that used irqentry_enter()
index f9d491b17b78b59b59b68a47f6ad161b05c7bce0..f09cae37ddd5ef617a3a1e27e37b2c9983982799 100644 (file)
@@ -385,6 +385,9 @@ void irqentry_exit_cond_resched(void)
                        preempt_schedule_irq();
        }
 }
+#ifdef CONFIG_PREEMPT_DYNAMIC
+DEFINE_STATIC_CALL(irqentry_exit_cond_resched, irqentry_exit_cond_resched);
+#endif
 
 noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state)
 {
@@ -411,8 +414,13 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state)
                }
 
                instrumentation_begin();
-               if (IS_ENABLED(CONFIG_PREEMPTION))
+               if (IS_ENABLED(CONFIG_PREEMPTION)) {
+#ifdef CONFIG_PREEMT_DYNAMIC
+                       static_call(irqentry_exit_cond_resched)();
+#else
                        irqentry_exit_cond_resched();
+#endif
+               }
                /* Covers both tracing and lockdep */
                trace_hardirqs_on();
                instrumentation_end();