Re: [RFC PATCH v3 01/13] lib/sbm: Introduce helpers for architectures to configure LLC properties
flat view
From: Tim Chen <hidden>
Date: 2026-10-12 22:22:09
Also in:
driver-core, linux-arch, linux-mips, linux-s390, lkml, loongarch
On Thu, 2026-10-01 at 19:28 +0000, K Prateek Nayak wrote:
Subsequent commits will add arch/ hooks to configure the sparsebitmask (sbm) topology - number of sbm instance and the maximum CPUs that a single instance can represent. Introduce sbm_set_topology() that helps architectures configure the sbm topology. Also add arch_sbm_cpu_instance_id() which will be used to map CPUs to the sbm instances during init to keep CPUs on the same instance on the same sbm leaf. Individual arch/ users will be added one at a time in the subsequent commits.
Thanks for working on this series.
quoted hunk ↗ jump to hunk
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com> --- include/linux/sbm.h | 8 ++++++++ lib/Makefile | 2 +- lib/sbm.c | 27 +++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 include/linux/sbm.h create mode 100644 lib/sbm.cdiff --git a/include/linux/sbm.h b/include/linux/sbm.h new file mode 100644 index 000000000000..adac12ed233a --- /dev/null +++ b/include/linux/sbm.h@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_SBM_H +#define _LINUX_SBM_H + +int arch_sbm_cpu_instance_id(int cpu); +void sbm_set_topology(int num_instances, int max_threads_per_instance); + +#endif /* _LINUX_SBM_H */diff --git a/lib/Makefile b/lib/Makefile index dfab958327c5..7776330f5b25 100644 --- a/lib/Makefile +++ b/lib/Makefile@@ -40,7 +40,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ is_single_threaded.o plist.o decompress.o kobject_uevent.o \ earlycpio.o seq_buf.o siphash.o dec_and_lock.o \ nmi_backtrace.o win_minmax.o memcat_p.o \ - buildid.o objpool.o iomem_copy.o sys_info.o + buildid.o objpool.o iomem_copy.o sys_info.o sbm.o lib-$(CONFIG_UNION_FIND) += union_find.o lib-$(CONFIG_PRINTK) += dump_stack.odiff --git a/lib/sbm.c b/lib/sbm.c new file mode 100644 index 000000000000..82280e3306de --- /dev/null +++ b/lib/sbm.c@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */
Minor nits. Convention is // SPDX-License-Identifier: GPL-2.0 for .c file according to Documentation/process/license-rules.rst checkpatch asks for a MAINTAINERS entry for include/linux/sbm.h and lib/sbm.c. Tim
quoted hunk ↗ jump to hunk
+#include <linux/sbm.h> +#include <linux/init.h> +#include <linux/printk.h> + +static int sbm_max_threads_per_instance = -1; +static int sbm_num_instance = -1; + +/* + * In absence of an arch definition, consider all CPUs to + * belong to the same sbm instance. + */ +int __weak arch_sbm_cpu_instance_id(int cpu) +{ + return 0; +} + +void __init sbm_set_topology(int num_instances, int max_threads_per_instance) +{ + sbm_max_threads_per_instance = max_threads_per_instance; + sbm_num_instance = num_instances; + + pr_info("sbm topology set to %d instance(s) with a maximum of %d thread(s) per instance\n", + sbm_num_instance, + sbm_max_threads_per_instance); +} +