Skip to contentSkip to conversation

Cache-aware scheduling does not work well with amd big/little cores

DISCUSSION Klaus Kusche 4 participants 21 messages Aug 29 – Sep 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello,

I'm running linux on an AMD Ryzen HX 370.
I use Gentoo and compile a lot of things (including the kernel) with Clang using full LTO, which results in a single LTO process running for minutes on an otherwise idle processor.

Before Cache-aware scheduling was introduced,
AMD's pstate driver informed the scheduler about big and little cores, and the scheduler always moved those LTO processes to a big/fast core.

Now, the cache-aware scheduling takes precedence over big/little
scheduling: All big cores form one L3 cache domain, and all little cores form the other L3 cache domain.

When a process is started on a little core (and LTO is in most cases), it will no longer be moved to a big core,
even if it runs for minutes and all big cores are idle.

In case of LTO this hurts twice and badly
(slows down LTO not just noticeably, but dramatically:
In total, any compilation with LTO-linking takes much longer compared to earlier kernels without cache-aware scheduling):

* The little cores run slower (3.3 GHz instead of 5.1 GHz).

* LTO linking is very cache intensive,
and the L3 cache of the little cores is only half the size (8 MB) of the L3 cache of the big cores (16 MB).

So if a big core is idling, and a process on a little core is long-running, big/little scheduling should overrule cache-aware scheduling and move that process to a big core, even if this moves the process to another cache domain.

Greetings

Signature · 5 lines
Prof. Dr. Klaus Kusche
Privat: Söllmnitz 32 d, D-07554 Gera/Söllmnitz
036695/859909 [email protected] https://www.computerix.info
Dienstlich: DHGE Gera, Weg der Freundschaft 4, D-07546 Gera
[email protected] https://www.dhge.de
#1 lore raw

Add a few others who have worked on CAS.

Quoted 32 lines · Klaus Kusche

Hello,

I'm running linux on an AMD Ryzen HX 370.
I use Gentoo and compile a lot of things (including the kernel) with Clang using full LTO, which results in a single LTO process running for minutes on an otherwise idle processor.

Before Cache-aware scheduling was introduced,
AMD's pstate driver informed the scheduler about big and little cores, and the scheduler always moved those LTO processes to a big/fast core.

Now, the cache-aware scheduling takes precedence over big/little
scheduling: All big cores form one L3 cache domain, and all little cores form the other L3 cache domain.

When a process is started on a little core (and LTO is in most cases), it will no longer be moved to a big core,
even if it runs for minutes and all big cores are idle.

In case of LTO this hurts twice and badly
(slows down LTO not just noticeably, but dramatically:
In total, any compilation with LTO-linking takes much longer compared to earlier kernels without cache-aware scheduling):

* The little cores run slower (3.3 GHz instead of 5.1 GHz).

* LTO linking is very cache intensive,
and the L3 cache of the little cores is only half the size (8 MB) of the L3 cache of the big cores (16 MB).

Quoted 7 lines

So if a big core is idling, and a process on a little core is long-running, big/little scheduling should overrule cache-aware scheduling and move that process to a big core, even if this moves the process to another cache domain.

Greetings

Not so sure if it would help this case but I will note there is a debugfs knob you might be able to use called aggr_tolerance (it was introduced in c1e7fe5e75ed11fa85368e5a186472afd3858f3a if you want to read more about it's background).

#2 lore raw

Hi,

Quoted 40 lines · Mario Limonciello

Add a few others who have worked on CAS.

Quoted 37 lines · Klaus Kusche

Hello,

I'm running linux on an AMD Ryzen HX 370.
I use Gentoo and compile a lot of things (including the kernel) with Clang using full LTO, which results in a single LTO process running for minutes on an otherwise idle processor.

Before Cache-aware scheduling was introduced,
AMD's pstate driver informed the scheduler about big and little cores, and the scheduler always moved those LTO processes to a big/fast core.

Now, the cache-aware scheduling takes precedence over big/little
scheduling: All big cores form one L3 cache domain, and all little cores form the other L3 cache domain.

When a process is started on a little core (and LTO is in most cases), it will no longer be moved to a big core,
even if it runs for minutes and all big cores are idle.

In case of LTO this hurts twice and badly
(slows down LTO not just noticeably, but dramatically:
In total, any compilation with LTO-linking takes much longer compared to earlier kernels without cache-aware scheduling):

* The little cores run slower (3.3 GHz instead of 5.1 GHz).

* LTO linking is very cache intensive,
and the L3 cache of the little cores is only half the size (8 MB) of the L3 cache of the big cores (16 MB).

So if a big core is idling, and a process on a little core is long-running, big/little scheduling should overrule cache-aware scheduling and move that process to a big core, even if this moves the process to another cache domain.

Quoted 4 lines
Quoted 2 lines

Greetings

Not so sure if it would help this case but I will note there is a debugfs knob you might be able to use called aggr_tolerance (it was introduced in c1e7fe5e75ed11fa85368e5a186472afd3858f3a if you want to read more about it's background).

Thanks Mario and Kusche for bringing this issue up. Yes, we can tune Cache Aware scheduling via debugfs or even turn it off. The issue in current code is that the cache aware scheduling overwrites the strategy of asymmetric scheduling, and Ricardo also found this issue previous and there is a patch to address that, by honoring CPU capacity during cache aware scheduling, for the **misfit** task. It would be helpful to see if this patch makes things better:
https://lore.kernel.org/lkml/[email protected]/

thanks,
Chenyu

#3 lore raw

Hello,

both patches in combination seem to have the desired effect.

But I just look at a bar graph showing the current load of each core.
The graph suggests that long-running CPU-intensive processes migrate to fast cores when fast cores become available. And I have the impression that LTO compilations finish significantly faster now.

I don't have exact numbers or benchmarks.

P.S.: I'm currently on holiday (for three weeks). So my responses will be much slower than usual.

Greetings

Prof. Dr. Klaus Kusche
Privat: Söllmnitz 32 d, D-07554 Gera/Söllmnitz 036695/859909 [email protected] https://www.computerix.info
Dienstlich: DHGE Gera, Weg der Freundschaft 4, D-07546 Gera [email protected] https://www.dhge.de

Quoted 63 lines · Yu C

Hi,

Quoted 40 lines · Mario Limonciello

Add a few others who have worked on CAS.

Quoted 37 lines · Klaus Kusche

Hello,

I'm running linux on an AMD Ryzen HX 370.
I use Gentoo and compile a lot of things (including the kernel) with Clang using full LTO, which results in a single LTO process running for minutes on an otherwise idle processor.

Before Cache-aware scheduling was introduced,
AMD's pstate driver informed the scheduler about big and little cores, and the scheduler always moved those LTO processes to a big/fast core.

Now, the cache-aware scheduling takes precedence over big/little
scheduling: All big cores form one L3 cache domain, and all little cores form the other L3 cache domain.

When a process is started on a little core (and LTO is in most cases), it will no longer be moved to a big core,
even if it runs for minutes and all big cores are idle.

In case of LTO this hurts twice and badly
(slows down LTO not just noticeably, but dramatically:
In total, any compilation with LTO-linking takes much longer compared to earlier kernels without cache-aware scheduling):

* The little cores run slower (3.3 GHz instead of 5.1 GHz).

* LTO linking is very cache intensive,
and the L3 cache of the little cores is only half the size (8 MB) of the L3 cache of the big cores (16 MB).

So if a big core is idling, and a process on a little core is long-running, big/little scheduling should overrule cache-aware scheduling and move that process to a big core, even if this moves the process to another cache domain.

Quoted 7 lines
Quoted 2 lines

Greetings

Not so sure if it would help this case but I will note there is a debugfs knob you might be able to use called aggr_tolerance (it was introduced in c1e7fe5e75ed11fa85368e5a186472afd3858f3a if you want to read more about it's background).

Thanks Mario and Kusche for bringing this issue up. Yes, we can tune Cache Aware scheduling via debugfs or even turn it off. The issue in current code is that the cache aware scheduling overwrites the strategy of asymmetric scheduling,
and Ricardo also found this issue previous and there is a patch to address that, by honoring CPU capacity during cache aware scheduling, for the **misfit**
task. It would be helpful to see if this patch makes things better:
https://lore.kernel.org/lkml/[email protected]/

thanks,
Chenyu

#4 lore raw
Quoted 4 lines · Klaus Kusche

Hello,

both patches in combination seem to have the desired effect.

Quoted 8 lines

But I just look at a bar graph showing the current load of each core.
The graph suggests that long-running CPU-intensive processes migrate to fast cores when fast cores become available. And I have the impression that LTO compilations finish significantly faster now.

I don't have exact numbers or benchmarks.

Thanks for testing the fix.

If you just apply https://lore.kernel.org/lkml/[email protected]/,
with default aggr_tolerance, what numbers do you see?

That will be helpful for further tuning. Thanks.

Tim

#5 lore raw

This would need some more testing efforts,
because all my kernels are built without debugfs (using an earlier version of Mario's patch),
and without Mario's patch and without debugfs,
I don't get any big/little scheduling at all.
So I'd need to build and test with debugfs (tomorrow I'm on a mountain tour, perhaps later this week).

Prof. Dr. Klaus Kusche
Privat: Söllmnitz 32 d, D-07554 Gera/Söllmnitz 036695/859909 [email protected] https://www.computerix.info
Dienstlich: DHGE Gera, Weg der Freundschaft 4, D-07546 Gera [email protected] https://www.dhge.de

Quoted 22 lines · Tim Chen
Quoted 4 lines · Klaus Kusche

Hello,

both patches in combination seem to have the desired effect.

Quoted 8 lines

But I just look at a bar graph showing the current load of each core.
The graph suggests that long-running CPU-intensive processes migrate to fast cores when fast cores become available. And I have the impression that LTO compilations finish significantly faster now.

I don't have exact numbers or benchmarks.

Thanks for testing the fix.

If you just apply https://lore.kernel.org/lkml/[email protected]/,
with default aggr_tolerance, what numbers do you see?

That will be helpful for further tuning. Thanks.

Tim

#6 lore raw
Quoted 9 lines · Klaus Kusche

This would need some more testing efforts,
because all my kernels are built without debugfs (using an earlier version of Mario's patch),
and without Mario's patch and without debugfs,
I don't get any big/little scheduling at all.
So I'd need to build and test with debugfs (tomorrow I'm on a mountain tour, perhaps later this week).

The debugfs patch doesn't really add anything tangible. I'd say tests with that and debugfs turned off are just as valid as tests with no patch and debugfs turned on.

#7 lore raw
In reply to Tim Chen

Hello,

Quoted 14 lines · Tim Chen
Quoted 4 lines · Klaus Kusche

Hello,

both patches in combination seem to have the desired effect.

Quoted 8 lines

But I just look at a bar graph showing the current load of each core.
The graph suggests that long-running CPU-intensive processes migrate to fast cores when fast cores become available. And I have the impression that LTO compilations finish significantly faster now.

I don't have exact numbers or benchmarks.

Quoted 8 lines

Thanks for testing the fix.

If you just apply https://lore.kernel.org/lkml/[email protected]/,
with default aggr_tolerance, what numbers do you see?

That will be helpful for further tuning. Thanks.

Tim

I did some quick testing (no perfect benchmark environment, just checking runtime and CPU consumption with "time").

I timed a kernel build (-j 24 and full lto, my own .config) and an application build (also with a lot of parallelism) with three different kernels:

a) Cache aware scheduling completely configured off

b) Cache aware scheduling turned on, but without patch

c) Cache aware scheduling turned on, with patch

