cacheinfo, powerpc, sched: Move powerpc to generic cacheinfo
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest6 patches 0 repliesNew
- v15 patches 9 repliesSuperseded
Changes in v2 from the cover letter
=========
- Add full cacheinfo teardown and transactional rebuild handling for firmware topology replacement. Avoiding build failure.
- Hold the CPU hotplug write lock while replacing cacheinfo during pSeries LPM.
- Add an ordered PowerPC CPUHP state before generic cacheinfo to make
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | cacheinfo: Allow architectures to provide custom cache IDsdrivers/ include/ | +35 | 0 replies | |
| 2/6 | cacheinfo: Support unified caches described by d-cache propertiesdrivers/ | +17 | 0 replies | |
| 3/6 | cacheinfo: Add firmware topology replacement helpersdrivers/ include/ | +128 | 0 replies | |
| 4/6 | powerpc: Set CPU device OF node before generic cacheinfo setuparch/ include/ | +46 | 0 replies | |
| 5/6 | powerpc/cacheinfo: Move to generic cacheinfoarch/ arch/ arch/ +2 more | +140 | 0 replies | |
| 6/6 | sched/topology: Remove stale comment around llc_bytes on powerpckernel/ | +2 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/6] cacheinfo, powerpc, sched: Move powerpc to generic cacheinfo
This is another attempt to move PowerPC to the generic cacheinfo framework and is a spiritual successor to the earlier work from Sudeep Holla [1].
Current motivation came from enabling Cache Aware Scheduling on PowerPC with an llc_override kernel parameter [2]. The scheduler obtains the effective LLC capacity through get_effective_llc_bytes(), which uses generic cacheinfo. Since PowerPC maintains a separate cacheinfo implementation and does not populate struct cpu_cacheinfo, llc_bytes is zero and the byte-capacity check effectively disables cache-aware placement once a process has a visible memory footprint.
Rather than adding an architecture-specific fallback for the physical LLC size and sharing information, this series moves PowerPC to generic cacheinfo. This also removes the separate PowerPC implementation of the cache sysfs interface. If move to generic cacheinfo is contentious due to new extentions, I am afraid we might have to fallback to arch_llc_bytes kind of hooks.
Since many don't read past this, Note that, I have tested this series on PowerVM LPAR (Dedicated and Shared) and PowerNV (Power9). I think there may be corner cases of error handling where consumers may have stale info. Also Please test this on your powerpc platform if it has different device tree quirks.
Applies cleanly on:
powerpc/master at c44104f3642d ("Merge tag 'drm-fixes-2026-11-21' of https://gitlab.freedesktop.org/drm/kernel")
powerpc/next at b6a9fa34ce41 ("Linux 7.4-rc4")
tip/sched/core at c47af8566706 ("selftests/sched: Add a test for stuck forced idle under core scheduling")
PowerPC move needs a few extensions.
===================================
1. PowerPC firmware cache node does not always identify one hardware cache instance. On Power11, one firmware CPU node can represent eight threads, while ibm,thread-groups divides those threads into two SMT4 cache-sharing groups. The series therefore allows an architecture to provide a cache ID derived from its physical cache-sharing topology.
2. PowerPC device trees commonly describe unified caches using d-cache-* properties. Generic cacheinfo is extended to read those properties while retaining CACHE_TYPE_UNIFIED for the resulting leaf.
The more involved part is preserving pSeries LPM and DLPAR behavior.
====================================================================
3. The existing PowerPC implementation owns references to its firmware cache nodes and destroys and recreates the cache objects when the firmware topology changes. Generic cacheinfo normally retains its per-CPU leaf allocations across CPU offline and online operations. That behavior is appropriate for ordinary hotplug, but not when LPM replaces the firmware cache topology or DLPAR detaches a CPU and its cache nodes.
This series adds explicit helpers to tear down and rebuild the complete generic cacheinfo hierarchy. These destructive operations run under the CPU hotplug write lock, excluding CPU hotplug readers while the old cacheinfo generationis replaced. Normal generic CPU hotplug behavior remains unchanged.
4. Moving cache discovery to the generic CPUHP callback also exposed an ordering issue for DLPAR-added CPUs. PowerPC previously associated cpu_dev->of_node and initialized its private cacheinfo from the same late dynamic CPUHP callback. Generic cacheinfo runs earlier at CPUHP_AP_BASE_CACHEINFO_ONLINE. For a DLPAR-added CPU, the CPU device already exists at that point, but its of_node is still NULL, causing generic cache discovery to fail.
An explicit PowerPC CPUHP state is added immediately before CPUHP_AP_BASE_CACHEINFO_ONLINE. The resulting ordering is:
PowerPC associates cpu_dev->of_node generic cacheinfo initializes the cache hierarchy PowerPC creates the remaining CPU sysfs attributes
CPU offline runs these callbacks in reverse order, ensuring that generic cacheinfo is removed before PowerPC releases the OF-node reference.
The series was tested on dedicated and shared Power11 LPARs. the existing cache sysfs values and hierarchy are preserved. Generic cacheinfo provides id and uevent in addition.
The testcases are covered and marked as success if cache values are preserved.
===================================================================
- Normal boot on dedicated LPARs - Success
- Normal boot on shared LPARs - Success
- Normal boot with lockdep on dedicated - Success
- CPU Hotplug (Dedicated and Shared LPAR) - Success
- CPU Hotplug with lockdep - Success
- LPM cacheinfo teardown and rebuild - Not tested
- DLPAR CPU remove and add - Success
- DLPAR CPU remove and add with lockdep - Success
- DLPAR add logical CPUs not present at boot - Success
- DLPAR reuse free CPUid from different node - Success
- Normal boot on PowerNV - Success
- CPU hotplug on PowerNV - Success
Script used for validation is here:
https://lore.kernel.org/all/[email protected]/
It is effectively checking for:
- Is cache hierarchy/values are same.
- comparing online,offline,possibe,preset masks.
- lscpu topology without id.
I have requested for the LPM test. Since I am on leave for next two weeks, wanted to send this out. Once I hear from LPM test, I will update the thread.
Moving PowerPC to generic cacheinfo also supplies the physical LLC size and sharing information required by get_effective_llc_bytes(). llc_override series[2] will use this information to scale the physical cache capacity to MC or package scope. In addition this also gives right information for page allocator.
[1] https://lore.kernel.org/all/[email protected]/#t
v1: [2] https://lore.kernel.org/all/[email protected]/
v1 -> v2:
=========
- Add full cacheinfo teardown and transactional rebuild handling for firmware topology replacement. Avoiding build failure.
- Hold the CPU hotplug write lock while replacing cacheinfo during pSeries LPM.
- Add an ordered PowerPC CPUHP state before generic cacheinfo to make
cpu_dev->of_node available for DLPAR-added CPUs.
- Clean up the caches/derived states after DLPAR remove.
- Clean up the caches/derived states after DLPAR add failure
Shrikanth Hegde (6):
cacheinfo: Allow architectures to provide custom cache IDs
cacheinfo: Support unified caches described by d-cache properties
cacheinfo: Add firmware topology replacement helpers
powerpc: Set CPU device OF node before generic cacheinfo setup 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 | 54 +- arch/powerpc/platforms/pseries/hotplug-cpu.c | 35 + arch/powerpc/platforms/pseries/mobility.c | 17 +- drivers/base/cacheinfo.c | 192 +++- include/linux/cacheinfo.h | 4 + include/linux/cpuhotplug.h | 1 + kernel/sched/topology.c | 11 +- 9 files changed, 368 insertions(+), 953 deletions(-) delete mode 100644 arch/powerpc/kernel/cacheinfo.h
Signature · 1 line
2.52.0