This hook allows architecture specific code to be called at the end of the task switch and after perf_events' context switch but before the scheduler lock is released.
The specific use case in this series is to avoid multiple writes to a slow MSR until all functions which modify such register in task switch have finished. Reviewed-by: Stephane Eranian <eran...@google.com> Signed-off-by: David Carrillo-Cisneros <davi...@google.com> --- arch/x86/include/asm/processor.h | 4 ++++ kernel/sched/core.c | 1 + kernel/sched/sched.h | 3 +++ 3 files changed, 8 insertions(+) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 9264476..036d94a 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -22,6 +22,7 @@ struct vm86; #include <asm/nops.h> #include <asm/special_insns.h> #include <asm/fpu/types.h> +#include <asm/pqr_common.h> #include <linux/personality.h> #include <linux/cache.h> @@ -841,4 +842,7 @@ bool xen_set_default_idle(void); void stop_this_cpu(void *dummy); void df_debug(struct pt_regs *regs, long error_code); + +#define finish_arch_pre_lock_switch pqr_update + #endif /* _ASM_X86_PROCESSOR_H */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 8b489fc..bcd5473 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2620,6 +2620,7 @@ static struct rq *finish_task_switch(struct task_struct *prev) prev_state = prev->state; vtime_task_switch(prev); perf_event_task_sched_in(prev, current); + finish_arch_pre_lock_switch(); finish_lock_switch(rq, prev); finish_arch_post_lock_switch(); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index ec2e8d2..cb48b5c 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1077,6 +1077,9 @@ static inline int task_on_rq_migrating(struct task_struct *p) #ifndef prepare_arch_switch # define prepare_arch_switch(next) do { } while (0) #endif +#ifndef finish_arch_pre_lock_switch +# define finish_arch_pre_lock_switch() do { } while (0) +#endif #ifndef finish_arch_post_lock_switch # define finish_arch_post_lock_switch() do { } while (0) #endif -- 2.8.0.rc3.226.g39d4020