From b5fd2b2fbbb7f91268f67455cc771065aa76b9b7 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 15 Aug 2022 11:17:52 +0200 Subject: [PATCH] drop some duplicated 5.15 patches, and the topology ones --- ...-userspace-break-from-using-bin_attr.patch | 188 ------- ...he-reset-handle-early-in-the-p.patch-12121 | 46 -- queue-5.15/series | 5 - ...resent-clusters-of-cpus-within-a-die.patch | 458 ------------------ ...xport-cluster-attributes-only-if-an-.patch | 119 ----- ...xport-die-attributes-only-if-an-arch.patch | 120 ----- 6 files changed, 936 deletions(-) delete mode 100644 queue-5.15/drivers-base-fix-userspace-break-from-using-bin_attr.patch delete mode 100644 queue-5.15/mmc-renesas_sdhi-get-the-reset-handle-early-in-the-p.patch-12121 delete mode 100644 queue-5.15/topology-represent-clusters-of-cpus-within-a-die.patch delete mode 100644 queue-5.15/topology-sysfs-export-cluster-attributes-only-if-an-.patch delete mode 100644 queue-5.15/topology-sysfs-export-die-attributes-only-if-an-arch.patch diff --git a/queue-5.15/drivers-base-fix-userspace-break-from-using-bin_attr.patch b/queue-5.15/drivers-base-fix-userspace-break-from-using-bin_attr.patch deleted file mode 100644 index 5350be56185..00000000000 --- a/queue-5.15/drivers-base-fix-userspace-break-from-using-bin_attr.patch +++ /dev/null @@ -1,188 +0,0 @@ -From 40c1b27ca3a22ee15423a5f6e890084576809c2b Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 15 Jul 2022 09:49:24 -0400 -Subject: drivers/base: fix userspace break from using bin_attributes for - cpumap and cpulist - -From: Phil Auld - -[ Upstream commit 7ee951acd31a88f941fd6535fbdee3a1567f1d63 ] - -Using bin_attributes with a 0 size causes fstat and friends to return that -0 size. This breaks userspace code that retrieves the size before reading -the file. Rather than reverting 75bd50fa841 ("drivers/base/node.c: use -bin_attribute to break the size limitation of cpumap ABI") let's put in a -size value at compile time. - -For cpulist the maximum size is on the order of - NR_CPUS * (ceil(log10(NR_CPUS)) + 1)/2 - -which for 8192 is 20480 (8192 * 5)/2. In order to get near that you'd need -a system with every other CPU on one node. For example: (0,2,4,8, ... ). -To simplify the math and support larger NR_CPUS in the future we are using -(NR_CPUS * 7)/2. We also set it to a min of PAGE_SIZE to retain the older -behavior for smaller NR_CPUS. - -The cpumap file the size works out to be NR_CPUS/4 + NR_CPUS/32 - 1 -(or NR_CPUS * 9/32 - 1) including the ","s. - -Add a set of macros for these values to cpumask.h so they can be used in -multiple places. Apply these to the handful of such files in -drivers/base/topology.c as well as node.c. - -As an example, on an 80 cpu 4-node system (NR_CPUS == 8192): - -before: - --r--r--r--. 1 root root 0 Jul 12 14:08 system/node/node0/cpulist --r--r--r--. 1 root root 0 Jul 11 17:25 system/node/node0/cpumap - -after: - --r--r--r--. 1 root root 28672 Jul 13 11:32 system/node/node0/cpulist --r--r--r--. 1 root root 4096 Jul 13 11:31 system/node/node0/cpumap - -CONFIG_NR_CPUS = 16384 --r--r--r--. 1 root root 57344 Jul 13 14:03 system/node/node0/cpulist --r--r--r--. 1 root root 4607 Jul 13 14:02 system/node/node0/cpumap - -The actual number of cpus doesn't matter for the reported size since they -are based on NR_CPUS. - -Fixes: 75bd50fa841d ("drivers/base/node.c: use bin_attribute to break the size limitation of cpumap ABI") -Fixes: bb9ec13d156e ("topology: use bin_attribute to break the size limitation of cpumap ABI") -Cc: Greg Kroah-Hartman -Cc: "Rafael J. Wysocki" -Cc: Yury Norov -Cc: stable@vger.kernel.org -Acked-by: Yury Norov (for include/linux/cpumask.h) -Signed-off-by: Phil Auld -Link: https://lore.kernel.org/r/20220715134924.3466194-1-pauld@redhat.com -Signed-off-by: Greg Kroah-Hartman -Signed-off-by: Sasha Levin ---- - drivers/base/node.c | 4 ++-- - drivers/base/topology.c | 32 ++++++++++++++++---------------- - include/linux/cpumask.h | 18 ++++++++++++++++++ - 3 files changed, 36 insertions(+), 18 deletions(-) - -diff --git a/drivers/base/node.c b/drivers/base/node.c -index 0f5319b79fad..5366d1b5359c 100644 ---- a/drivers/base/node.c -+++ b/drivers/base/node.c -@@ -45,7 +45,7 @@ static inline ssize_t cpumap_read(struct file *file, struct kobject *kobj, - return n; - } - --static BIN_ATTR_RO(cpumap, 0); -+static BIN_ATTR_RO(cpumap, CPUMAP_FILE_MAX_BYTES); - - static inline ssize_t cpulist_read(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, char *buf, -@@ -66,7 +66,7 @@ static inline ssize_t cpulist_read(struct file *file, struct kobject *kobj, - return n; - } - --static BIN_ATTR_RO(cpulist, 0); -+static BIN_ATTR_RO(cpulist, CPULIST_FILE_MAX_BYTES); - - /** - * struct node_access_nodes - Access class device to hold user visible -diff --git a/drivers/base/topology.c b/drivers/base/topology.c -index 9d049724e4b4..4c8328468e97 100644 ---- a/drivers/base/topology.c -+++ b/drivers/base/topology.c -@@ -59,47 +59,47 @@ define_id_show_func(core_id); - static DEVICE_ATTR_RO(core_id); - - define_siblings_read_func(thread_siblings, sibling_cpumask); --static BIN_ATTR_RO(thread_siblings, 0); --static BIN_ATTR_RO(thread_siblings_list, 0); -+static BIN_ATTR_RO(thread_siblings, CPUMAP_FILE_MAX_BYTES); -+static BIN_ATTR_RO(thread_siblings_list, CPULIST_FILE_MAX_BYTES); - - define_siblings_read_func(core_cpus, sibling_cpumask); --static BIN_ATTR_RO(core_cpus, 0); --static BIN_ATTR_RO(core_cpus_list, 0); -+static BIN_ATTR_RO(core_cpus, CPUMAP_FILE_MAX_BYTES); -+static BIN_ATTR_RO(core_cpus_list, CPULIST_FILE_MAX_BYTES); - - define_siblings_read_func(core_siblings, core_cpumask); --static BIN_ATTR_RO(core_siblings, 0); --static BIN_ATTR_RO(core_siblings_list, 0); -+static BIN_ATTR_RO(core_siblings, CPUMAP_FILE_MAX_BYTES); -+static BIN_ATTR_RO(core_siblings_list, CPULIST_FILE_MAX_BYTES); - - #ifdef TOPOLOGY_CLUSTER_SYSFS - define_siblings_read_func(cluster_cpus, cluster_cpumask); --static BIN_ATTR_RO(cluster_cpus, 0); --static BIN_ATTR_RO(cluster_cpus_list, 0); -+static BIN_ATTR_RO(cluster_cpus, CPUMAP_FILE_MAX_BYTES); -+static BIN_ATTR_RO(cluster_cpus_list, CPULIST_FILE_MAX_BYTES); - #endif - - #ifdef TOPOLOGY_DIE_SYSFS - define_siblings_read_func(die_cpus, die_cpumask); --static BIN_ATTR_RO(die_cpus, 0); --static BIN_ATTR_RO(die_cpus_list, 0); -+static BIN_ATTR_RO(die_cpus, CPUMAP_FILE_MAX_BYTES); -+static BIN_ATTR_RO(die_cpus_list, CPULIST_FILE_MAX_BYTES); - #endif - - define_siblings_read_func(package_cpus, core_cpumask); --static BIN_ATTR_RO(package_cpus, 0); --static BIN_ATTR_RO(package_cpus_list, 0); -+static BIN_ATTR_RO(package_cpus, CPUMAP_FILE_MAX_BYTES); -+static BIN_ATTR_RO(package_cpus_list, CPULIST_FILE_MAX_BYTES); - - #ifdef CONFIG_SCHED_BOOK - define_id_show_func(book_id); - static DEVICE_ATTR_RO(book_id); - define_siblings_read_func(book_siblings, book_cpumask); --static BIN_ATTR_RO(book_siblings, 0); --static BIN_ATTR_RO(book_siblings_list, 0); -+static BIN_ATTR_RO(book_siblings, CPUMAP_FILE_MAX_BYTES); -+static BIN_ATTR_RO(book_siblings_list, CPULIST_FILE_MAX_BYTES); - #endif - - #ifdef CONFIG_SCHED_DRAWER - define_id_show_func(drawer_id); - static DEVICE_ATTR_RO(drawer_id); - define_siblings_read_func(drawer_siblings, drawer_cpumask); --static BIN_ATTR_RO(drawer_siblings, 0); --static BIN_ATTR_RO(drawer_siblings_list, 0); -+static BIN_ATTR_RO(drawer_siblings, CPUMAP_FILE_MAX_BYTES); -+static BIN_ATTR_RO(drawer_siblings_list, CPULIST_FILE_MAX_BYTES); - #endif - - static struct bin_attribute *bin_attrs[] = { -diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h -index 1e7399fc69c0..054e654f06de 100644 ---- a/include/linux/cpumask.h -+++ b/include/linux/cpumask.h -@@ -1045,4 +1045,22 @@ cpumap_print_list_to_buf(char *buf, const struct cpumask *mask, - [0] = 1UL \ - } } - -+/* -+ * Provide a valid theoretical max size for cpumap and cpulist sysfs files -+ * to avoid breaking userspace which may allocate a buffer based on the size -+ * reported by e.g. fstat. -+ * -+ * for cpumap NR_CPUS * 9/32 - 1 should be an exact length. -+ * -+ * For cpulist 7 is (ceil(log10(NR_CPUS)) + 1) allowing for NR_CPUS to be up -+ * to 2 orders of magnitude larger than 8192. And then we divide by 2 to -+ * cover a worst-case of every other cpu being on one of two nodes for a -+ * very large NR_CPUS. -+ * -+ * Use PAGE_SIZE as a minimum for smaller configurations. -+ */ -+#define CPUMAP_FILE_MAX_BYTES ((((NR_CPUS * 9)/32 - 1) > PAGE_SIZE) \ -+ ? (NR_CPUS * 9)/32 - 1 : PAGE_SIZE) -+#define CPULIST_FILE_MAX_BYTES (((NR_CPUS * 7)/2 > PAGE_SIZE) ? (NR_CPUS * 7)/2 : PAGE_SIZE) -+ - #endif /* __LINUX_CPUMASK_H */ --- -2.35.1 - diff --git a/queue-5.15/mmc-renesas_sdhi-get-the-reset-handle-early-in-the-p.patch-12121 b/queue-5.15/mmc-renesas_sdhi-get-the-reset-handle-early-in-the-p.patch-12121 deleted file mode 100644 index 707c218f207..00000000000 --- a/queue-5.15/mmc-renesas_sdhi-get-the-reset-handle-early-in-the-p.patch-12121 +++ /dev/null @@ -1,46 +0,0 @@ -From 6c8b682c62db9b2841ef8cf013679a090e660ac6 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 24 Jun 2022 19:14:37 +0100 -Subject: mmc: renesas_sdhi: Get the reset handle early in the probe - -From: Lad Prabhakar - -[ Upstream commit 0dac1e498f8130fdacfdd5289e3a7ac87ec1b9ad ] - -In case of devm_reset_control_get_optional_exclusive() failure we returned -directly instead of jumping to the error path to roll back initialization. - -This patch moves devm_reset_control_get_optional_exclusive() early in the -probe so that we have the reset handle prior to initialization of the -hardware. - -Fixes: b4d86f37eacb7 ("mmc: renesas_sdhi: do hard reset if possible") -Reported-by: Pavel Machek -Signed-off-by: Lad Prabhakar -Reviewed-by: Geert Uytterhoeven -Reviewed-by: Wolfram Sang -Link: https://lore.kernel.org/r/20220624181438.4355-2-prabhakar.mahadev-lad.rj@bp.renesas.com -Signed-off-by: Ulf Hansson -Signed-off-by: Sasha Levin ---- - drivers/mmc/host/renesas_sdhi_core.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c -index 791e180a0617..c692709fcdd7 100644 ---- a/drivers/mmc/host/renesas_sdhi_core.c -+++ b/drivers/mmc/host/renesas_sdhi_core.c -@@ -929,6 +929,10 @@ int renesas_sdhi_probe(struct platform_device *pdev, - if (IS_ERR(priv->rstc)) - return PTR_ERR(priv->rstc); - -+ priv->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); -+ if (IS_ERR(priv->rstc)) -+ return PTR_ERR(priv->rstc); -+ - priv->pinctrl = devm_pinctrl_get(&pdev->dev); - if (!IS_ERR(priv->pinctrl)) { - priv->pins_default = pinctrl_lookup_state(priv->pinctrl, --- -2.35.1 - diff --git a/queue-5.15/series b/queue-5.15/series index 31dfbfe9ee2..4e3d6f628cc 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -477,7 +477,6 @@ staging-rtl8192u-fix-sleep-in-atomic-context-bug-in-.patch mmc-sdhci-of-esdhc-fix-refcount-leak-in-esdhc_signal.patch mmc-mxcmmc-silence-a-clang-warning.patch mmc-renesas_sdhi-get-the-reset-handle-early-in-the-p.patch -mmc-renesas_sdhi-get-the-reset-handle-early-in-the-p.patch-12121 memstick-ms_block-fix-some-incorrect-memory-allocati.patch memstick-ms_block-fix-a-memory-leak.patch mmc-sdhci-of-at91-fix-set_uhs_signaling-rewriting-of.patch @@ -719,10 +718,6 @@ serial-8250-fold-endrun-device-support-into-oxsemi-t.patch serial-8250-add-proper-clock-handling-for-oxsemi-pci.patch tty-8250-add-support-for-brainboxes-px-cards.patch dm-writecache-set-a-default-max_writeback_jobs.patch -topology-represent-clusters-of-cpus-within-a-die.patch -topology-sysfs-export-die-attributes-only-if-an-arch.patch -topology-sysfs-export-cluster-attributes-only-if-an-.patch -drivers-base-fix-userspace-break-from-using-bin_attr.patch kexec-keys-s390-make-use-of-built-in-and-secondary-k.patch dm-thin-fix-use-after-free-crash-in-dm_sm_register_t.patch net-9p-initialize-the-iounit-field-during-fid-creati.patch diff --git a/queue-5.15/topology-represent-clusters-of-cpus-within-a-die.patch b/queue-5.15/topology-represent-clusters-of-cpus-within-a-die.patch deleted file mode 100644 index ccf01006605..00000000000 --- a/queue-5.15/topology-represent-clusters-of-cpus-within-a-die.patch +++ /dev/null @@ -1,458 +0,0 @@ -From 384461141ad56b514a9d7c6b3aa4f8ae5c27daff Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 24 Sep 2021 20:51:02 +1200 -Subject: topology: Represent clusters of CPUs within a die - -From: Jonathan Cameron - -[ Upstream commit c5e22feffdd736cb02b98b0f5b375c8ebc858dd4 ] - -Both ACPI and DT provide the ability to describe additional layers of -topology between that of individual cores and higher level constructs -such as the level at which the last level cache is shared. -In ACPI this can be represented in PPTT as a Processor Hierarchy -Node Structure [1] that is the parent of the CPU cores and in turn -has a parent Processor Hierarchy Nodes Structure representing -a higher level of topology. - -For example Kunpeng 920 has 6 or 8 clusters in each NUMA node, and each -cluster has 4 cpus. All clusters share L3 cache data, but each cluster -has local L3 tag. On the other hand, each clusters will share some -internal system bus. - -+-----------------------------------+ +---------+ -| +------+ +------+ +--------------------------+ | -| | CPU0 | | cpu1 | | +-----------+ | | -| +------+ +------+ | | | | | -| +----+ L3 | | | -| +------+ +------+ cluster | | tag | | | -| | CPU2 | | CPU3 | | | | | | -| +------+ +------+ | +-----------+ | | -| | | | -+-----------------------------------+ | | -+-----------------------------------+ | | -| +------+ +------+ +--------------------------+ | -| | | | | | +-----------+ | | -| +------+ +------+ | | | | | -| | | L3 | | | -| +------+ +------+ +----+ tag | | | -| | | | | | | | | | -| +------+ +------+ | +-----------+ | | -| | | | -+-----------------------------------+ | L3 | - | data | -+-----------------------------------+ | | -| +------+ +------+ | +-----------+ | | -| | | | | | | | | | -| +------+ +------+ +----+ L3 | | | -| | | tag | | | -| +------+ +------+ | | | | | -| | | | | | +-----------+ | | -| +------+ +------+ +--------------------------+ | -+-----------------------------------| | | -+-----------------------------------| | | -| +------+ +------+ +--------------------------+ | -| | | | | | +-----------+ | | -| +------+ +------+ | | | | | -| +----+ L3 | | | -| +------+ +------+ | | tag | | | -| | | | | | | | | | -| +------+ +------+ | +-----------+ | | -| | | | -+-----------------------------------+ | | -+-----------------------------------+ | | -| +------+ +------+ +--------------------------+ | -| | | | | | +-----------+ | | -| +------+ +------+ | | | | | -| | | L3 | | | -| +------+ +------+ +---+ tag | | | -| | | | | | | | | | -| +------+ +------+ | +-----------+ | | -| | | | -+-----------------------------------+ | | -+-----------------------------------+ | | -| +------+ +------+ +--------------------------+ | -| | | | | | +-----------+ | | -| +------+ +------+ | | | | | -| | | L3 | | | -| +------+ +------+ +--+ tag | | | -| | | | | | | | | | -| +------+ +------+ | +-----------+ | | -| | +---------+ -+-----------------------------------+ - -That means spreading tasks among clusters will bring more bandwidth -while packing tasks within one cluster will lead to smaller cache -synchronization latency. So both kernel and userspace will have -a chance to leverage this topology to deploy tasks accordingly to -achieve either smaller cache latency within one cluster or an even -distribution of load among clusters for higher throughput. - -This patch exposes cluster topology to both kernel and userspace. -Libraried like hwloc will know cluster by cluster_cpus and related -sysfs attributes. PoC of HWLOC support at [2]. - -Note this patch only handle the ACPI case. - -Special consideration is needed for SMT processors, where it is -necessary to move 2 levels up the hierarchy from the leaf nodes -(thus skipping the processor core level). - -Note that arm64 / ACPI does not provide any means of identifying -a die level in the topology but that may be unrelate to the cluster -level. - -[1] ACPI Specification 6.3 - section 5.2.29.1 processor hierarchy node - structure (Type 0) -[2] https://github.com/hisilicon/hwloc/tree/linux-cluster - -Signed-off-by: Jonathan Cameron -Signed-off-by: Tian Tao -Signed-off-by: Barry Song -Signed-off-by: Peter Zijlstra (Intel) -Link: https://lore.kernel.org/r/20210924085104.44806-2-21cnbao@gmail.com -Signed-off-by: Sasha Levin ---- - .../ABI/stable/sysfs-devices-system-cpu | 15 +++++ - Documentation/admin-guide/cputopology.rst | 12 ++-- - arch/arm64/kernel/topology.c | 2 + - drivers/acpi/pptt.c | 67 +++++++++++++++++++ - drivers/base/arch_topology.c | 15 +++++ - drivers/base/topology.c | 10 +++ - include/linux/acpi.h | 5 ++ - include/linux/arch_topology.h | 5 ++ - include/linux/topology.h | 6 ++ - 9 files changed, 133 insertions(+), 4 deletions(-) - -diff --git a/Documentation/ABI/stable/sysfs-devices-system-cpu b/Documentation/ABI/stable/sysfs-devices-system-cpu -index 516dafea03eb..3965ce504484 100644 ---- a/Documentation/ABI/stable/sysfs-devices-system-cpu -+++ b/Documentation/ABI/stable/sysfs-devices-system-cpu -@@ -42,6 +42,12 @@ Description: the CPU core ID of cpuX. Typically it is the hardware platform's - architecture and platform dependent. - Values: integer - -+What: /sys/devices/system/cpu/cpuX/topology/cluster_id -+Description: the cluster ID of cpuX. Typically it is the hardware platform's -+ identifier (rather than the kernel's). The actual value is -+ architecture and platform dependent. -+Values: integer -+ - What: /sys/devices/system/cpu/cpuX/topology/book_id - Description: the book ID of cpuX. Typically it is the hardware platform's - identifier (rather than the kernel's). The actual value is -@@ -85,6 +91,15 @@ Description: human-readable list of CPUs within the same die. - The format is like 0-3, 8-11, 14,17. - Values: decimal list. - -+What: /sys/devices/system/cpu/cpuX/topology/cluster_cpus -+Description: internal kernel map of CPUs within the same cluster. -+Values: hexadecimal bitmask. -+ -+What: /sys/devices/system/cpu/cpuX/topology/cluster_cpus_list -+Description: human-readable list of CPUs within the same cluster. -+ The format is like 0-3, 8-11, 14,17. -+Values: decimal list. -+ - What: /sys/devices/system/cpu/cpuX/topology/book_siblings - Description: internal kernel map of cpuX's hardware threads within the same - book_id. it's only used on s390. -diff --git a/Documentation/admin-guide/cputopology.rst b/Documentation/admin-guide/cputopology.rst -index b085dbac60a5..6b62e182baf4 100644 ---- a/Documentation/admin-guide/cputopology.rst -+++ b/Documentation/admin-guide/cputopology.rst -@@ -19,11 +19,13 @@ these macros in include/asm-XXX/topology.h:: - - #define topology_physical_package_id(cpu) - #define topology_die_id(cpu) -+ #define topology_cluster_id(cpu) - #define topology_core_id(cpu) - #define topology_book_id(cpu) - #define topology_drawer_id(cpu) - #define topology_sibling_cpumask(cpu) - #define topology_core_cpumask(cpu) -+ #define topology_cluster_cpumask(cpu) - #define topology_die_cpumask(cpu) - #define topology_book_cpumask(cpu) - #define topology_drawer_cpumask(cpu) -@@ -39,10 +41,12 @@ not defined by include/asm-XXX/topology.h: - - 1) topology_physical_package_id: -1 - 2) topology_die_id: -1 --3) topology_core_id: 0 --4) topology_sibling_cpumask: just the given CPU --5) topology_core_cpumask: just the given CPU --6) topology_die_cpumask: just the given CPU -+3) topology_cluster_id: -1 -+4) topology_core_id: 0 -+5) topology_sibling_cpumask: just the given CPU -+6) topology_core_cpumask: just the given CPU -+7) topology_cluster_cpumask: just the given CPU -+8) topology_die_cpumask: just the given CPU - - For architectures that don't support books (CONFIG_SCHED_BOOK) there are no - default definitions for topology_book_id() and topology_book_cpumask(). -diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c -index 4dd14a6620c1..9ab78ad826e2 100644 ---- a/arch/arm64/kernel/topology.c -+++ b/arch/arm64/kernel/topology.c -@@ -103,6 +103,8 @@ int __init parse_acpi_topology(void) - cpu_topology[cpu].thread_id = -1; - cpu_topology[cpu].core_id = topology_id; - } -+ topology_id = find_acpi_cpu_topology_cluster(cpu); -+ cpu_topology[cpu].cluster_id = topology_id; - topology_id = find_acpi_cpu_topology_package(cpu); - cpu_topology[cpu].package_id = topology_id; - -diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c -index fe69dc518f31..701f61c01359 100644 ---- a/drivers/acpi/pptt.c -+++ b/drivers/acpi/pptt.c -@@ -746,6 +746,73 @@ int find_acpi_cpu_topology_package(unsigned int cpu) - ACPI_PPTT_PHYSICAL_PACKAGE); - } - -+/** -+ * find_acpi_cpu_topology_cluster() - Determine a unique CPU cluster value -+ * @cpu: Kernel logical CPU number -+ * -+ * Determine a topology unique cluster ID for the given CPU/thread. -+ * This ID can then be used to group peers, which will have matching ids. -+ * -+ * The cluster, if present is the level of topology above CPUs. In a -+ * multi-thread CPU, it will be the level above the CPU, not the thread. -+ * It may not exist in single CPU systems. In simple multi-CPU systems, -+ * it may be equal to the package topology level. -+ * -+ * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found -+ * or there is no toplogy level above the CPU.. -+ * Otherwise returns a value which represents the package for this CPU. -+ */ -+ -+int find_acpi_cpu_topology_cluster(unsigned int cpu) -+{ -+ struct acpi_table_header *table; -+ acpi_status status; -+ struct acpi_pptt_processor *cpu_node, *cluster_node; -+ u32 acpi_cpu_id; -+ int retval; -+ int is_thread; -+ -+ status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); -+ if (ACPI_FAILURE(status)) { -+ acpi_pptt_warn_missing(); -+ return -ENOENT; -+ } -+ -+ acpi_cpu_id = get_acpi_id_for_cpu(cpu); -+ cpu_node = acpi_find_processor_node(table, acpi_cpu_id); -+ if (cpu_node == NULL || !cpu_node->parent) { -+ retval = -ENOENT; -+ goto put_table; -+ } -+ -+ is_thread = cpu_node->flags & ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD; -+ cluster_node = fetch_pptt_node(table, cpu_node->parent); -+ if (cluster_node == NULL) { -+ retval = -ENOENT; -+ goto put_table; -+ } -+ if (is_thread) { -+ if (!cluster_node->parent) { -+ retval = -ENOENT; -+ goto put_table; -+ } -+ cluster_node = fetch_pptt_node(table, cluster_node->parent); -+ if (cluster_node == NULL) { -+ retval = -ENOENT; -+ goto put_table; -+ } -+ } -+ if (cluster_node->flags & ACPI_PPTT_ACPI_PROCESSOR_ID_VALID) -+ retval = cluster_node->acpi_processor_id; -+ else -+ retval = ACPI_PTR_DIFF(cluster_node, table); -+ -+put_table: -+ acpi_put_table(table); -+ -+ return retval; -+} -+ - /** - * find_acpi_cpu_topology_hetero_id() - Get a core architecture tag - * @cpu: Kernel logical CPU number -diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c -index ef4fc89f085d..3d6df911bcb3 100644 ---- a/drivers/base/arch_topology.c -+++ b/drivers/base/arch_topology.c -@@ -600,6 +600,11 @@ const struct cpumask *cpu_coregroup_mask(int cpu) - return core_mask; - } - -+const struct cpumask *cpu_clustergroup_mask(int cpu) -+{ -+ return &cpu_topology[cpu].cluster_sibling; -+} -+ - void update_siblings_masks(unsigned int cpuid) - { - struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid]; -@@ -617,6 +622,12 @@ void update_siblings_masks(unsigned int cpuid) - if (cpuid_topo->package_id != cpu_topo->package_id) - continue; - -+ if (cpuid_topo->cluster_id == cpu_topo->cluster_id && -+ cpuid_topo->cluster_id != -1) { -+ cpumask_set_cpu(cpu, &cpuid_topo->cluster_sibling); -+ cpumask_set_cpu(cpuid, &cpu_topo->cluster_sibling); -+ } -+ - cpumask_set_cpu(cpuid, &cpu_topo->core_sibling); - cpumask_set_cpu(cpu, &cpuid_topo->core_sibling); - -@@ -635,6 +646,9 @@ static void clear_cpu_topology(int cpu) - cpumask_clear(&cpu_topo->llc_sibling); - cpumask_set_cpu(cpu, &cpu_topo->llc_sibling); - -+ cpumask_clear(&cpu_topo->cluster_sibling); -+ cpumask_set_cpu(cpu, &cpu_topo->cluster_sibling); -+ - cpumask_clear(&cpu_topo->core_sibling); - cpumask_set_cpu(cpu, &cpu_topo->core_sibling); - cpumask_clear(&cpu_topo->thread_sibling); -@@ -650,6 +664,7 @@ void __init reset_cpu_topology(void) - - cpu_topo->thread_id = -1; - cpu_topo->core_id = -1; -+ cpu_topo->cluster_id = -1; - cpu_topo->package_id = -1; - cpu_topo->llc_id = -1; - -diff --git a/drivers/base/topology.c b/drivers/base/topology.c -index 43c0940643f5..8f2b641d0b8c 100644 ---- a/drivers/base/topology.c -+++ b/drivers/base/topology.c -@@ -48,6 +48,9 @@ static DEVICE_ATTR_RO(physical_package_id); - define_id_show_func(die_id); - static DEVICE_ATTR_RO(die_id); - -+define_id_show_func(cluster_id); -+static DEVICE_ATTR_RO(cluster_id); -+ - define_id_show_func(core_id); - static DEVICE_ATTR_RO(core_id); - -@@ -63,6 +66,10 @@ define_siblings_read_func(core_siblings, core_cpumask); - static BIN_ATTR_RO(core_siblings, 0); - static BIN_ATTR_RO(core_siblings_list, 0); - -+define_siblings_read_func(cluster_cpus, cluster_cpumask); -+static BIN_ATTR_RO(cluster_cpus, 0); -+static BIN_ATTR_RO(cluster_cpus_list, 0); -+ - define_siblings_read_func(die_cpus, die_cpumask); - static BIN_ATTR_RO(die_cpus, 0); - static BIN_ATTR_RO(die_cpus_list, 0); -@@ -94,6 +101,8 @@ static struct bin_attribute *bin_attrs[] = { - &bin_attr_thread_siblings_list, - &bin_attr_core_siblings, - &bin_attr_core_siblings_list, -+ &bin_attr_cluster_cpus, -+ &bin_attr_cluster_cpus_list, - &bin_attr_die_cpus, - &bin_attr_die_cpus_list, - &bin_attr_package_cpus, -@@ -112,6 +121,7 @@ static struct bin_attribute *bin_attrs[] = { - static struct attribute *default_attrs[] = { - &dev_attr_physical_package_id.attr, - &dev_attr_die_id.attr, -+ &dev_attr_cluster_id.attr, - &dev_attr_core_id.attr, - #ifdef CONFIG_SCHED_BOOK - &dev_attr_book_id.attr, -diff --git a/include/linux/acpi.h b/include/linux/acpi.h -index 6224b1e32681..878a62266304 100644 ---- a/include/linux/acpi.h -+++ b/include/linux/acpi.h -@@ -1362,6 +1362,7 @@ static inline int lpit_read_residency_count_address(u64 *address) - #ifdef CONFIG_ACPI_PPTT - int acpi_pptt_cpu_is_thread(unsigned int cpu); - int find_acpi_cpu_topology(unsigned int cpu, int level); -+int find_acpi_cpu_topology_cluster(unsigned int cpu); - int find_acpi_cpu_topology_package(unsigned int cpu); - int find_acpi_cpu_topology_hetero_id(unsigned int cpu); - int find_acpi_cpu_cache_topology(unsigned int cpu, int level); -@@ -1374,6 +1375,10 @@ static inline int find_acpi_cpu_topology(unsigned int cpu, int level) - { - return -EINVAL; - } -+static inline int find_acpi_cpu_topology_cluster(unsigned int cpu) -+{ -+ return -EINVAL; -+} - static inline int find_acpi_cpu_topology_package(unsigned int cpu) - { - return -EINVAL; -diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h -index f180240dc95f..b97cea83b25e 100644 ---- a/include/linux/arch_topology.h -+++ b/include/linux/arch_topology.h -@@ -62,10 +62,12 @@ void topology_set_thermal_pressure(const struct cpumask *cpus, - struct cpu_topology { - int thread_id; - int core_id; -+ int cluster_id; - int package_id; - int llc_id; - cpumask_t thread_sibling; - cpumask_t core_sibling; -+ cpumask_t cluster_sibling; - cpumask_t llc_sibling; - }; - -@@ -73,13 +75,16 @@ struct cpu_topology { - extern struct cpu_topology cpu_topology[NR_CPUS]; - - #define topology_physical_package_id(cpu) (cpu_topology[cpu].package_id) -+#define topology_cluster_id(cpu) (cpu_topology[cpu].cluster_id) - #define topology_core_id(cpu) (cpu_topology[cpu].core_id) - #define topology_core_cpumask(cpu) (&cpu_topology[cpu].core_sibling) - #define topology_sibling_cpumask(cpu) (&cpu_topology[cpu].thread_sibling) -+#define topology_cluster_cpumask(cpu) (&cpu_topology[cpu].cluster_sibling) - #define topology_llc_cpumask(cpu) (&cpu_topology[cpu].llc_sibling) - void init_cpu_topology(void); - void store_cpu_topology(unsigned int cpuid); - const struct cpumask *cpu_coregroup_mask(int cpu); -+const struct cpumask *cpu_clustergroup_mask(int cpu); - void update_siblings_masks(unsigned int cpu); - void remove_cpu_topology(unsigned int cpuid); - void reset_cpu_topology(void); -diff --git a/include/linux/topology.h b/include/linux/topology.h -index 7634cd737061..80d27d717631 100644 ---- a/include/linux/topology.h -+++ b/include/linux/topology.h -@@ -186,6 +186,9 @@ static inline int cpu_to_mem(int cpu) - #ifndef topology_die_id - #define topology_die_id(cpu) ((void)(cpu), -1) - #endif -+#ifndef topology_cluster_id -+#define topology_cluster_id(cpu) ((void)(cpu), -1) -+#endif - #ifndef topology_core_id - #define topology_core_id(cpu) ((void)(cpu), 0) - #endif -@@ -195,6 +198,9 @@ static inline int cpu_to_mem(int cpu) - #ifndef topology_core_cpumask - #define topology_core_cpumask(cpu) cpumask_of(cpu) - #endif -+#ifndef topology_cluster_cpumask -+#define topology_cluster_cpumask(cpu) cpumask_of(cpu) -+#endif - #ifndef topology_die_cpumask - #define topology_die_cpumask(cpu) cpumask_of(cpu) - #endif --- -2.35.1 - diff --git a/queue-5.15/topology-sysfs-export-cluster-attributes-only-if-an-.patch b/queue-5.15/topology-sysfs-export-cluster-attributes-only-if-an-.patch deleted file mode 100644 index ca696e02291..00000000000 --- a/queue-5.15/topology-sysfs-export-cluster-attributes-only-if-an-.patch +++ /dev/null @@ -1,119 +0,0 @@ -From e4d3e0f541c6884ea3a9d67839e74293c4cd8512 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Mon, 29 Nov 2021 14:03:08 +0100 -Subject: topology/sysfs: export cluster attributes only if an architectures - has support - -From: Heiko Carstens - -[ Upstream commit e795707703b32fecdd7467afcc33ff1e92416c05 ] - -The cluster_id and cluster_cpus topology sysfs attributes have been -added with commit c5e22feffdd7 ("topology: Represent clusters of CPUs -within a die"). - -They are currently only used for x86, arm64, and riscv (via generic -arch topology), however they are still present with bogus default -values for all other architectures. Instead of enforcing such new -sysfs attributes to all architectures, make them only optional visible -if an architecture opts in by defining both the topology_cluster_id -and topology_cluster_cpumask attributes. - -This is similar to what was done when the book and drawer topology -levels were introduced: avoid useless and therefore confusing sysfs -attributes for architectures which cannot make use of them. - -This should not break any existing applications, since this is a -new interface introduced with the v5.16 merge window. - -Acked-by: Peter Zijlstra (Intel) -Signed-off-by: Heiko Carstens -Link: https://lore.kernel.org/r/20211129130309.3256168-3-hca@linux.ibm.com -Signed-off-by: Greg Kroah-Hartman -Signed-off-by: Sasha Levin ---- - Documentation/admin-guide/cputopology.rst | 4 ++-- - drivers/base/topology.c | 8 ++++++++ - include/linux/topology.h | 3 +++ - 3 files changed, 13 insertions(+), 2 deletions(-) - -diff --git a/Documentation/admin-guide/cputopology.rst b/Documentation/admin-guide/cputopology.rst -index c68d07533c45..ad2238b41439 100644 ---- a/Documentation/admin-guide/cputopology.rst -+++ b/Documentation/admin-guide/cputopology.rst -@@ -11,8 +11,8 @@ Architecture-neutral, drivers/base/topology.c, exports these attributes. - However, the book and drawer related sysfs files will only be created if - CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are selected, respectively. - --The die hierarchy related sysfs files will only be created if an architecture --provides the related macros as described below. -+The die and cluster hierarchy related sysfs files will only be created if an -+architecture provides the related macros as described below. - - CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are currently only used on s390, - where they reflect the cpu and cache hierarchy. -diff --git a/drivers/base/topology.c b/drivers/base/topology.c -index f079a55793ec..9d049724e4b4 100644 ---- a/drivers/base/topology.c -+++ b/drivers/base/topology.c -@@ -50,8 +50,10 @@ define_id_show_func(die_id); - static DEVICE_ATTR_RO(die_id); - #endif - -+#ifdef TOPOLOGY_CLUSTER_SYSFS - define_id_show_func(cluster_id); - static DEVICE_ATTR_RO(cluster_id); -+#endif - - define_id_show_func(core_id); - static DEVICE_ATTR_RO(core_id); -@@ -68,9 +70,11 @@ define_siblings_read_func(core_siblings, core_cpumask); - static BIN_ATTR_RO(core_siblings, 0); - static BIN_ATTR_RO(core_siblings_list, 0); - -+#ifdef TOPOLOGY_CLUSTER_SYSFS - define_siblings_read_func(cluster_cpus, cluster_cpumask); - static BIN_ATTR_RO(cluster_cpus, 0); - static BIN_ATTR_RO(cluster_cpus_list, 0); -+#endif - - #ifdef TOPOLOGY_DIE_SYSFS - define_siblings_read_func(die_cpus, die_cpumask); -@@ -105,8 +109,10 @@ static struct bin_attribute *bin_attrs[] = { - &bin_attr_thread_siblings_list, - &bin_attr_core_siblings, - &bin_attr_core_siblings_list, -+#ifdef TOPOLOGY_CLUSTER_SYSFS - &bin_attr_cluster_cpus, - &bin_attr_cluster_cpus_list, -+#endif - #ifdef TOPOLOGY_DIE_SYSFS - &bin_attr_die_cpus, - &bin_attr_die_cpus_list, -@@ -129,7 +135,9 @@ static struct attribute *default_attrs[] = { - #ifdef TOPOLOGY_DIE_SYSFS - &dev_attr_die_id.attr, - #endif -+#ifdef TOPOLOGY_CLUSTER_SYSFS - &dev_attr_cluster_id.attr, -+#endif - &dev_attr_core_id.attr, - #ifdef CONFIG_SCHED_BOOK - &dev_attr_book_id.attr, -diff --git a/include/linux/topology.h b/include/linux/topology.h -index 9ec418f58804..6f6f9cdc5274 100644 ---- a/include/linux/topology.h -+++ b/include/linux/topology.h -@@ -183,6 +183,9 @@ static inline int cpu_to_mem(int cpu) - #if defined(topology_die_id) && defined(topology_die_cpumask) - #define TOPOLOGY_DIE_SYSFS - #endif -+#if defined(topology_cluster_id) && defined(topology_cluster_cpumask) -+#define TOPOLOGY_CLUSTER_SYSFS -+#endif - - #ifndef topology_physical_package_id - #define topology_physical_package_id(cpu) ((void)(cpu), -1) --- -2.35.1 - diff --git a/queue-5.15/topology-sysfs-export-die-attributes-only-if-an-arch.patch b/queue-5.15/topology-sysfs-export-die-attributes-only-if-an-arch.patch deleted file mode 100644 index 5823a7194bb..00000000000 --- a/queue-5.15/topology-sysfs-export-die-attributes-only-if-an-arch.patch +++ /dev/null @@ -1,120 +0,0 @@ -From c7a2cd6e4e942bd7271d652f8f40aafab20e69c0 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Mon, 29 Nov 2021 14:03:07 +0100 -Subject: topology/sysfs: export die attributes only if an architectures has - support - -From: Heiko Carstens - -[ Upstream commit 2c4dcd7fd57b20a21b65da04d89c38a7217d79cf ] - -The die_id and die_cpus topology sysfs attributes have been added with -commit 0e344d8c709f ("cpu/topology: Export die_id") and commit -2e4c54dac7b3 ("topology: Create core_cpus and die_cpus sysfs attributes"). - -While they are currently only used and useful for x86 they are still -present with bogus default values for all architectures. Instead of -enforcing such new sysfs attributes to all architectures, make them -only optional visible if an architecture opts in by defining both the -topology_die_id and topology_die_cpumask attributes. - -This is similar to what was done when the book and drawer topology -levels were introduced: avoid useless and therefore confusing sysfs -attributes for architectures which cannot make use of them. - -This should not break any existing applications, since this is a -rather new interface and applications should be able to handle also -older kernel versions without such attributes - besides that they -contain only useful information for x86. - -Acked-by: Peter Zijlstra (Intel) -Signed-off-by: Heiko Carstens -Link: https://lore.kernel.org/r/20211129130309.3256168-2-hca@linux.ibm.com -Signed-off-by: Greg Kroah-Hartman -Signed-off-by: Sasha Levin ---- - Documentation/admin-guide/cputopology.rst | 3 +++ - drivers/base/topology.c | 8 ++++++++ - include/linux/topology.h | 4 ++++ - 3 files changed, 15 insertions(+) - -diff --git a/Documentation/admin-guide/cputopology.rst b/Documentation/admin-guide/cputopology.rst -index 6b62e182baf4..c68d07533c45 100644 ---- a/Documentation/admin-guide/cputopology.rst -+++ b/Documentation/admin-guide/cputopology.rst -@@ -11,6 +11,9 @@ Architecture-neutral, drivers/base/topology.c, exports these attributes. - However, the book and drawer related sysfs files will only be created if - CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are selected, respectively. - -+The die hierarchy related sysfs files will only be created if an architecture -+provides the related macros as described below. -+ - CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are currently only used on s390, - where they reflect the cpu and cache hierarchy. - -diff --git a/drivers/base/topology.c b/drivers/base/topology.c -index 8f2b641d0b8c..f079a55793ec 100644 ---- a/drivers/base/topology.c -+++ b/drivers/base/topology.c -@@ -45,8 +45,10 @@ static ssize_t name##_list_read(struct file *file, struct kobject *kobj, \ - define_id_show_func(physical_package_id); - static DEVICE_ATTR_RO(physical_package_id); - -+#ifdef TOPOLOGY_DIE_SYSFS - define_id_show_func(die_id); - static DEVICE_ATTR_RO(die_id); -+#endif - - define_id_show_func(cluster_id); - static DEVICE_ATTR_RO(cluster_id); -@@ -70,9 +72,11 @@ define_siblings_read_func(cluster_cpus, cluster_cpumask); - static BIN_ATTR_RO(cluster_cpus, 0); - static BIN_ATTR_RO(cluster_cpus_list, 0); - -+#ifdef TOPOLOGY_DIE_SYSFS - define_siblings_read_func(die_cpus, die_cpumask); - static BIN_ATTR_RO(die_cpus, 0); - static BIN_ATTR_RO(die_cpus_list, 0); -+#endif - - define_siblings_read_func(package_cpus, core_cpumask); - static BIN_ATTR_RO(package_cpus, 0); -@@ -103,8 +107,10 @@ static struct bin_attribute *bin_attrs[] = { - &bin_attr_core_siblings_list, - &bin_attr_cluster_cpus, - &bin_attr_cluster_cpus_list, -+#ifdef TOPOLOGY_DIE_SYSFS - &bin_attr_die_cpus, - &bin_attr_die_cpus_list, -+#endif - &bin_attr_package_cpus, - &bin_attr_package_cpus_list, - #ifdef CONFIG_SCHED_BOOK -@@ -120,7 +126,9 @@ static struct bin_attribute *bin_attrs[] = { - - static struct attribute *default_attrs[] = { - &dev_attr_physical_package_id.attr, -+#ifdef TOPOLOGY_DIE_SYSFS - &dev_attr_die_id.attr, -+#endif - &dev_attr_cluster_id.attr, - &dev_attr_core_id.attr, - #ifdef CONFIG_SCHED_BOOK -diff --git a/include/linux/topology.h b/include/linux/topology.h -index 80d27d717631..9ec418f58804 100644 ---- a/include/linux/topology.h -+++ b/include/linux/topology.h -@@ -180,6 +180,10 @@ static inline int cpu_to_mem(int cpu) - - #endif /* [!]CONFIG_HAVE_MEMORYLESS_NODES */ - -+#if defined(topology_die_id) && defined(topology_die_cpumask) -+#define TOPOLOGY_DIE_SYSFS -+#endif -+ - #ifndef topology_physical_package_id - #define topology_physical_package_id(cpu) ((void)(cpu), -1) - #endif --- -2.35.1 - -- 2.47.3