Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f94c8d11 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

sched/clock, x86/tsc: Rework the x86 'unstable' sched_clock() interface



Wanpeng Li reported that since the following commit:

  acb04058 ("sched/clock: Fix hotplug crash")

... KVM always runs with unstable sched-clock even though KVM's
kvm_clock _is_ stable.

The problem is that we've tied clear_sched_clock_stable() to the TSC
state, and overlooked that sched_clock() is a paravirt function.

Solve this by doing two things:

 - tie the sched_clock() stable state more clearly to the TSC stable
   state for the normal (!paravirt) case.

 - only call clear_sched_clock_stable() when we mark TSC unstable
   when we use native_sched_clock().

The first means we can actually run with stable sched_clock in more
situations then before, which is good. And since commit:

  12907fbb ("sched/clock, clocksource: Add optional cs::mark_unstable() method")

... this should be reliable. Since any detection of TSC fail now results
in marking the TSC unstable.

Reported-by: default avatarWanpeng Li <kernellwp@gmail.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Fixes: acb04058 ("sched/clock: Fix hotplug crash")
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 0ba87bb2
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -555,10 +555,6 @@ static void early_init_amd(struct cpuinfo_x86 *c)
	if (c->x86_power & (1 << 8)) {
		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
		set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
		if (check_tsc_unstable())
			clear_sched_clock_stable();
	} else {
		clear_sched_clock_stable();
	}

	/* Bit 12 of 8000_0007 edx is accumulated power mechanism. */
+0 −2
Original line number Diff line number Diff line
@@ -104,8 +104,6 @@ static void early_init_centaur(struct cpuinfo_x86 *c)
#ifdef CONFIG_X86_64
	set_cpu_cap(c, X86_FEATURE_SYSENTER32);
#endif

	clear_sched_clock_stable();
}

static void init_centaur(struct cpuinfo_x86 *c)
+0 −3
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ static void default_init(struct cpuinfo_x86 *c)
			strcpy(c->x86_model_id, "386");
	}
#endif
	clear_sched_clock_stable();
}

static const struct cpu_dev default_cpu = {
@@ -1075,8 +1074,6 @@ static void identify_cpu(struct cpuinfo_x86 *c)
	 */
	if (this_cpu->c_init)
		this_cpu->c_init(c);
	else
		clear_sched_clock_stable();

	/* Disable the PN if appropriate */
	squash_the_stupid_serial_number(c);
+0 −1
Original line number Diff line number Diff line
@@ -184,7 +184,6 @@ static void early_init_cyrix(struct cpuinfo_x86 *c)
		set_cpu_cap(c, X86_FEATURE_CYRIX_ARR);
		break;
	}
	clear_sched_clock_stable();
}

static void init_cyrix(struct cpuinfo_x86 *c)
+0 −4
Original line number Diff line number Diff line
@@ -161,10 +161,6 @@ static void early_init_intel(struct cpuinfo_x86 *c)
	if (c->x86_power & (1 << 8)) {
		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
		set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
		if (check_tsc_unstable())
			clear_sched_clock_stable();
	} else {
		clear_sched_clock_stable();
	}

	/* Penwell and Cloverview have the TSC which doesn't sleep on S3 */
Loading