From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
driver-core@lists.linux.dev
Cc: sshegde@linux.ibm.com, christophe.leroy@csgroup.eu,
maddy@linux.ibm.com, gregkh@linuxfoundation.org,
rafael@kernel.org, dakr@kernel.org, johan@kernel.org,
sudeep.holla@kernel.org, ritesh.list@gmail.com,
tim.c.chen@linux.intel.com, yu.c.chen@intel.com
Subject: [PATCH 3/5] cacheinfo: Add teardown and rebuild helpers
Date: Wed, 18 Nov 2026 22:06:37 +0530 [thread overview]
Message-ID: <20261118163639.890546-4-sshegde@linux.ibm.com> (raw)
In-Reply-To: <20261118163639.890546-1-sshegde@linux.ibm.com>
The PowerPC cacheinfo implementation provides teardown and rebuild
operations for pSeries mobility.
During partition migration, firmware cache nodes may be replaced as part
of the device-tree update. Cacheinfo must first remove its sysfs objects
and release references to the old firmware nodes. After the device tree
has been updated, it must discover the new cache hierarchy and recreate
the cache information for each online CPU.
Provide equivalent helpers in generic cacheinfo so architectures moving
from private cacheinfo implementations can retain this behavior.
Both helpers require the CPU hotplug lock to be held. The teardown helper
removes cache sysfs devices and sharing-map membership before freeing the
per-CPU cache leaves. The rebuild helper rediscovers and recreates
cacheinfo for every online CPU.
[Both draft changelog and code are written by LLM]
Assisted-by: LLM
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
drivers/base/cacheinfo.c | 44 +++++++++++++++++++++++++++++++++++++++
include/linux/cacheinfo.h | 2 ++
2 files changed, 46 insertions(+)
diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
index 4a23377e9312..b13046863ea3 100644
--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -1120,6 +1120,50 @@ static int cacheinfo_cpu_pre_down(unsigned int cpu)
return 0;
}
+void cacheinfo_teardown(void)
+{
+ unsigned int cpu;
+
+ lockdep_assert_cpus_held();
+
+ /*
+ * Remove sysfs entries and detach online CPUs from the
+ * cache-sharing maps before releasing cache leaves that may
+ * reference firmware nodes.
+ */
+ for_each_online_cpu(cpu)
+ cacheinfo_cpu_pre_down(cpu);
+
+ for_each_possible_cpu(cpu) {
+ struct cpu_cacheinfo *ci = ci_cacheinfo(cpu);
+
+ kfree(ci->info_list);
+ ci->info_list = NULL;
+ ci->num_levels = 0;
+ ci->num_leaves = 0;
+ ci->per_cpu_data_slice_size = 0;
+ ci->cpu_map_populated = false;
+ ci->early_ci_levels = false;
+ }
+}
+
+int cacheinfo_rebuild(void)
+{
+ unsigned int cpu;
+ int first_err = 0;
+ int ret;
+
+ lockdep_assert_cpus_held();
+
+ for_each_online_cpu(cpu) {
+ ret = cacheinfo_cpu_online(cpu);
+ if (ret && !first_err)
+ first_err = ret;
+ }
+
+ return first_err;
+}
+
static int __init cacheinfo_sysfs_init(void)
{
return cpuhp_setup_state(CPUHP_AP_BASE_CACHEINFO_ONLINE,
diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h
index d3557a1b464b..89f2f9fcc88d 100644
--- a/include/linux/cacheinfo.h
+++ b/include/linux/cacheinfo.h
@@ -94,6 +94,8 @@ struct cacheinfo *get_cpu_cacheinfo_llc(unsigned int cpu);
int fetch_cache_info(unsigned int cpu);
int detect_cache_attributes(unsigned int cpu);
int cacheinfo_get_arch_id(unsigned int cpu, unsigned int level, unsigned int *id);
+void cacheinfo_teardown(void);
+int cacheinfo_rebuild(void);
#ifndef CONFIG_ACPI_PPTT
/*
* acpi_get_cache_info() is only called on ACPI enabled
--
2.54.0
next prev parent reply other threads:[~2026-11-18 16:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 16:36 [PATCH 0/5] cacheinfo, powerpc: Move powerpc to generic cacheinfo Shrikanth Hegde
2026-11-18 16:36 ` [PATCH 1/5] cacheinfo: Allow architectures to provide custom cache IDs Shrikanth Hegde
2026-11-18 16:36 ` [PATCH 2/5] cacheinfo: Support unified caches described by d-cache properties Shrikanth Hegde
2026-11-18 16:36 ` Shrikanth Hegde [this message]
2026-11-18 16:36 ` [PATCH 4/5] powerpc/cacheinfo: Move to generic cacheinfo Shrikanth Hegde
2026-11-18 16:36 ` [PATCH 5/5] 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=20261118163639.890546-4-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=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=rafael@kernel.org \
--cc=ritesh.list@gmail.com \
--cc=sudeep.holla@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®