Big/little scheduling was always on, Mario's patch was always applied
(without it, results are significantly worse, because I use kernels without debugfs,
so big/little scheduling is off without the patch).

Results:

There is no significant difference between b) and c) (<= 1 % wallclock time)
Sometimes b) is better, sometimes c) is better, I'd say the differences are below the accuracy of my tests.

But a) was reproducibly better than b) and c)
w.r.t. wallclock time: 2-2.6 %
It was also very slightly better w.r.t. total kernel CPU seconds. The results w.r.t. total usermode CPU seconds varied too much. (I always ran the application build twice,
and for all a), b) and c), the second run consumed significantly more usermode CPU seconds,
but took a little less wallclock time - I don't know why).

So in short, at least for the two build benchmarks I made, and with respect to the wallclock time they took, AMD Ryzen HX 370 does slightly better completely *without* cache aware scheduling, but cache aware scheduling looses less than 3 %,
both with and without the patch.

The big difference I observed when 7.2 came out
was perhaps due to the fact
that the older version of Mario's patch I had
did not apply correctly or did not work as expected with 7.2.

Greetings

Signature · 5 lines
Prof. Dr. Klaus Kusche
Privat: Söllmnitz 32 d, D-07554 Gera/Söllmnitz
036695/859909 [email protected] https://www.computerix.info
Dienstlich: DHGE Gera, Weg der Freundschaft 4, D-07546 Gera
[email protected] https://www.dhge.de
#8 lore raw
Quoted 35 lines · Klaus Kusche

Hello,

Quoted 14 lines · Tim Chen
Quoted 4 lines · Klaus Kusche

Hello,

both patches in combination seem to have the desired effect.

Quoted 8 lines

But I just look at a bar graph showing the current load of each core.
The graph suggests that long-running CPU-intensive processes migrate to fast cores when fast cores become available. And I have the impression that LTO compilations finish significantly faster now.

I don't have exact numbers or benchmarks.

Quoted 8 lines

Thanks for testing the fix.

If you just apply https://lore.kernel.org/lkml/[email protected]/,
with default aggr_tolerance, what numbers do you see?

That will be helpful for further tuning. Thanks.

Tim

I did some quick testing (no perfect benchmark environment, just checking runtime and CPU consumption with "time").

I timed a kernel build (-j 24 and full lto, my own .config) and an application build (also with a lot of parallelism) with three different kernels:

a) Cache aware scheduling completely configured off

Quoted 7 lines

b) Cache aware scheduling turned on, but without patch

c) Cache aware scheduling turned on, with patch

Big/little scheduling was always on,
Mario's patch was always applied
(without it, results are significantly worse,

Sorry, I am a bit confused. You mentioned later the result for (b) and (c) are about the same with or without the patch exposing debugfs (commit c1e7fe5e75ed11fa85368e5a186472afd3858f3a Mario mentioned in another mail).
But here you say the result is much worse without Mario's patch. Is Mario's patch the one above or some other patch?

Quoted 7 lines

because I use kernels without debugfs,
so big/little scheduling is off without the patch).

Results:

There is no significant difference between b) and c) (<= 1 % wallclock time)

Yes, I don't expect difference between (b) and (c). My understanding is the patch in question is to only expose the default cache aware parameters via debugfs but don't acutally change them.

Quoted 11 lines

Sometimes b) is better, sometimes c) is better, I'd say the differences are below the accuracy of my tests.

But a) was reproducibly better than b) and c)
w.r.t. wallclock time: 2-2.6 %
It was also very slightly better w.r.t. total kernel CPU seconds. The results w.r.t. total usermode CPU seconds varied too much. (I always ran the application build twice,
and for all a), b) and c), the second run consumed significantly more usermode CPU seconds,
but took a little less wallclock time - I don't know why).

Will have to look around to see if we have some similar CPUs as HX-370. My understanding is that the 4 big cores are in one L3 and the 8 small cores are in another L3.

BTW, we have also found two issues with the active load balance paths for CAS that need fixes. You may want to add those patches and see if they are helpful to improve things.

Active load balance fixes:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

Tim

Quoted 13 lines

