2024-03-07 08:59:55

by Shrikanth Hegde

[permalink] [raw]
Subject: [PATCH v6 0/3] sched/fair: Limit access to overutilized

When running an ISV workload on a large system (240 Cores, SMT8), it was
observed from perf profile that newidle_balance and enqueue_task_fair
were consuming more cycles. Perf annotate showed that most of the time
was spent on accessing overutilized field of root domain. Similar perf profile
was simulated by making some changes to stress-ng --wait. Both
newidle_balance and enqueue_task_fair consume close to 5-7%.

Overutilized was added for EAS(Energy aware scheduler) to decide whether
to do load balance or not. Simultaneous access to overutilized by
multiple CPUs lead cache invalidations due to true sharing. Updating
overutilized is not required for non-EAS platforms. Since overutilized and
overload are part of the same cacheline, there is false sharing as well.

Patch 1/3 - Main patch. It helps in reducing the above said issue.
Both the functions don't show up in the profile. With patch comparison is in
changelog. With the patch stated problem in the ISV workload also got
solved and throughput has improved.
Patch 2/3 - Code refactoring to use the helper function instead of
direct access of the field. Keeping this patch so patch 3/3 becomes
easier to understand. Depends on 1/3.
Patch 3/3 - Refactoring the code since most of the patterns are observed
are eas && !overutilzed. Changed the helper function accordingly.
Depends on 2/3.

More details can be found in cover letter of v1.

v5 -> v6:
- Mades minor changes for !CONFIG_SMP cases as pointed out by Vincent.
v4 -> v5:
- Added EAS check inside helper functions instead of sprinkling it
around. EAS check is static branch at best. So that keeps the code
simpler.
- added EAS check inside cpu_overutilized as suggested by Qais.
- Added patch 3 since most of the code does eas && !overutilized
pattern as suggested by Vincent.
v3 -> v4:
- corrected a mistake where EAS check was missed.
v2 -> v3:
- Pierre and Dietmar suggested we could add one more EAS check before
calling cpu_overutilized. That makes sense since that value is not used
anyway in Non-EAS case.
- Refactored the code as dietmar suggested to avoid additional call to
sched_energy_enabled().
- Minor edits to change log.
v1 -> v2:
Chen Yu pointed out minor issue in code. Corrected that code and updated
the changelog.

v1: https://lore.kernel.org/lkml/[email protected]/
v2: https://lore.kernel.org/lkml/[email protected]/
v3: https://lore.kernel.org/lkml/[email protected]/
v4: https://lore.kernel.org/lkml/[email protected]/
v5: https://lore.kernel.org/lkml/[email protected]/

Shrikanth Hegde (3):
sched/fair: Add EAS checks before updating overutilized
sched/fair: Use helper function to access rd->overutilized
sched/fair: Combine EAS check with overutilized access

kernel/sched/fair.c | 72 ++++++++++++++++++++++++++++-----------------
1 file changed, 45 insertions(+), 27 deletions(-)

--
2.39.3



2024-03-14 16:47:22

by Valentin Schneider

[permalink] [raw]
Subject: Re: [PATCH v6 0/3] sched/fair: Limit access to overutilized

On 07/03/24 14:27, Shrikanth Hegde wrote:
> When running an ISV workload on a large system (240 Cores, SMT8), it was
> observed from perf profile that newidle_balance and enqueue_task_fair
> were consuming more cycles. Perf annotate showed that most of the time
> was spent on accessing overutilized field of root domain. Similar perf profile
> was simulated by making some changes to stress-ng --wait. Both
> newidle_balance and enqueue_task_fair consume close to 5-7%.
>
> Overutilized was added for EAS(Energy aware scheduler) to decide whether
> to do load balance or not. Simultaneous access to overutilized by
> multiple CPUs lead cache invalidations due to true sharing. Updating
> overutilized is not required for non-EAS platforms. Since overutilized and
> overload are part of the same cacheline, there is false sharing as well.
>
> Patch 1/3 - Main patch. It helps in reducing the above said issue.
> Both the functions don't show up in the profile. With patch comparison is in
> changelog. With the patch stated problem in the ISV workload also got
> solved and throughput has improved.
> Patch 2/3 - Code refactoring to use the helper function instead of
> direct access of the field. Keeping this patch so patch 3/3 becomes
> easier to understand. Depends on 1/3.
> Patch 3/3 - Refactoring the code since most of the patterns are observed
> are eas && !overutilzed. Changed the helper function accordingly.
> Depends on 2/3.

Reviewed-by: Valentin Schneider <[email protected]>