mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: maddy@linux.ibm.com, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, driver-core@lists.linux.dev
Cc: sshegde@linux.ibm.com, christophe.leroy@csgroup.eu,
	ritesh.list@gmail.com, tim.c.chen@linux.intel.com,
	yu.c.chen@intel.com, gregkh@linuxfoundation.org,
	rafael@kernel.org, dakr@kernel.org, johan@kernel.org,
	sudeep.holla@kernel.org, peterz@infradead.org, tglx@kernel.org,
	kprateek.nayak@amd.com, srikar@linux.ibm.com
Subject: [PATCH v2 0/6] cacheinfo, powerpc, sched: Move powerpc to generic cacheinfo
Date: Fri, 27 Nov 2026 20:52:36 +0530	[thread overview]
Message-ID: <20261127152242.306333-1-sshegde@linux.ibm.com> (raw)

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/d76a72b5-e489-47fe-81bd-a3bf5935c209@linux.ibm.com/
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/1424715500-21725-1-git-send-email-sudeep.holla@arm.com/#t
v1: [2] https://lore.kernel.org/all/20261023131646.2907938-1-sshegde@linux.ibm.com/

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

-- 
2.52.0


             reply	other threads:[~2026-11-27 15:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 15:22 Shrikanth Hegde [this message]
2026-11-27 15:22 ` [PATCH v2 1/6] cacheinfo: Allow architectures to provide custom cache IDs Shrikanth Hegde
2026-11-27 15:22 ` [PATCH v2 2/6] cacheinfo: Support unified caches described by d-cache properties Shrikanth Hegde
2026-11-27 15:22 ` [PATCH v2 3/6] cacheinfo: Add firmware topology replacement helpers Shrikanth Hegde
2026-11-27 15:22 ` [PATCH v2 4/6] powerpc: Set CPU device OF node before generic cacheinfo setup Shrikanth Hegde
2026-11-27 15:22 ` [PATCH v2 5/6] powerpc/cacheinfo: Move to generic cacheinfo Shrikanth Hegde
2026-11-27 15:22 ` [PATCH v2 6/6] sched/topology: Remove stale comment around llc_bytes on powerpc Shrikanth Hegde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127152242.306333-1-sshegde@linux.ibm.com \
    --to=sshegde@linux.ibm.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=ritesh.list@gmail.com \
    --cc=srikar@linux.ibm.com \
    --cc=sudeep.holla@kernel.org \
    --cc=tglx@kernel.org \
    --cc=tim.c.chen@linux.intel.com \
    --cc=yu.c.chen@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®