So in short, at least for the two build benchmarks I made, and with respect to the wallclock time they took, AMD Ryzen HX 370 does slightly better completely *without* cache aware scheduling, but cache aware scheduling looses less than 3 %,
both with and without the patch.

The big difference I observed when 7.2 came out
was perhaps due to the fact
that the older version of Mario's patch I had
did not apply correctly or did not work as expected with 7.2.

Greetings

#9 lore raw

Hello,

Quoted 17 lines · Tim Chen
Quoted 9 lines

I did some quick testing (no perfect benchmark environment, just checking runtime and CPU consumption with "time").

I timed a kernel build (-j 24 and full lto, my own .config) and an application build (also with a lot of parallelism) with three different kernels:

a) Cache aware scheduling completely configured off

Quoted 7 lines

b) Cache aware scheduling turned on, but without patch

c) Cache aware scheduling turned on, with patch

Big/little scheduling was always on,
Mario's patch was always applied
(without it, results are significantly worse,

Quoted 6 lines

Sorry, I am a bit confused. You mentioned later the result for (b) and (c) are about the same with or without the patch exposing debugfs (commit c1e7fe5e75ed11fa85368e5a186472afd3858f3a Mario mentioned in another mail).
But here you say the result is much worse without Mario's patch. Is Mario's patch the one above or some other patch?

The with/without patch in (b) and (c)
refers to the patch you sent on 31/08/2026
( https://lore.kernel.org/lkml/[email protected]/ ), not to Mario's patch.

Quoted 25 lines
Quoted 7 lines

because I use kernels without debugfs,
so big/little scheduling is off without the patch).

Results:

There is no significant difference between b) and c) (<= 1 % wallclock time)

Yes, I don't expect difference between (b) and (c). My understanding is the patch in question is to only expose the default cache aware parameters via debugfs but don't acutally change them.

Quoted 11 lines

Sometimes b) is better, sometimes c) is better, I'd say the differences are below the accuracy of my tests.

But a) was reproducibly better than b) and c)
w.r.t. wallclock time: 2-2.6 %
It was also very slightly better w.r.t. total kernel CPU seconds. The results w.r.t. total usermode CPU seconds varied too much. (I always ran the application build twice,
and for all a), b) and c), the second run consumed significantly more usermode CPU seconds,
but took a little less wallclock time - I don't know why).

Quoted 3 lines

Will have to look around to see if we have some similar CPUs as HX-370. My understanding is that the 4 big cores are in one L3 and the 8 small cores are in another L3.

Yes, as far as I know, it has 16 MB L3 cache for the 4 big cores and 8 MB L3 cache for the 8 little cores.

Quoted 3 lines

BTW, we have also found two issues with the active load balance paths for CAS that need fixes. You may want to add those patches and see if they are helpful to improve things.

Most likely not within the next few days.
I'm still on holiday and quite busy:
Ars Electronica Festival in Linz.

Quoted 3 lines

Active load balance fixes:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

Signature · 5 lines
Prof. Dr. Klaus Kusche
Privat: Söllmnitz 32 d, D-07554 Gera/Söllmnitz
036695/859909 [email protected] https://www.computerix.info
Dienstlich: DHGE Gera, Weg der Freundschaft 4, D-07546 Gera
[email protected] https://www.dhge.de
#10 lore raw
Quoted 28 lines · Klaus Kusche

Hello,

Quoted 17 lines · Tim Chen
Quoted 9 lines

I did some quick testing (no perfect benchmark environment, just checking runtime and CPU consumption with "time").

I timed a kernel build (-j 24 and full lto, my own .config) and an application build (also with a lot of parallelism) with three different kernels:

a) Cache aware scheduling completely configured off

Quoted 7 lines

b) Cache aware scheduling turned on, but without patch

c) Cache aware scheduling turned on, with patch

Big/little scheduling was always on,
Mario's patch was always applied
(without it, results are significantly worse,

Quoted 6 lines

Sorry, I am a bit confused. You mentioned later the result for (b) and (c) are about the same with or without the patch exposing debugfs (commit c1e7fe5e75ed11fa85368e5a186472afd3858f3a Mario mentioned in another mail).
But here you say the result is much worse without Mario's patch. Is Mario's patch the one above or some other patch?

Quoted 5 lines

The with/without patch in (b) and (c)
refers to the patch you sent on 31/08/2026
( https://lore.kernel.org/lkml/[email protected]/ ), not to Mario's patch.

Just to clarify Mario's patch in this context refers to the fix to ITMT/debugfs fixes as Klaus doesn't nominally enable debugfs in Kconfig:

eaece4849991d62fcd6f46637c55dcce00e25d70

Quoted 44 lines
Quoted 25 lines
Quoted 7 lines

because I use kernels without debugfs,
so big/little scheduling is off without the patch).

Results:

There is no significant difference between b) and c) (<= 1 % wallclock time)

Yes, I don't expect difference between (b) and (c). My understanding is the patch in question is to only expose the default cache aware parameters via debugfs but don't acutally change them.

Quoted 11 lines

Sometimes b) is better, sometimes c) is better, I'd say the differences are below the accuracy of my tests.

But a) was reproducibly better than b) and c)
w.r.t. wallclock time: 2-2.6 %
It was also very slightly better w.r.t. total kernel CPU seconds. The results w.r.t. total usermode CPU seconds varied too much. (I always ran the application build twice,
and for all a), b) and c), the second run consumed significantly more usermode CPU seconds,
but took a little less wallclock time - I don't know why).

Quoted 3 lines

Will have to look around to see if we have some similar CPUs as HX-370. My understanding is that the 4 big cores are in one L3 and the 8 small cores are in another L3.

Yes, as far as I know, it has 16 MB L3 cache for the 4 big cores and 8 MB L3 cache for the 8 little cores.

Quoted 3 lines

BTW, we have also found two issues with the active load balance paths for CAS that need fixes. You may want to add those patches and see if they are helpful to improve things.

Most likely not within the next few days.
I'm still on holiday and quite busy:
Ars Electronica Festival in Linz.

Quoted 3 lines

Active load balance fixes:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

#11 lore raw
Quoted 36 lines · Mario Limonciello
Quoted 28 lines · Klaus Kusche

Hello,

Quoted 17 lines · Tim Chen
Quoted 9 lines

I did some quick testing (no perfect benchmark environment, just checking runtime and CPU consumption with "time").

I timed a kernel build (-j 24 and full lto, my own .config) and an application build (also with a lot of parallelism) with three different kernels:

a) Cache aware scheduling completely configured off

Quoted 7 lines

b) Cache aware scheduling turned on, but without patch

c) Cache aware scheduling turned on, with patch

Big/little scheduling was always on,
Mario's patch was always applied
(without it, results are significantly worse,

Quoted 6 lines

Sorry, I am a bit confused. You mentioned later the result for (b) and (c) are about the same with or without the patch exposing debugfs (commit c1e7fe5e75ed11fa85368e5a186472afd3858f3a Mario mentioned in another mail).
But here you say the result is much worse without Mario's patch. Is Mario's patch the one above or some other patch?

Quoted 5 lines

The with/without patch in (b) and (c)
refers to the patch you sent on 31/08/2026
( https://lore.kernel.org/lkml/[email protected]/ ), not to Mario's patch.

Quoted 5 lines

Just to clarify Mario's patch in this context refers to the fix to ITMT/debugfs fixes as Klaus doesn't nominally enable debugfs in Kconfig:

eaece4849991d62fcd6f46637c55dcce00e25d70

Ricardo reminded me that AMD's hybrid CPU relies on SD_ASYM_PACKING instead of SD_ASYM_CPUCAPACITY. So the patch I pointed to
(https://lore.kernel.org/lkml/[email protected]/)
only fixes the SD_ASYM_CPUCAPACITY case and would not have an effect on your test system.

The fact that ITMT needs to be turned on to improve performance also point in that direction.

There was a bug that Chen Yu fixes for ITMT compatability with cache aware scheduling. It prevents a task from getting stuck in the wrong LLC in the ITMT case
(https://lore.kernel.org/lkml/[email protected]/).
Klaus, Can you apply that with Mario's ITMT/debugfs patch to see if that improves performance on your system?

Tim

Quoted 45 lines
Quoted 44 lines
Quoted 25 lines
Quoted 7 lines

because I use kernels without debugfs,
so big/little scheduling is off without the patch).

Results:

There is no significant difference between b) and c) (<= 1 % wallclock time)

Yes, I don't expect difference between (b) and (c). My understanding is the patch in question is to only expose the default cache aware parameters via debugfs but don't acutally change them.

Quoted 11 lines

Sometimes b) is better, sometimes c) is better, I'd say the differences are below the accuracy of my tests.

