Skip to content

Commit

Permalink
sched/core: Fix arch_scale_freq_tick() on tickless systems
Browse files Browse the repository at this point in the history
[ Upstream commit 7fb3ff2 ]

In order for the scheduler to be frequency invariant we measure the
ratio between the maximum CPU frequency and the actual CPU frequency.

During long tickless periods of time the calculations that keep track
of that might overflow, in the function scale_freq_tick():

  if (check_shl_overflow(acnt, 2*SCHED_CAPACITY_SHIFT, &acnt))
          goto error;

eventually forcing the kernel to disable the feature for all CPUs,
and show the warning message:

   "Scheduler frequency invariance went wobbly, disabling!".

Let's avoid that by limiting the frequency invariant calculations
to CPUs with regular tick.

Fixes: e2b0d61 ("x86, sched: check for counters overflow in frequency invariant accounting")
Suggested-by: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Signed-off-by: Yair Podemsky <ypodemsk@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Valentin Schneider <vschneid@redhat.com>
Acked-by: Giovanni Gherdovich <ggherdovich@suse.cz>
Link: https://lore.kernel.org/r/20221130125121.34407-1-ypodemsk@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yair Podemsky authored and gregkh committed Jan 18, 2023
1 parent d995fad commit 92b0051
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/sched/core.c
Expand Up @@ -5498,7 +5498,9 @@ void scheduler_tick(void)
unsigned long thermal_pressure;
u64 resched_latency;

arch_scale_freq_tick();
if (housekeeping_cpu(cpu, HK_TYPE_TICK))
arch_scale_freq_tick();

sched_clock_tick();

rq_lock(rq, &rf);
Expand Down

0 comments on commit 92b0051

Please sign in to comment.