Re: [PATCH 0/5] cacheinfo, powerpc: Move powerpc to generic cacheinfo

From: Shrikanth Hegde

Date: Tue Nov 24 2026 - 04:35:44 EST




On 11/18/26 10:06 PM, Shrikanth Hegde wrote:
This is another attempt to move powerpc towards generic cacheinfo
framework. This is spiritual successor to earlier attempts by Sudeep
Holla [1]

The context around this time was, when trying to enable Cache Aware
scheduling on powerpc using a llc_override kernel parameter[2], it was
pointed out that the llc_bytes which is retreived using
get_effective_llc_bytes fails and hence the cache aware scheduling is
effectively a NOP, moment the process has a visible footprint.

Instead of adding more hacks around with custom arch_llc_bytes, this is
an attempt to move powerpc to generic cacheinfo instead. This removes
the powerpc maintaining a separate sysfs entries for all caches.
A few modifications to the generic code is necessary due to some of the
conventions followed in the device tree specifications. The details are
in the respective patches.

If this approach does not work, then I am afraid we might have to fallback to
arch_llc_bytes.

Well, though it worked for normal boot and hotplug, LPM is broken and DLPAR is likely
a problem too if the logical CPUid is reused with different device tree node.

So I am afraid it is not straightforward to port.

The current PowerPC implementation owns references to the device-tree cache nodes
and destroys and rebuilds its cache objects during LPM. It also releases cache
objects as CPUs are removed during DLPAR.

Generic cacheinfo has a different lifetime model. Its per-CPU info_list is retained
across CPU offline, and the leaves continue to contain fw_token pointers to the
device-tree cache nodes. Replacing or freeing those leaves safely is not straightforward
because scheduler and page allocator users can access them concurrently. Handling this properly
would need a broader lifetime and synchronization mechanism in generic cacheinfo.

Doing all that heavy lifting for the case of LPM/DLPAR is likely going to be overkill.
That may still be worth doing independently, but it is substantially more involved than
what is needed here.

So I am planning to resort to something like below. Introduce a new arch
specific hook (cacheinfo_get_arch_llc_info) to get the cache size and
cpus of that cache.

Hopefully should be able to send it out soon. Now would be the good to wake me up if
there is a better way!!


@@ -XXX,15 +XXX,23 @@ static unsigned long get_effective_llc_bytes(int cpu,
struct sched_domain *sd)
{
struct cacheinfo *llc;
+ unsigned long size;
unsigned int hw_weight;
llc = get_cpu_cacheinfo_llc(cpu);
- if (!llc)
- return 0;
+ if (llc) {
+ size = llc->size;
+ hw_weight = cpumask_weight(&llc->shared_cpu_map);
+ } else if (cacheinfo_get_arch_llc_info(cpu, &size, &hw_weight)) {
+ return 0;
+ }
- hw_weight = cpumask_weight(&llc->shared_cpu_map);
- if (!hw_weight)
+ if (!size || !hw_weight)
return 0;
- return llc->size * sd->span_weight / hw_weight;
+ return size * sd->span_weight / hw_weight;


Note that initial draft of the work[code,changelog] was carried out by LLM.
Provided the device tree blob and both powerpc,generic cacheinfo code.
With few iterations, LLM did generate the right code with few tweaks.
Only the cover-letter and Patch 5 are completely from me. Thanks to
LLM, this series is in shape in few days otherwise would have taken
more time.

Tested the values compatibilty on Power11 Dedicated and Shared LPAR's.
All the values are same, except id and uevent which was not there
before. That should help rather than hurt any tool.

This may need more broader checks on different boards/configuration
to ensure it is same. Also DLPAR CPU add/remove is not tested yet.
Please test and report if your board/platform shows up any different
values in those cache entries.

[1]: https://lore.kernel.org/all/1424715500-21725-1-git-send-email-sudeep.holla@xxxxxxx/#t
[2]: https://lore.kernel.org/all/20261023131646.2907938-1-sshegde@xxxxxxxxxxxxx/

This series is needed llc_override patch[2] series to work. A subsequent
version of that will be sent out soon.

PS: I am working with 90% coffee and 10% sleep.

Shrikanth Hegde (5):
cacheinfo: Allow architectures to provide custom cache IDs
cacheinfo: Support unified caches described by d-cache properties
cacheinfo: Add teardown and rebuild helpers
powerpc/cacheinfo: Move to generic cacheinfo
sched/topology: Remove stale comment around llc_bytes on powerpc

arch/powerpc/kernel/cacheinfo.c | 994 +++-------------------
arch/powerpc/kernel/cacheinfo.h | 13 -
arch/powerpc/kernel/sysfs.c | 3 -
arch/powerpc/platforms/pseries/mobility.c | 2 +-
drivers/base/cacheinfo.c | 111 ++-
include/linux/cacheinfo.h | 3 +
kernel/sched/topology.c | 7 -
7 files changed, 194 insertions(+), 939 deletions(-)
delete mode 100644 arch/powerpc/kernel/cacheinfo.h