But a) was reproducibly better than b) and c)
w.r.t. wallclock time: 2-2.6 %
It was also very slightly better w.r.t. total kernel CPU seconds. The results w.r.t. total usermode CPU seconds varied too much. (I always ran the application build twice,
and for all a), b) and c), the second run consumed significantly more usermode CPU seconds,
but took a little less wallclock time - I don't know why).

Quoted 3 lines

Will have to look around to see if we have some similar CPUs as HX-370. My understanding is that the 4 big cores are in one L3 and the 8 small cores are in another L3.

Yes, as far as I know, it has 16 MB L3 cache for the 4 big cores and 8 MB L3 cache for the 8 little cores.

Quoted 3 lines

BTW, we have also found two issues with the active load balance paths for CAS that need fixes. You may want to add those patches and see if they are helpful to improve things.

Most likely not within the next few days.
I'm still on holiday and quite busy:
Ars Electronica Festival in Linz.

Quoted 3 lines

Active load balance fixes:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

#12 lore raw
Quoted 52 lines · Tim Chen
Quoted 36 lines · Mario Limonciello
Quoted 28 lines · Klaus Kusche

Hello,

Quoted 17 lines · Tim Chen
Quoted 9 lines

I did some quick testing (no perfect benchmark environment, just checking runtime and CPU consumption with "time").

I timed a kernel build (-j 24 and full lto, my own .config) and an application build (also with a lot of parallelism) with three different kernels:

a) Cache aware scheduling completely configured off

Quoted 7 lines

b) Cache aware scheduling turned on, but without patch

c) Cache aware scheduling turned on, with patch

