* [PATCH] sched/core: Fix arch_scale_freq_tick() on tickless systems
@ 2022-11-30 12:51 Yair Podemsky
2022-12-14 9:49 ` Valentin Schneider
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Yair Podemsky @ 2022-11-30 12:51 UTC (permalink / raw)
To: peterz, mingo, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, bristot, vschneid, rafael.j.wysocki,
ggherdovich, jlelli, mtosatti, nsaenz, linux-kernel
Cc: ypodemsk
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: e2b0d619b400 ("x86, sched: check for counters overflow in frequency invariant accounting")
Signed-off-by: Yair Podemsky <ypodemsk@redhat.com>
Suggested-by: "Peter Zijlstra (Intel)" <peterz@infradead.org>
---
V1 -> V2: solution approach was changed from detecting long tickless periods
to frequency invariant measurements on housekeeping cpus only.
Link: ee89073a1e9de11c7bd7726eb5da71a0e8795099.camel@redhat.com
---
kernel/sched/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index daff72f00385..1bb0a840c817 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5469,7 +5469,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);
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] sched/core: Fix arch_scale_freq_tick() on tickless systems
2022-11-30 12:51 [PATCH] sched/core: Fix arch_scale_freq_tick() on tickless systems Yair Podemsky
@ 2022-12-14 9:49 ` Valentin Schneider
2022-12-14 15:35 ` Giovanni Gherdovich
2023-01-07 11:36 ` [tip: sched/urgent] " tip-bot2 for Yair Podemsky
2 siblings, 0 replies; 5+ messages in thread
From: Valentin Schneider @ 2022-12-14 9:49 UTC (permalink / raw)
To: Yair Podemsky, peterz, mingo, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, bristot,
rafael.j.wysocki, ggherdovich, jlelli, mtosatti, nsaenz,
linux-kernel
Cc: ypodemsk
On 30/11/22 14:51, Yair Podemsky wrote:
> 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: e2b0d619b400 ("x86, sched: check for counters overflow in frequency invariant accounting")
> Signed-off-by: Yair Podemsky <ypodemsk@redhat.com>
> Suggested-by: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Reviewed-by: Valentin Schneider <vschneid@redhat.com>
> ---
> V1 -> V2: solution approach was changed from detecting long tickless periods
> to frequency invariant measurements on housekeeping cpus only.
> Link: ee89073a1e9de11c7bd7726eb5da71a0e8795099.camel@redhat.com
> ---
> kernel/sched/core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index daff72f00385..1bb0a840c817 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -5469,7 +5469,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);
> --
> 2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sched/core: Fix arch_scale_freq_tick() on tickless systems
2022-11-30 12:51 [PATCH] sched/core: Fix arch_scale_freq_tick() on tickless systems Yair Podemsky
2022-12-14 9:49 ` Valentin Schneider
@ 2022-12-14 15:35 ` Giovanni Gherdovich
2023-01-04 15:47 ` ypodemsk
2023-01-07 11:36 ` [tip: sched/urgent] " tip-bot2 for Yair Podemsky
2 siblings, 1 reply; 5+ messages in thread
From: Giovanni Gherdovich @ 2022-12-14 15:35 UTC (permalink / raw)
To: Yair Podemsky, peterz, mingo, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
rafael.j.wysocki, jlelli, mtosatti, nsaenz, linux-kernel
On Wed, 2022-11-30 at 14:51 +0200, Yair Podemsky wrote:
> 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: e2b0d619b400 ("x86, sched: check for counters overflow in frequency invariant accounting")
> Signed-off-by: Yair Podemsky <ypodemsk@redhat.com>
> Suggested-by: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Acked-by: Giovanni Gherdovich <ggherdovich@suse.cz>
> ---
> V1 -> V2: solution approach was changed from detecting long tickless periods
> to frequency invariant measurements on housekeeping cpus only.
> Link: ee89073a1e9de11c7bd7726eb5da71a0e8795099.camel@redhat.com
> ---
> kernel/sched/core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index daff72f00385..1bb0a840c817 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -5469,7 +5469,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);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sched/core: Fix arch_scale_freq_tick() on tickless systems
2022-12-14 15:35 ` Giovanni Gherdovich
@ 2023-01-04 15:47 ` ypodemsk
0 siblings, 0 replies; 5+ messages in thread
From: ypodemsk @ 2023-01-04 15:47 UTC (permalink / raw)
To: Giovanni Gherdovich, peterz, mingo, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
rafael.j.wysocki, jlelli, mtosatti, nsaenz, linux-kernel
Friendly ping
On Wed, 2022-12-14 at 16:35 +0100, Giovanni Gherdovich wrote:
> On Wed, 2022-11-30 at 14:51 +0200, Yair Podemsky wrote:
> > 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: e2b0d619b400 ("x86, sched: check for counters overflow in
> > frequency invariant accounting")
> > Signed-off-by: Yair Podemsky <ypodemsk@redhat.com>
> > Suggested-by: "Peter Zijlstra (Intel)" <peterz@infradead.org>
>
> Acked-by: Giovanni Gherdovich <ggherdovich@suse.cz>
>
> > ---
> > V1 -> V2: solution approach was changed from detecting long
> > tickless periods
> > to frequency invariant measurements on housekeeping cpus only.
> > Link: ee89073a1e9de11c7bd7726eb5da71a0e8795099.camel@redhat.com
> > ---
> > kernel/sched/core.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index daff72f00385..1bb0a840c817 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -5469,7 +5469,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);
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: sched/urgent] sched/core: Fix arch_scale_freq_tick() on tickless systems
2022-11-30 12:51 [PATCH] sched/core: Fix arch_scale_freq_tick() on tickless systems Yair Podemsky
2022-12-14 9:49 ` Valentin Schneider
2022-12-14 15:35 ` Giovanni Gherdovich
@ 2023-01-07 11:36 ` tip-bot2 for Yair Podemsky
2 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Yair Podemsky @ 2023-01-07 11:36 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel),
Yair Podemsky, Ingo Molnar, Valentin Schneider,
Giovanni Gherdovich, x86, linux-kernel
The following commit has been merged into the sched/urgent branch of tip:
Commit-ID: 7fb3ff22ad8772bbf0e3ce1ef3eb7b09f431807f
Gitweb: https://git.kernel.org/tip/7fb3ff22ad8772bbf0e3ce1ef3eb7b09f431807f
Author: Yair Podemsky <ypodemsk@redhat.com>
AuthorDate: Wed, 30 Nov 2022 14:51:21 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Sat, 07 Jan 2023 12:25:50 +01:00
sched/core: Fix arch_scale_freq_tick() on tickless systems
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: e2b0d619b400 ("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
---
kernel/sched/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 25b582b..965d813 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5504,7 +5504,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);
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-07 11:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-30 12:51 [PATCH] sched/core: Fix arch_scale_freq_tick() on tickless systems Yair Podemsky
2022-12-14 9:49 ` Valentin Schneider
2022-12-14 15:35 ` Giovanni Gherdovich
2023-01-04 15:47 ` ypodemsk
2023-01-07 11:36 ` [tip: sched/urgent] " tip-bot2 for Yair Podemsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).