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

Commit 128c434a authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull scheduler fixes from Thomas Gleixner:
 "This update provides:

   - make the scheduler clock switch to unstable mode smooth so the
     timestamps stay at microseconds granularity instead of switching to
     tick granularity.

   - unbreak perf test tsc by taking the new offset into account which
     was added in order to proveide better sched clock continuity

   - switching sched clock to unstable mode runs all clock related
     computations which affect the sched clock output itself from a work
     queue. In case of preemption sched clock uses half updated data and
     provides wrong timestamps. Keep the math in the protected context
     and delegate only the static key switch to workqueue context.

   - remove a duplicate header include"

* 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  sched/headers: Remove duplicate #include <linux/sched/debug.h> line
  sched/clock: Fix broken stable to unstable transfer
  sched/clock, x86/perf: Fix "perf test tsc"
  sched/clock: Fix clear_sched_clock_stable() preempt wobbly
parents 0a89b5eb 658b2995
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -2256,6 +2256,7 @@ void arch_perf_update_userpage(struct perf_event *event,
			       struct perf_event_mmap_page *userpg, u64 now)
			       struct perf_event_mmap_page *userpg, u64 now)
{
{
	struct cyc2ns_data *data;
	struct cyc2ns_data *data;
	u64 offset;


	userpg->cap_user_time = 0;
	userpg->cap_user_time = 0;
	userpg->cap_user_time_zero = 0;
	userpg->cap_user_time_zero = 0;
@@ -2263,11 +2264,13 @@ void arch_perf_update_userpage(struct perf_event *event,
		!!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED);
		!!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED);
	userpg->pmc_width = x86_pmu.cntval_bits;
	userpg->pmc_width = x86_pmu.cntval_bits;


	if (!sched_clock_stable())
	if (!using_native_sched_clock() || !sched_clock_stable())
		return;
		return;


	data = cyc2ns_read_begin();
	data = cyc2ns_read_begin();


	offset = data->cyc2ns_offset + __sched_clock_offset;

	/*
	/*
	 * Internal timekeeping for enabled/running/stopped times
	 * Internal timekeeping for enabled/running/stopped times
	 * is always in the local_clock domain.
	 * is always in the local_clock domain.
@@ -2275,7 +2278,7 @@ void arch_perf_update_userpage(struct perf_event *event,
	userpg->cap_user_time = 1;
	userpg->cap_user_time = 1;
	userpg->time_mult = data->cyc2ns_mul;
	userpg->time_mult = data->cyc2ns_mul;
	userpg->time_shift = data->cyc2ns_shift;
	userpg->time_shift = data->cyc2ns_shift;
	userpg->time_offset = data->cyc2ns_offset - now;
	userpg->time_offset = offset - now;


	/*
	/*
	 * cap_user_time_zero doesn't make sense when we're using a different
	 * cap_user_time_zero doesn't make sense when we're using a different
@@ -2283,7 +2286,7 @@ void arch_perf_update_userpage(struct perf_event *event,
	 */
	 */
	if (!event->attr.use_clockid) {
	if (!event->attr.use_clockid) {
		userpg->cap_user_time_zero = 1;
		userpg->cap_user_time_zero = 1;
		userpg->time_zero = data->cyc2ns_offset;
		userpg->time_zero = offset;
	}
	}


	cyc2ns_read_end(data);
	cyc2ns_read_end(data);
+2 −0
Original line number Original line Diff line number Diff line
@@ -12,6 +12,8 @@ extern int recalibrate_cpu_khz(void);


extern int no_timer_check;
extern int no_timer_check;


extern bool using_native_sched_clock(void);

/*
/*
 * We use the full linear equation: f(x) = a + b*x, in order to allow
 * We use the full linear equation: f(x) = a + b*x, in order to allow
 * a continuous function in the face of dynamic freq changes.
 * a continuous function in the face of dynamic freq changes.
+2 −2
Original line number Original line Diff line number Diff line
@@ -328,7 +328,7 @@ unsigned long long sched_clock(void)
	return paravirt_sched_clock();
	return paravirt_sched_clock();
}
}


static inline bool using_native_sched_clock(void)
bool using_native_sched_clock(void)
{
{
	return pv_time_ops.sched_clock == native_sched_clock;
	return pv_time_ops.sched_clock == native_sched_clock;
}
}
@@ -336,7 +336,7 @@ static inline bool using_native_sched_clock(void)
unsigned long long
unsigned long long
sched_clock(void) __attribute__((alias("native_sched_clock")));
sched_clock(void) __attribute__((alias("native_sched_clock")));


static inline bool using_native_sched_clock(void) { return true; }
bool using_native_sched_clock(void) { return true; }
#endif
#endif


int check_tsc_unstable(void)
int check_tsc_unstable(void)
+0 −1
Original line number Original line Diff line number Diff line
@@ -28,7 +28,6 @@
#include <linux/module.h>
#include <linux/module.h>
#include <linux/sched/signal.h>
#include <linux/sched/signal.h>
#include <linux/sched/debug.h>
#include <linux/sched/debug.h>
#include <linux/sched/debug.h>
#include <linux/tty.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/tty_flip.h>
#include <linux/mm.h>
#include <linux/mm.h>
+7 −6
Original line number Original line Diff line number Diff line
@@ -54,15 +54,16 @@ static inline u64 local_clock(void)
}
}
#else
#else
extern void sched_clock_init_late(void);
extern void sched_clock_init_late(void);
/*
 * Architectures can set this to 1 if they have specified
 * CONFIG_HAVE_UNSTABLE_SCHED_CLOCK in their arch Kconfig,
 * but then during bootup it turns out that sched_clock()
 * is reliable after all:
 */
extern int sched_clock_stable(void);
extern int sched_clock_stable(void);
extern void clear_sched_clock_stable(void);
extern void clear_sched_clock_stable(void);


/*
 * When sched_clock_stable(), __sched_clock_offset provides the offset
 * between local_clock() and sched_clock().
 */
extern u64 __sched_clock_offset;


extern void sched_clock_tick(void);
extern void sched_clock_tick(void);
extern void sched_clock_idle_sleep_event(void);
extern void sched_clock_idle_sleep_event(void);
extern void sched_clock_idle_wakeup_event(u64 delta_ns);
extern void sched_clock_idle_wakeup_event(u64 delta_ns);
Loading