Big/little scheduling was always on,
Mario's patch was always applied
(without it, results are significantly worse,

Quoted 6 lines

Sorry, I am a bit confused. You mentioned later the result for (b) and (c) are about the same with or without the patch exposing debugfs (commit c1e7fe5e75ed11fa85368e5a186472afd3858f3a Mario mentioned in another mail).
But here you say the result is much worse without Mario's patch. Is Mario's patch the one above or some other patch?

Quoted 5 lines

The with/without patch in (b) and (c)
refers to the patch you sent on 31/08/2026
( https://lore.kernel.org/lkml/[email protected]/ ), not to Mario's patch.

Quoted 5 lines

Just to clarify Mario's patch in this context refers to the fix to ITMT/debugfs fixes as Klaus doesn't nominally enable debugfs in Kconfig:

eaece4849991d62fcd6f46637c55dcce00e25d70

Ricardo reminded me that AMD's hybrid CPU relies on SD_ASYM_PACKING instead of SD_ASYM_CPUCAPACITY. So the patch I pointed to
(https://lore.kernel.org/lkml/[email protected]/)
only fixes the SD_ASYM_CPUCAPACITY case and would not have an effect on your test system.

The fact that ITMT needs to be turned on to improve performance also point in that direction.

Quoted 7 lines

There was a bug that Chen Yu fixes for ITMT compatability with cache aware scheduling. It prevents a task from getting stuck in the wrong LLC in the ITMT case
(https://lore.kernel.org/lkml/[email protected]/).
Klaus, Can you apply that with Mario's ITMT/debugfs patch to see if that improves performance on your system?

Tim

Yes, that patch tries to coordinate ITMT with cache-aware scheduling. It would also be helpful to get a dump of /sys/kernel/sched/debug/domains/* to confirm that the SD_ASYM_PACKING flag is set at the MC domains as well as /sys/kernel/debug/x86/sched_itmt_enabled to double-check that ITMT is enabled and /sys/kernel/debug/x86/sched_core_priority to look at CPU priorities.

thanks,
Chenyu

#13 lore raw

I did some very quick tests.

1.) /sys/kernel/sched/debug/domains/* does not exist on my system, not even with debug_fs on.

/sys/kernel/debug/x86/sched_itmt_enabled is "Y", /sys/kernel/debug/x86/sched_core_priority looks good (big cores have values almost twice as high as small cores)

2.) The situation with 7.2.5 which seems to include
https://lore.kernel.org/lkml/[email protected]/
is almost unchanged: Without cache aware scheduling, my build jobs run faster (wallclock time):
Just 6:16 compared to 6:19 for my kernel build with full LTO, but 4:50 compared to 5:20 (???) for my python uv build (the python uv build seems to be a very interesting test case?)

However, with cache sched enabled, in spite of the longer wallclock time, cpu seconds are sometimes a little bit lower.

3.) https://lore.kernel.org/lkml/[email protected]/
seems to make things much worse:
Kernel builds had the LTO step and the CC compressed step
placed on little cores for significant amounts of time,
resulting in total build times above 8 minutes.
Same impression by watching the bar graph for individual cores for the uv build.

Prof. Dr. Klaus Kusche
Privat: Söllmnitz 32 d, D-07554 Gera/Söllmnitz 036695/859909 [email protected] https://www.computerix.info
Dienstlich: DHGE Gera, Weg der Freundschaft 4, D-07546 Gera [email protected] https://www.dhge.de

Quoted 73 lines · Yu C
Quoted 52 lines · Tim Chen
Quoted 36 lines · Mario Limonciello
Quoted 28 lines · Klaus Kusche

Hello,

Quoted 17 lines · Tim Chen
Quoted 9 lines

I did some quick testing (no perfect benchmark environment, just checking runtime and CPU consumption with "time").

I timed a kernel build (-j 24 and full lto, my own .config) and an application build (also with a lot of parallelism) with three different kernels:

a) Cache aware scheduling completely configured off

Quoted 7 lines

b) Cache aware scheduling turned on, but without patch

c) Cache aware scheduling turned on, with patch

Big/little scheduling was always on,
Mario's patch was always applied
(without it, results are significantly worse,

Quoted 6 lines

Sorry, I am a bit confused. You mentioned later the result for (b) and (c) are about the same with or without the patch exposing debugfs (commit c1e7fe5e75ed11fa85368e5a186472afd3858f3a Mario mentioned in another mail).
But here you say the result is much worse without Mario's patch. Is Mario's patch the one above or some other patch?

Quoted 5 lines

The with/without patch in (b) and (c)
refers to the patch you sent on 31/08/2026
( https://lore.kernel.org/lkml/[email protected]/ ), not to Mario's patch.

Quoted 5 lines

Just to clarify Mario's patch in this context refers to the fix to ITMT/debugfs fixes as Klaus doesn't nominally enable debugfs in Kconfig:

eaece4849991d62fcd6f46637c55dcce00e25d70

Ricardo reminded me that AMD's hybrid CPU relies on SD_ASYM_PACKING instead of SD_ASYM_CPUCAPACITY. So the patch I pointed to
(https://lore.kernel.org/lkml/[email protected]/)
only fixes the SD_ASYM_CPUCAPACITY case and would not have an effect on your test system.

The fact that ITMT needs to be turned on to improve performance also point in that direction.

Quoted 7 lines

There was a bug that Chen Yu fixes for ITMT compatability with cache aware scheduling. It prevents a task from getting stuck in the wrong LLC in the ITMT case
(https://lore.kernel.org/lkml/[email protected]/).
Klaus, Can you apply that with Mario's ITMT/debugfs patch to see if that improves performance on your system?

Tim

Yes, that patch tries to coordinate ITMT with cache-aware scheduling. It would also
be helpful to get a dump of /sys/kernel/sched/debug/domains/* to confirm that the
SD_ASYM_PACKING flag is set at the MC domains as well as /sys/kernel/debug/x86/sched_itmt_enabled
to double-check that ITMT is enabled and /sys/kernel/debug/x86/sched_core_priority to look at
CPU priorities.

thanks,
Chenyu

#14 lore raw
Quoted 18 lines · Klaus Kusche

I did some very quick tests.

1.) /sys/kernel/sched/debug/domains/* does not exist on my system, not even with debug_fs on.

/sys/kernel/debug/x86/sched_itmt_enabled is "Y", /sys/kernel/debug/x86/sched_core_priority looks good (big cores have values almost twice as high as small cores)

2.) The situation with 7.2.5 which seems to include
https://lore.kernel.org/lkml/[email protected]/
is almost unchanged: Without cache aware scheduling, my build jobs run faster (wallclock time):
Just 6:16 compared to 6:19 for my kernel build with full LTO, but 4:50 compared to 5:20 (???) for my python uv build (the python uv build seems to be a very interesting test case?)

Quoted 4 lines

However, with cache sched enabled, in spite of the longer wallclock time, cpu seconds are sometimes a little bit lower.

3.) https://lore.kernel.org/lkml/[email protected]/

This patch inhibits ASYM_PACKING and favors Cache-Aware-Scheduling, which is the opposite of what your platform expects.

Quoted 7 lines

seems to make things much worse:
Kernel builds had the LTO step and the CC compressed step placed on little cores for significant amounts of time, resulting in total build times above 8 minutes.
Same impression by watching the bar graph for individual cores for the uv build.

After a second thought, I wonder if we should disable Cache-Aware Scheduling if ASYM_PACKING is enabled, because the latter would prefer a higher priority CPU rather than just choosing a random L3 to aggregate the threads. Would the following patch work for you? (just compile tested, as I do not have a multi-LLC hybrid AMD platform for testing) Thanks.

kernel/sched/topology.c +16 -0
index 0248227d983a..07bc8a302574 100644
@@ -684,6 +684,7 @@ DEFINE_PER_CPU(struct sched_domain __rcu *, sd_asym_cpucapacity);
 
 DEFINE_STATIC_KEY_FALSE(sched_asym_cpucapacity);
 DEFINE_STATIC_KEY_FALSE(sched_cluster_active);
+DEFINE_STATIC_KEY_FALSE(sched_asym_packing_active);
 
 static void update_top_cache_domain(int cpu)
 {
@@ -957,6 +958,11 @@ static void _sched_cache_active_set(void)
 		return;
 	}
 
+	if (static_branch_unlikely(&sched_asym_packing_active)) {
+		static_branch_disable_cpuslocked(&sched_cache_active);
+		return;
+	}
+
 	/*
 	 * user wants it or not ?
 	 * TBD: read before writing the static key.
@@ -3085,6 +3091,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
 	int i, ret = -ENOMEM;
 	bool has_asym = false;
 	bool has_cluster = false;
+	bool has_asym_packing = false;
 
 	if (WARN_ON(cpumask_empty(cpu_map)))
 		goto error;
@@ -3204,6 +3211,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
 
 		if (lowest_flag_domain(i, SD_CLUSTER))
 			has_cluster = true;
+
+		if (highest_flag_domain(i, SD_ASYM_PACKING))
+			has_asym_packing = true;
 	}
 	rcu_read_unlock();
 
@@ -3213,6 +3223,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
 	if (has_cluster)
 		static_branch_inc_cpuslocked(&sched_cluster_active);
 
+	if (has_asym_packing)
+		static_branch_inc_cpuslocked(&sched_asym_packing_active);
+
 	if (rq && sched_debug_verbose)
 		pr_info("root domain span: %*pbl\n", cpumask_pr_args(cpu_map));
 
@@ -3318,6 +3331,9 @@ static void detach_destroy_domains(const struct cpumask *cpu_map)
 	if (static_branch_unlikely(&sched_cluster_active))
 		static_branch_dec_cpuslocked(&sched_cluster_active);
 
+	if (rcu_access_pointer(per_cpu(sd_asym_packing, cpu)))
+		static_branch_dec_cpuslocked(&sched_asym_packing_active);
+
 	rcu_read_lock();
 	for_each_cpu(i, cpu_map)
 		cpu_attach_domain(NULL, &def_root_domain, i);
Signature · 1 line
2.43.0
#15 lore raw

I don't know what your last patch does (does it dynamically disable cache aware scheduling on big/little CPU's?),
but it makes my two build tests running at almost the same speed on a kernel with cache aware scheduling
compared to a kernel without cache aware scheduling, which means it is rougly 2 % faster
than earlier cache aware scheduling kernels.

Just by looking at the core bar graph,
I also didn't see any obviously misplaced processes.

Klaus Kusche

Quoted 104 lines · Chen Yu
Quoted 18 lines · Klaus Kusche

I did some very quick tests.

1.) /sys/kernel/sched/debug/domains/* does not exist on my system, not even with debug_fs on.

/sys/kernel/debug/x86/sched_itmt_enabled is "Y", /sys/kernel/debug/x86/sched_core_priority looks good (big cores have values almost twice as high as small cores)

2.) The situation with 7.2.5 which seems to include
https://lore.kernel.org/lkml/[email protected]/
is almost unchanged: Without cache aware scheduling, my build jobs run faster (wallclock time):
Just 6:16 compared to 6:19 for my kernel build with full LTO, but 4:50 compared to 5:20 (???) for my python uv build (the python uv build seems to be a very interesting test case?)

Quoted 4 lines

However, with cache sched enabled, in spite of the longer wallclock time, cpu seconds are sometimes a little bit lower.

3.) https://lore.kernel.org/lkml/[email protected]/

This patch inhibits ASYM_PACKING and favors Cache-Aware-Scheduling, which is the opposite of what your platform expects.

Quoted 7 lines

seems to make things much worse:
Kernel builds had the LTO step and the CC compressed step placed on little cores for significant amounts of time, resulting in total build times above 8 minutes.
Same impression by watching the bar graph for individual cores for the uv build.

After a second thought, I wonder if we should disable Cache-Aware Scheduling if ASYM_PACKING is enabled, because the latter would prefer a higher priority CPU rather than just choosing a random L3 to aggregate the threads. Would the following patch work for you? (just compile tested, as I do not have a multi-LLC hybrid AMD platform for testing) Thanks.

kernel/sched/topology.c +16 -0
index 0248227d983a..07bc8a302574 100644
@@ -684,6 +684,7 @@ DEFINE_PER_CPU(struct sched_domain __rcu *, sd_asym_cpucapacity);
 
 DEFINE_STATIC_KEY_FALSE(sched_asym_cpucapacity);
 DEFINE_STATIC_KEY_FALSE(sched_cluster_active);
+DEFINE_STATIC_KEY_FALSE(sched_asym_packing_active);
 
 static void update_top_cache_domain(int cpu)
 {
@@ -957,6 +958,11 @@ static void _sched_cache_active_set(void)
 		return;
 	}
 
+	if (static_branch_unlikely(&sched_asym_packing_active)) {
+		static_branch_disable_cpuslocked(&sched_cache_active);
+		return;
+	}
+
 	/*
 	 * user wants it or not ?
 	 * TBD: read before writing the static key.
@@ -3085,6 +3091,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
 	int i, ret = -ENOMEM;
 	bool has_asym = false;
 	bool has_cluster = false;
+	bool has_asym_packing = false;
 
 	if (WARN_ON(cpumask_empty(cpu_map)))
 		goto error;
@@ -3204,6 +3211,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
 
 		if (lowest_flag_domain(i, SD_CLUSTER))
 			has_cluster = true;
+
+		if (highest_flag_domain(i, SD_ASYM_PACKING))
+			has_asym_packing = true;
 	}
 	rcu_read_unlock();
 
@@ -3213,6 +3223,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
 	if (has_cluster)
 		static_branch_inc_cpuslocked(&sched_cluster_active);
 
+	if (has_asym_packing)
+		static_branch_inc_cpuslocked(&sched_asym_packing_active);
+
 	if (rq && sched_debug_verbose)
 		pr_info("root domain span: %*pbl\n", cpumask_pr_args(cpu_map));
 
@@ -3318,6 +3331,9 @@ static void detach_destroy_domains(const struct cpumask *cpu_map)
 	if (static_branch_unlikely(&sched_cluster_active))
 		static_branch_dec_cpuslocked(&sched_cluster_active);
 
+	if (rcu_access_pointer(per_cpu(sd_asym_packing, cpu)))
+		static_branch_dec_cpuslocked(&sched_asym_packing_active);
+
 	rcu_read_lock();
 	for_each_cpu(i, cpu_map)
 		cpu_attach_domain(NULL, &def_root_domain, i);
#16 lore raw
Quoted 10 lines · Klaus Kusche

I don't know what your last patch does (does it dynamically disable cache aware scheduling on big/little CPU's?),
but it makes my two build tests running at almost the same speed on a kernel with cache aware scheduling
compared to a kernel without cache aware scheduling, which means it is rougly 2 % faster
than earlier cache aware scheduling kernels.

Just by looking at the core bar graph,
I also didn't see any obviously misplaced processes.

Hi Klaus,

I wonder if you can try this alternate patch to Chen Yu's. This patch does not require turning off cache aware scheduling entirely as in the previous patch when using the asym packing mechanism to prioritize big core.

Hopefully it will have a similar effect to restore performance on your tests.

Thanks.

Tim

From 7bad1c19317e08d398fa36d66940867110bdd037 Mon Sep 17 00:00:00 2001
From: Tim Chen <[email protected]>
Date: Wed, 23 Sep 2026 14:28:40 -0700
Subject: [PATCH] sched/cache: Honor asym packing over cache aware scheduling
on hybrid system

A regression was reported on an AMD Ryzen AI HX 370 running a cache intensive Clang full-LTO link. The little cores run at a much lower frequency (3.3 GHz vs 5.1 GHz) and have only half of the L3 cache (8 MB vs 16 MB), so pinning such a task to the little-core LLC hurts twice, and full-LTO builds slow down dramatically compared to pre-cache-aware-scheduling kernels.

Asym packing and cache aware scheduling express conflicting placement strategy. Asym packing wants a task to run on the highest priority CPU, whereas CAS wants to co-locate the tasks of a process on one LLC regardless of the priority of CPUs in that LLC. When asym packing is turned on, it is trying to migrate task to an empty core that has higher priority than source cpu, let asym packing win.

---
 kernel/sched/fair.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
kernel/sched/fair.c +18 -3
index f265de8721db..89eed4fbc4e2 100644
@@ -10823,6 +10823,8 @@ static inline bool task_misfits_asym_cpu(struct lb_env *env, struct task_struct
 	return false;
 }
 
+static inline bool sched_asym(struct sched_domain *sd, int dst_cpu, int src_cpu);
+
 /*
  * Check if task p can migrate from source LLC to
  * destination LLC in terms of cache aware load balance.
@@ -10847,6 +10849,10 @@ static enum llc_mig can_migrate_llc_task(struct lb_env *env,
 	if (cpu < 0 || cpus_share_cache(src_cpu, dst_cpu))
 		return mig_unrestricted;
 
+	/* Prioritize asym packing over cache awareness */
+	if (sched_asym(env->sd, dst_cpu, src_cpu))
+		return mig_unrestricted;
+
 	/* skip cache aware load balance for too many threads */
 	if (invalid_llc_nr(grp, p, dst_cpu) ||
 	    exceed_llc_capacity(grp, dst_cpu)) {
@@ -12043,6 +12049,15 @@ static inline bool llc_balance(struct lb_env *env, struct sg_lb_stats *sgs,
 	    sgs->group_misfit_task_load)
 		return false;
 
+	/*
+	 * On asym packing domains, if the destination CPU
+	 * has higher priority than all CPUs in the source group,
+	 * prioritize asym packing.
+	 */ 
+	if ((env->sd->flags & SD_ASYM_PACKING) &&
+	    sgs->group_asym_packing)
+		return false;
+
 	/*
 	 * Skip cache aware tagging if nr_balanced_failed is sufficiently high.
 	 * Threshold of cache_nice_tries is set to 1 higher than nr_balance_failed
@@ -13458,12 +13473,12 @@ static int need_active_balance(struct lb_env *env)
 {
 	struct sched_domain *sd = env->sd;
 
-	if (alb_break_llc(env))
-		return 0;
-
 	if (asym_active_balance(env))
 		return 1;
 
+	if (alb_break_llc(env))
+		return 0;
+
 	if (imbalanced_active_balance(env))
 		return 1;
 
Signature · 1 line
2.32.0
#17 lore raw
Quoted 6 lines · Tim Chen

Hi Klaus,

I wonder if you can try this alternate patch to Chen Yu's. This patch does not require turning off cache aware scheduling entirely as in the previous patch when using the asym packing mechanism to prioritize big core.

Hello,

1.) This patch applies with quite some fuzz to 7.2.7 (for example, the context of the -10847,6+10849,10 hunk is obviously different), and the resulting fair.c fails to compile:
call to undeclared function 'sched_use_asym_prio' conflicting types for 'sched_use_asym_prio' (sched_use_asym_prio is called before being declared) use of undeclared identifier 'env'

2.) As far as I know, "inline" does not look ahead in C. So I think the call to sched_asym you added in hunk -10847,6+10849,10 will result in a real call, not in inline code
(at least without optimization), because the code of sched_asym is not yet known at the position of that call.

Signature · 1 line
Klaus Kusche
Quoted 83 lines

From 7bad1c19317e08d398fa36d66940867110bdd037 Mon Sep 17 00:00:00 2001
From: Tim Chen <[email protected]>
Date: Wed, 23 Sep 2026 14:28:40 -0700
Subject: [PATCH] sched/cache: Honor asym packing over cache aware scheduling
on hybrid system

A regression was reported on an AMD Ryzen AI HX 370 running a cache intensive Clang full-LTO link. The little cores run at a much lower frequency (3.3 GHz vs 5.1 GHz) and have only half of the L3 cache (8 MB vs 16 MB), so pinning such a task to the little-core LLC hurts twice, and full-LTO builds slow down dramatically compared to pre-cache-aware-scheduling kernels.

Asym packing and cache aware scheduling express conflicting placement strategy. Asym packing wants a task to run on the highest priority CPU, whereas CAS wants to co-locate the tasks of a process on one LLC regardless of the priority of CPUs in that LLC. When asym packing is turned on, it is trying to migrate task to an empty core that has higher priority than source cpu, let asym packing win.

---
 kernel/sched/fair.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
kernel/sched/fair.c +18 -3
index f265de8721db..89eed4fbc4e2 100644
@@ -10823,6 +10823,8 @@ static inline bool task_misfits_asym_cpu(struct lb_env *env, struct task_struct
 	return false;
 }
 
+static inline bool sched_asym(struct sched_domain *sd, int dst_cpu, int src_cpu);
+
 /*
  * Check if task p can migrate from source LLC to
  * destination LLC in terms of cache aware load balance.
@@ -10847,6 +10849,10 @@ static enum llc_mig can_migrate_llc_task(struct lb_env *env,
 	if (cpu < 0 || cpus_share_cache(src_cpu, dst_cpu))
 		return mig_unrestricted;
 
+	/* Prioritize asym packing over cache awareness */
+	if (sched_asym(env->sd, dst_cpu, src_cpu))
+		return mig_unrestricted;
+
 	/* skip cache aware load balance for too many threads */
 	if (invalid_llc_nr(grp, p, dst_cpu) ||
 	    exceed_llc_capacity(grp, dst_cpu)) {
@@ -12043,6 +12049,15 @@ static inline bool llc_balance(struct lb_env *env, struct sg_lb_stats *sgs,
 	    sgs->group_misfit_task_load)
 		return false;
 
+	/*
+	 * On asym packing domains, if the destination CPU
+	 * has higher priority than all CPUs in the source group,
+	 * prioritize asym packing.
+	 */ 
+	if ((env->sd->flags & SD_ASYM_PACKING) &&
+	    sgs->group_asym_packing)
+		return false;
+
 	/*
 	 * Skip cache aware tagging if nr_balanced_failed is sufficiently high.
 	 * Threshold of cache_nice_tries is set to 1 higher than nr_balance_failed
@@ -13458,12 +13473,12 @@ static int need_active_balance(struct lb_env *env)
 {
 	struct sched_domain *sd = env->sd;
 
-	if (alb_break_llc(env))
-		return 0;
-
 	if (asym_active_balance(env))
 		return 1;
 
+	if (alb_break_llc(env))
+		return 0;
+
 	if (imbalanced_active_balance(env))
 		return 1;
 
#18 lore raw
Quoted 10 lines · Klaus Kusche
Quoted 6 lines · Tim Chen

Hi Klaus,

I wonder if you can try this alternate patch to Chen Yu's. This patch does not require turning off cache aware scheduling entirely as in the previous patch when using the asym packing mechanism to prioritize big core.

Hello,

Quoted 7 lines

1.) This patch applies with quite some fuzz to 7.2.7 (for example, the context of the -10847,6+10849,10 hunk is obviously different), and the resulting fair.c fails to compile:
call to undeclared function 'sched_use_asym_prio' conflicting types for 'sched_use_asym_prio' (sched_use_asym_prio is called before being declared) use of undeclared identifier 'env'

Thanks a lot for applying the patch and reporting back so quickly.

You are right, and the fuzz is the cause of the build failure. I generated the original patch on top of Peter's sched/urgent tree, where fair.c is laid out differently
from 7.2.7. The interface to can_migrate_llc() has been modified to use "env" in Peter's tree.

I rebased the change onto v7.2.7 for you to test. It now applies cleanly with git am and builds. Two things differ on v7.2.7, so this is a real backport rather than the same diff:

- can_migrate_llc_task() takes (src_cpu, dst_cpu, p) here instead of an lb_env, so I pass the sched_domain in explicitly and update its one caller.
- llc_balance() has no SD_ASYM_CPUCAPACITY misfit early-out on v7.2.7, so the new asym check is placed after the SD_SHARE_LLC check.

You can either test with the previous patch on sched/urgent
(https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/log/?h=sched/urgent)
or use the backported patch attached to the end of the mail.

Quoted 6 lines

2.) As far as I know, "inline" does not look ahead in C. So I think the call to sched_asym you added in hunk -10847,6+10849,10 will result in a real call, not in inline code
(at least without optimization), because the code of sched_asym is not yet known at the position of that call.

Good point to raise, but that part is not the problem. Whether the call is inlined is only an optimization and should not affect whether the code
compiles: a static inline function that is forward-declared and defined later in the same file is valid C. I checked my disassembled code and find that sched_asym() in indeed inlined.

There are other function in fair.c already with similar declaration for cfs_rq_max_slice(), account_mm_sched(), and others.

Could you give it a try on your system?

Thanks again for testing on your hardware.

Tim

---
From: Tim Chen <[email protected]>
Date: Wed, 23 Sep 2026 14:28:40 -0700
Subject: [PATCH] sched/cache: Honor asym packing over cache aware scheduling
on hybrid system

A regression was reported on an AMD Ryzen AI HX 370 running a cache intensive Clang full-LTO link. The little cores run at a much lower frequency (3.3 GHz vs 5.1 GHz) and have only half of the L3 cache (8 MB vs 16 MB), so pinning such a task to the little-core LLC hurts twice, and full-LTO builds slow down dramatically compared to pre-cache-aware-scheduling kernels.

Asym packing and cache aware scheduling express conflicting placement strategy. Asym packing wants a task to run on the highest priority CPU, whereas CAS wants to co-locate the tasks of a process on one LLC regardless of the priority of CPUs in that LLC. When asym packing is turned on, it is trying to migrate task to an empty core that has higher priority than source cpu, let asym packing win.

[ Backport to v7.2.7: can_migrate_llc_task() takes (src_cpu, dst_cpu, p)
here rather than lb_env, so pass the sched_domain in explicitly. Drop context from task_misfits_asym_cpu() and the SD_ASYM_CPUCAPACITY misfit check in llc_balance(), which are not present in v7.2.7. ]

---
 kernel/sched/fair.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
kernel/sched/fair.c +21 -5
index bb8a5f358ee19..2dae60ad09276 100644
@@ -10575,11 +10575,14 @@ static enum llc_mig can_migrate_llc(int src_cpu, int dst_cpu,
 	return mig_llc;
 }
 
+static inline bool sched_asym(struct sched_domain *sd, int dst_cpu, int src_cpu);
+
 /*
  * Check if task p can migrate from source LLC to
  * destination LLC in terms of cache aware load balance.
  */
-static enum llc_mig can_migrate_llc_task(int src_cpu, int dst_cpu,
+static enum llc_mig can_migrate_llc_task(struct sched_domain *sd,
+					 int src_cpu, int dst_cpu,
 					 struct task_struct *p)
 {
 	struct mm_struct *mm;
@@ -10594,6 +10597,10 @@ static enum llc_mig can_migrate_llc_task(int src_cpu, int dst_cpu,
 	if (cpu < 0 || cpus_share_cache(src_cpu, dst_cpu))
 		return mig_unrestricted;
 
+	/* Prioritize asym packing over cache awareness */
+	if (sched_asym(sd, dst_cpu, src_cpu))
+		return mig_unrestricted;
+
 	/* skip cache aware load balance for too many threads */
 	if (invalid_llc_nr(mm, p, dst_cpu) ||
 	    exceed_llc_capacity(mm, dst_cpu)) {
@@ -10689,7 +10696,7 @@ static bool migrate_degrades_llc(struct task_struct *p, struct lb_env *env)
 	    READ_ONCE(p->preferred_llc) != llc_id(env->dst_cpu))
 		return true;
 
-	if (can_migrate_llc_task(env->src_cpu,
+	if (can_migrate_llc_task(env->sd, env->src_cpu,
 				 env->dst_cpu, p) != mig_forbid)
 		return false;
 
@@ -11753,6 +11760,15 @@ static inline bool llc_balance(struct lb_env *env, struct sg_lb_stats *sgs,
 	if (env->sd->flags & SD_SHARE_LLC)
 		return false;
 
+	/*
+	 * On asym packing domains, if the destination CPU
+	 * has higher priority than all CPUs in the source group,
+	 * prioritize asym packing.
+	 */
+	if ((env->sd->flags & SD_ASYM_PACKING) &&
+	    sgs->group_asym_packing)
+		return false;
+
 	/*
 	 * Skip cache aware tagging if nr_balanced_failed is sufficiently high.
 	 * Threshold of cache_nice_tries is set to 1 higher than nr_balance_failed
@@ -13140,12 +13156,12 @@ static int need_active_balance(struct lb_env *env)
 {
 	struct sched_domain *sd = env->sd;
 
-	if (alb_break_llc(env))
-		return 0;
-
 	if (asym_active_balance(env))
 		return 1;
 
+	if (alb_break_llc(env))
+		return 0;
+
 	if (imbalanced_active_balance(env))
 		return 1;
 
Signature · 1 line
2.32.0
#19 lore raw

Hello,

this one looks good.
It does not show any core assignment anomalies in the core bar graph (i.e. no processes are staying on little cores when big cores are idle), and at least for the two compile jobs I tested, it gives timings which are

* better w.r.t. elapsed wallclock time (sometimes slightly, sometimes significantly) than all other versions and patches I tried so far with cache-aware scheduling on

* and at least as good as the unpatched kernel with cache-aware scheduling turned off
(so one does not loose anything by turning it on).

As expected, the uv build profits more than the kernel built, because besides all-cores-loaded and single-core-loaded phases, it spends significant time with about half as many busy processes as cores, and in these phases, placement makes a difference.

Klaus Kusche

Quoted 170 lines · Tim Chen
Quoted 10 lines · Klaus Kusche
Quoted 6 lines · Tim Chen

Hi Klaus,

I wonder if you can try this alternate patch to Chen Yu's. This patch does not require turning off cache aware scheduling entirely as in the previous patch when using the asym packing mechanism to prioritize big core.

Hello,

Quoted 7 lines

1.) This patch applies with quite some fuzz to 7.2.7 (for example, the context of the -10847,6+10849,10 hunk is obviously different), and the resulting fair.c fails to compile:
call to undeclared function 'sched_use_asym_prio' conflicting types for 'sched_use_asym_prio' (sched_use_asym_prio is called before being declared) use of undeclared identifier 'env'

Thanks a lot for applying the patch and reporting back so quickly.

You are right, and the fuzz is the cause of the build failure. I generated the original patch on top of Peter's sched/urgent tree, where fair.c is laid out differently
from 7.2.7. The interface to can_migrate_llc() has been modified to use "env" in Peter's tree.

I rebased the change onto v7.2.7 for you to test. It now applies cleanly with git am and builds. Two things differ on v7.2.7, so this is a real backport rather than the same diff:

- can_migrate_llc_task() takes (src_cpu, dst_cpu, p) here instead of an lb_env, so I pass the sched_domain in explicitly and update its one caller.
- llc_balance() has no SD_ASYM_CPUCAPACITY misfit early-out on v7.2.7, so the new asym check is placed after the SD_SHARE_LLC check.

You can either test with the previous patch on sched/urgent
(https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/log/?h=sched/urgent)
or use the backported patch attached to the end of the mail.

Quoted 6 lines

2.) As far as I know, "inline" does not look ahead in C. So I think the call to sched_asym you added in hunk -10847,6+10849,10 will result in a real call, not in inline code
(at least without optimization), because the code of sched_asym is not yet known at the position of that call.

Good point to raise, but that part is not the problem. Whether the call is inlined is only an optimization and should not affect whether the code
compiles: a static inline function that is forward-declared and defined later in the same file is valid C. I checked my disassembled code and find that sched_asym() in indeed inlined.

There are other function in fair.c already with similar declaration for cfs_rq_max_slice(), account_mm_sched(), and others.

Could you give it a try on your system?

Thanks again for testing on your hardware.

Tim

---
From: Tim Chen <[email protected]>
Date: Wed, 23 Sep 2026 14:28:40 -0700
Subject: [PATCH] sched/cache: Honor asym packing over cache aware scheduling
on hybrid system

A regression was reported on an AMD Ryzen AI HX 370 running a cache intensive Clang full-LTO link. The little cores run at a much lower frequency (3.3 GHz vs 5.1 GHz) and have only half of the L3 cache (8 MB vs 16 MB), so pinning such a task to the little-core LLC hurts twice, and full-LTO builds slow down dramatically compared to pre-cache-aware-scheduling kernels.

Asym packing and cache aware scheduling express conflicting placement strategy. Asym packing wants a task to run on the highest priority CPU, whereas CAS wants to co-locate the tasks of a process on one LLC regardless of the priority of CPUs in that LLC. When asym packing is turned on, it is trying to migrate task to an empty core that has higher priority than source cpu, let asym packing win.

[ Backport to v7.2.7: can_migrate_llc_task() takes (src_cpu, dst_cpu, p)
here rather than lb_env, so pass the sched_domain in explicitly. Drop context from task_misfits_asym_cpu() and the SD_ASYM_CPUCAPACITY misfit check in llc_balance(), which are not present in v7.2.7. ]

---
 kernel/sched/fair.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
kernel/sched/fair.c +21 -5
index bb8a5f358ee19..2dae60ad09276 100644
@@ -10575,11 +10575,14 @@ static enum llc_mig can_migrate_llc(int src_cpu, int dst_cpu,
 	return mig_llc;
 }
 
+static inline bool sched_asym(struct sched_domain *sd, int dst_cpu, int src_cpu);
+
 /*
  * Check if task p can migrate from source LLC to
  * destination LLC in terms of cache aware load balance.
  */
-static enum llc_mig can_migrate_llc_task(int src_cpu, int dst_cpu,
+static enum llc_mig can_migrate_llc_task(struct sched_domain *sd,
+					 int src_cpu, int dst_cpu,
 					 struct task_struct *p)
 {
 	struct mm_struct *mm;
@@ -10594,6 +10597,10 @@ static enum llc_mig can_migrate_llc_task(int src_cpu, int dst_cpu,
 	if (cpu < 0 || cpus_share_cache(src_cpu, dst_cpu))
 		return mig_unrestricted;
 
+	/* Prioritize asym packing over cache awareness */
+	if (sched_asym(sd, dst_cpu, src_cpu))
+		return mig_unrestricted;
+
 	/* skip cache aware load balance for too many threads */
 	if (invalid_llc_nr(mm, p, dst_cpu) ||
 	    exceed_llc_capacity(mm, dst_cpu)) {
@@ -10689,7 +10696,7 @@ static bool migrate_degrades_llc(struct task_struct *p, struct lb_env *env)
 	    READ_ONCE(p->preferred_llc) != llc_id(env->dst_cpu))
 		return true;
 
-	if (can_migrate_llc_task(env->src_cpu,
+	if (can_migrate_llc_task(env->sd, env->src_cpu,
 				 env->dst_cpu, p) != mig_forbid)
 		return false;
 
@@ -11753,6 +11760,15 @@ static inline bool llc_balance(struct lb_env *env, struct sg_lb_stats *sgs,
 	if (env->sd->flags & SD_SHARE_LLC)
 		return false;
 
+	/*
+	 * On asym packing domains, if the destination CPU
+	 * has higher priority than all CPUs in the source group,
+	 * prioritize asym packing.
+	 */
+	if ((env->sd->flags & SD_ASYM_PACKING) &&
+	    sgs->group_asym_packing)
+		return false;
+
 	/*
 	 * Skip cache aware tagging if nr_balanced_failed is sufficiently high.
 	 * Threshold of cache_nice_tries is set to 1 higher than nr_balance_failed
@@ -13140,12 +13156,12 @@ static int need_active_balance(struct lb_env *env)
 {
 	struct sched_domain *sd = env->sd;
 
-	if (alb_break_llc(env))
-		return 0;
-
 	if (asym_active_balance(env))
 		return 1;
 
+	if (alb_break_llc(env))
+		return 0;
+
 	if (imbalanced_active_balance(env))
 		return 1;
 
#20 lore raw
Quoted 9 lines · Klaus Kusche

Hello,

this one looks good.
It does not show any core assignment anomalies in the core bar graph (i.e. no processes are staying on little cores when big cores are idle), and at least for the two compile jobs I tested, it gives timings which are

Quoted 8 lines

* better w.r.t. elapsed wallclock time (sometimes slightly, sometimes significantly) than all other versions and patches I tried so far with cache-aware scheduling on

* and at least as good as the unpatched kernel with cache-aware scheduling turned off
(so one does not loose anything by turning it on).

Thank you for testing and sharing the results so quickly. I will send a cleaned up patch for sched/urgent branch shortly for Peter.

Tim

Quoted 8 lines

As expected, the uv build profits more than the kernel built, because besides all-cores-loaded and single-core-loaded phases, it spends significant time with about half as many busy processes as cores, and in these phases, placement makes a difference.

Klaus Kusche