Skip to content

Commit d13508f

Browse files
committed
nohz: Optimize full dynticks's sched hooks with static keys
Scheduler IPIs and task context switches are serious fast path. Let's try to hide as much as we can the impact of full dynticks APIs' off case that are called on these sites through the use of static keys. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Li Zhong <zhong@linux.vnet.ibm.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Kevin Hilman <khilman@linaro.org>
1 parent 460775d commit d13508f

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

‎include/linux/tick.h‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,32 @@ static inline bool tick_nohz_full_cpu(int cpu)
180180
}
181181

182182
extern void tick_nohz_init(void);
183-
extern void tick_nohz_full_check(void);
183+
extern void __tick_nohz_full_check(void);
184184
extern void tick_nohz_full_kick(void);
185185
extern void tick_nohz_full_kick_all(void);
186-
extern void tick_nohz_task_switch(struct task_struct *tsk);
186+
extern void __tick_nohz_task_switch(struct task_struct *tsk);
187187
#else
188188
static inline void tick_nohz_init(void) { }
189189
static inline bool tick_nohz_full_enabled(void) { return false; }
190190
static inline bool tick_nohz_full_cpu(int cpu) { return false; }
191-
static inline void tick_nohz_full_check(void) { }
191+
static inline void __tick_nohz_full_check(void) { }
192192
static inline void tick_nohz_full_kick(void) { }
193193
static inline void tick_nohz_full_kick_all(void) { }
194-
static inline void tick_nohz_task_switch(struct task_struct *tsk) { }
194+
static inline void __tick_nohz_task_switch(struct task_struct *tsk) { }
195195
#endif
196196

197+
static inline void tick_nohz_full_check(void)
198+
{
199+
if (tick_nohz_full_enabled())
200+
__tick_nohz_full_check();
201+
}
202+
203+
static inline void tick_nohz_task_switch(struct task_struct *tsk)
204+
{
205+
if (tick_nohz_full_enabled())
206+
__tick_nohz_task_switch(tsk);
207+
}
208+
197209

198210
# ifdef CONFIG_CPU_IDLE_GOV_MENU
199211
extern void menu_hrtimer_cancel(void);

‎kernel/time/tick-sched.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now);
198198
* Re-evaluate the need for the tick on the current CPU
199199
* and restart it if necessary.
200200
*/
201-
void tick_nohz_full_check(void)
201+
void __tick_nohz_full_check(void)
202202
{
203203
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
204204

@@ -212,7 +212,7 @@ void tick_nohz_full_check(void)
212212

213213
static void nohz_full_kick_work_func(struct irq_work *work)
214214
{
215-
tick_nohz_full_check();
215+
__tick_nohz_full_check();
216216
}
217217

218218
static DEFINE_PER_CPU(struct irq_work, nohz_full_kick_work) = {
@@ -231,7 +231,7 @@ void tick_nohz_full_kick(void)
231231

232232
static void nohz_full_kick_ipi(void *info)
233233
{
234-
tick_nohz_full_check();
234+
__tick_nohz_full_check();
235235
}
236236

237237
/*
@@ -254,7 +254,7 @@ void tick_nohz_full_kick_all(void)
254254
* It might need the tick due to per task/process properties:
255255
* perf events, posix cpu timers, ...
256256
*/
257-
void tick_nohz_task_switch(struct task_struct *tsk)
257+
void __tick_nohz_task_switch(struct task_struct *tsk)
258258
{
259259
unsigned long flags;
260260

0 commit comments

Comments
 (0)