FAILED: patch "[PATCH] x86: kvm: Revert "remove sched notifier for cross-cpu" failed to apply to 3.14-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 3.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
0a4e6be9ca17c54817cf814b4b5aa60478c6df27Mon Sep 17 00:00:00 2001
From: Marcelo Tosatti <[email protected]>
Date: Mon, 23 Mar 2015 20:21:51 -0300
Subject: [PATCH] x86: kvm: Revert "remove sched notifier for cross-cpu
migrations"
The following point:
2. per-CPU pvclock time info is updated if the underlying CPU changes.
Is not true anymore since "KVM: x86: update pvclock area conditionally, on cpu migration".
Add task migration notification back.
Problem noticed by Andy Lutomirski.
arch/x86/include/asm/pvclock.h +1 -0
@@ -95,6 +95,7 @@ unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src,struct pvclock_vsyscall_time_info {struct pvclock_vcpu_time_info pvti; +u32 migrate_count; } __attribute__((__aligned__ (SMP_CACHE_BYTES )));#define PVTI_SIZE sizeof(struct pvclock_vsyscall_time_info)
arch/x86/kernel/pvclock.c +44 -0
63 lines not on this page · raw message
arch/x86/vdso/vclock_gettime.c +8 -8
@@ -82,18 +82,15 @@ static notrace cycle_t vread_pvclock(int *mode)cycle_t ret;u64 last;u32 version; +u32 migrate_count;u8 flags;unsigned cpu, cpu1;/* -* Note: hypervisor must guarantee that: -* 1. cpu ID number maps 1:1 to per-CPU pvclock time info. -* 2. that per-CPU pvclock time info is updated if the -* underlying CPU changes. -* 3. that version is increased whenever underlying CPU -* changes. -* +* When looping to get a consistent (time-info, tsc) pair, we +* also need to deal with the possibility we can switch vcpus, +* so make sure we always re-fetch time-info for the current vcpu. */ do { cpu = __getcpu() & VGETCPU_CPU_MASK;
@@ -104,6 +101,8 @@ static notrace cycle_t vread_pvclock(int *mode) pvti =get_pvti (cpu); + migrate_count = pvti->migrate_count; + version =__pvclock_read_cycles (&pvti->pvti, &ret, &flags);/*
@@ -115,7 +114,8 @@ static notrace cycle_t vread_pvclock(int *mode) cpu1 =__getcpu () &VGETCPU_CPU_MASK ; }while (unlikely (cpu != cpu1 || (pvti->pvti.version &1 ) || - pvti->pvti.version != version)); + pvti->pvti.version != version || + pvti->migrate_count != migrate_count));if (unlikely (!(flags &PVCLOCK_TSC_STABLE_BIT ))) *mode =VCLOCK_NONE ;
include/linux/sched.h +8 -0
@@ -176,6 +176,14 @@ extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load);extern void calc_global_load (unsigned long ticks);extern void update_cpu_load_nohz (void ); +/* Notifier for when a task gets migrated to a new CPU */ +struct task_migration_notifier { +struct task_struct *task; +int from_cpu; +int to_cpu; +}; +extern void register_task_migration_notifier (struct notifier_block *n); +extern unsigned long get_parent_ip (unsigned long addr);extern void dump_cpu_task (int cpu);
kernel/sched/core.c +15 -0
@@ -996,6 +996,13 @@ void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags)rq_clock_skip_update (rq, true); } +static ATOMIC_NOTIFIER_HEAD (task_migration_notifier); + +void register_task_migration_notifier (struct notifier_block *n) +{ +atomic_notifier_chain_register (&task_migration_notifier, n); +} +#ifdef CONFIG_SMP void set_task_cpu (struct task_struct *p,unsigned int new_cpu) {
@@ -1026,10 +1033,18 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)trace_sched_migrate_task (p, new_cpu);if (task_cpu (p) != new_cpu) { +struct task_migration_notifier tmn; +if (p->sched_class->migrate_task_rq) p->sched_class->migrate_task_rq (p, new_cpu); p->se.nr_migrations++;perf_sw_event_sched (PERF_COUNT_SW_CPU_MIGRATIONS ,1 ,0 ); + + tmn.task = p; + tmn.from_cpu =task_cpu (p); + tmn.to_cpu = new_cpu; + +atomic_notifier_call_chain (&task_migration_notifier,0 , &tmn); }__set_task_cpu (p, new_cpu);