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

Commit c5c90f60 authored by Steve Muckle's avatar Steve Muckle
Browse files

sched: do not set window until sched_clock is fully initialized



The system initially uses a jiffy-based sched clock. When the platform
registers a new timer for sched_clock, sched_clock can jump backwards.
Once sched_clock_postinit() runs it should be safe to rely on it.

Also sched_clock_cpu() relies on completion of sched_clock_init()
and until that happens sched_clock_cpu() returns zero. This is used
in the irq accounting path which window-based stats relies upon.
So do not set window_start until sched_clock_cpu() is working.

Change-Id: Ided349de8f8554f80a027ace0f63ea52b1c38c68
Signed-off-by: default avatarSteve Muckle <smuckle@codeaurora.org>
parent 51c75088
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1973,6 +1973,7 @@ extern u64 sched_clock_cpu(int cpu);


extern void sched_clock_init(void);
extern int sched_clock_initialized(void);

#ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
static inline void sched_clock_tick(void)
+2 −1
Original line number Diff line number Diff line
@@ -1900,7 +1900,8 @@ static inline void set_window_start(struct rq *rq)
	int cpu = cpu_of(rq);
	struct rq *sync_rq = cpu_rq(sync_cpu);

	if (rq->window_start || !sched_enable_hmp)
	if (rq->window_start || !sched_enable_hmp ||
	    !sched_clock_initialized() || !sched_clock_cpu(cpu))
		return;

	if (cpu == sync_cpu) {
+8 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ struct clock_data {

static struct hrtimer sched_clock_timer;
static int irqtime = -1;
static int initialized;

core_param(irqtime, irqtime, int, 0400);

@@ -178,6 +179,11 @@ unsigned long long notrace sched_clock(void)
	return sched_clock_func();
}

int sched_clock_initialized(void)
{
	return initialized;
}

void __init sched_clock_postinit(void)
{
	/*
@@ -196,6 +202,8 @@ void __init sched_clock_postinit(void)
	hrtimer_init(&sched_clock_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	sched_clock_timer.function = sched_clock_poll;
	hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL);

	initialized = 1;
}

static int sched_clock_suspend(void)