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

Commit 3df29117 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Greg Kroah-Hartman
Browse files

tick/sched: Optimize tick_do_update_jiffies64() further



[ Upstream commit 7a35bf2a6a871cd0252cd371d741e7d070b53af9 ]

Now that it's clear that there is always one tick to account, simplify the
calculations some more.

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20201117132006.565663056@linutronix.de


Stable-dep-of: e9523a0d8189 ("tick/common: Align tick period with the HZ tick.")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent b6fe34d9
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ static ktime_t last_jiffies_update;
 */
static void tick_do_update_jiffies64(ktime_t now)
{
	unsigned long ticks = 0;
	unsigned long ticks = 1;
	ktime_t delta;

	/*
@@ -91,20 +91,21 @@ static void tick_do_update_jiffies64(ktime_t now)

	write_seqcount_begin(&jiffies_seq);

	last_jiffies_update = ktime_add(last_jiffies_update, tick_period);

	delta = ktime_sub(now, tick_next_period);
	if (unlikely(delta >= tick_period)) {
		/* Slow path for long idle sleep times */
		s64 incr = ktime_to_ns(tick_period);

		ticks = ktime_divns(delta, incr);
		ticks += ktime_divns(delta, incr);

		last_jiffies_update = ktime_add_ns(last_jiffies_update,
						   incr * ticks);
	} else {
		last_jiffies_update = ktime_add(last_jiffies_update,
						tick_period);
	}

	do_timer(++ticks);
	do_timer(ticks);

	/*
	 * Keep the tick_next_period variable up to date.  WRITE_ONCE()