]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.1-stable patches master
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Oct 2025 13:54:53 +0000 (15:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Oct 2025 13:54:53 +0000 (15:54 +0200)
added patches:
cacheinfo-fix-llc-is-not-exported-through-sysfs.patch
cacheinfo-initialize-variables-in-fetch_cache_info.patch
drivers-base-cacheinfo-update-cpu_map_populated-during-cpu-hotplug.patch

queue-6.1/cacheinfo-fix-llc-is-not-exported-through-sysfs.patch [new file with mode: 0644]
queue-6.1/cacheinfo-initialize-variables-in-fetch_cache_info.patch [new file with mode: 0644]
queue-6.1/drivers-base-cacheinfo-update-cpu_map_populated-during-cpu-hotplug.patch [new file with mode: 0644]
queue-6.1/series

diff --git a/queue-6.1/cacheinfo-fix-llc-is-not-exported-through-sysfs.patch b/queue-6.1/cacheinfo-fix-llc-is-not-exported-through-sysfs.patch
new file mode 100644 (file)
index 0000000..109a58b
--- /dev/null
@@ -0,0 +1,75 @@
+From 5c2712387d4850e0b64121d5fd3e6c4e84ea3266 Mon Sep 17 00:00:00 2001
+From: Yicong Yang <yangyicong@hisilicon.com>
+Date: Tue, 28 Mar 2023 19:49:15 +0800
+Subject: cacheinfo: Fix LLC is not exported through sysfs
+
+From: Yicong Yang <yangyicong@hisilicon.com>
+
+commit 5c2712387d4850e0b64121d5fd3e6c4e84ea3266 upstream.
+
+After entering 6.3-rc1 the LLC cacheinfo is not exported on our ACPI
+based arm64 server. This is because the LLC cacheinfo is partly reset
+when secondary CPUs boot up. On arm64 the primary cpu will allocate
+and setup cacheinfo:
+init_cpu_topology()
+  for_each_possible_cpu()
+    fetch_cache_info() // Allocate cacheinfo and init levels
+detect_cache_attributes()
+  cache_shared_cpu_map_setup()
+    if (!last_level_cache_is_valid()) // not valid, setup LLC
+      cache_setup_properties() // setup LLC
+
+On secondary CPU boot up:
+detect_cache_attributes()
+  populate_cache_leaves()
+    get_cache_type() // Get cache type from clidr_el1,
+                     // for LLC type=CACHE_TYPE_NOCACHE
+  cache_shared_cpu_map_setup()
+    if (!last_level_cache_is_valid()) // Valid and won't go to this branch,
+                                      // leave LLC's type=CACHE_TYPE_NOCACHE
+
+The last_level_cache_is_valid() use cacheinfo->{attributes, fw_token} to
+test it's valid or not, but populate_cache_leaves() will only reset
+LLC's type, so we won't try to re-setup LLC's type and leave it
+CACHE_TYPE_NOCACHE and won't export it through sysfs.
+
+This patch tries to fix this by not re-populating the cache leaves if
+the LLC is valid.
+
+Fixes: 5944ce092b97 ("arch_topology: Build cacheinfo from primary CPU")
+Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
+Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
+Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
+Link: https://lore.kernel.org/r/20230328114915.33340-1-yangyicong@huawei.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/base/cacheinfo.c |   16 +++++++++++-----
+ 1 file changed, 11 insertions(+), 5 deletions(-)
+
+--- a/drivers/base/cacheinfo.c
++++ b/drivers/base/cacheinfo.c
+@@ -490,12 +490,18 @@ int detect_cache_attributes(unsigned int
+ populate_leaves:
+       /*
+-       * populate_cache_leaves() may completely setup the cache leaves and
+-       * shared_cpu_map or it may leave it partially setup.
++       * If LLC is valid the cache leaves were already populated so just go to
++       * update the cpu map.
+        */
+-      ret = populate_cache_leaves(cpu);
+-      if (ret)
+-              goto free_ci;
++      if (!last_level_cache_is_valid(cpu)) {
++              /*
++               * populate_cache_leaves() may completely setup the cache leaves and
++               * shared_cpu_map or it may leave it partially setup.
++               */
++              ret = populate_cache_leaves(cpu);
++              if (ret)
++                      goto free_ci;
++      }
+       /*
+        * For systems using DT for cache hierarchy, fw_token
diff --git a/queue-6.1/cacheinfo-initialize-variables-in-fetch_cache_info.patch b/queue-6.1/cacheinfo-initialize-variables-in-fetch_cache_info.patch
new file mode 100644 (file)
index 0000000..3da9ab7
--- /dev/null
@@ -0,0 +1,37 @@
+From ecaef469920fd6d2c7687f19081946f47684a423 Mon Sep 17 00:00:00 2001
+From: Pierre Gondois <pierre.gondois@arm.com>
+Date: Tue, 24 Jan 2023 16:40:46 +0100
+Subject: cacheinfo: Initialize variables in fetch_cache_info()
+
+From: Pierre Gondois <pierre.gondois@arm.com>
+
+commit ecaef469920fd6d2c7687f19081946f47684a423 upstream.
+
+Set potentially uninitialized variables to 0. This is particularly
+relevant when CONFIG_ACPI_PPTT is not set.
+
+Reported-by: kernel test robot <lkp@intel.com>
+Link: https://lore.kernel.org/all/202301052307.JYt1GWaJ-lkp@intel.com/
+Reported-by: Dan Carpenter <error27@gmail.com>
+Link: https://lore.kernel.org/all/Y86iruJPuwNN7rZw@kili/
+Fixes: 5944ce092b97 ("arch_topology: Build cacheinfo from primary CPU")
+Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
+Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
+Link: https://lore.kernel.org/r/20230124154053.355376-2-pierre.gondois@arm.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/base/cacheinfo.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/base/cacheinfo.c
++++ b/drivers/base/cacheinfo.c
+@@ -440,7 +440,7 @@ int allocate_cache_info(int cpu)
+ int fetch_cache_info(unsigned int cpu)
+ {
+       struct cpu_cacheinfo *this_cpu_ci;
+-      unsigned int levels, split_levels;
++      unsigned int levels = 0, split_levels = 0;
+       int ret;
+       if (acpi_disabled) {
diff --git a/queue-6.1/drivers-base-cacheinfo-update-cpu_map_populated-during-cpu-hotplug.patch b/queue-6.1/drivers-base-cacheinfo-update-cpu_map_populated-during-cpu-hotplug.patch
new file mode 100644 (file)
index 0000000..532747a
--- /dev/null
@@ -0,0 +1,112 @@
+From c26fabe73330d983c7ce822c6b6ec0879b4da61f Mon Sep 17 00:00:00 2001
+From: K Prateek Nayak <kprateek.nayak@amd.com>
+Date: Mon, 8 May 2023 14:11:15 +0530
+Subject: drivers: base: cacheinfo: Update cpu_map_populated during CPU Hotplug
+
+From: K Prateek Nayak <kprateek.nayak@amd.com>
+
+commit c26fabe73330d983c7ce822c6b6ec0879b4da61f upstream.
+
+Until commit 5c2712387d48 ("cacheinfo: Fix LLC is not exported through
+sysfs"), cacheinfo called populate_cache_leaves() for CPU coming online
+which let the arch specific functions handle (at least on x86)
+populating the shared_cpu_map. However, with the changes in the
+aforementioned commit, populate_cache_leaves() is not called when a CPU
+comes online as a result of hotplug since last_level_cache_is_valid()
+returns true as the cacheinfo data is not discarded. The CPU coming
+online is not present in shared_cpu_map, however, it will not be added
+since the cpu_cacheinfo->cpu_map_populated flag is set (it is set in
+populate_cache_leaves() when cacheinfo is first populated for x86)
+
+This can lead to inconsistencies in the shared_cpu_map when an offlined
+CPU comes online again. Example below depicts the inconsistency in the
+shared_cpu_list in cacheinfo when CPU8 is offlined and onlined again on
+a 3rd Generation EPYC processor:
+
+  # for i in /sys/devices/system/cpu/cpu8/cache/index*/shared_cpu_list; do echo -n "$i: "; cat $i; done
+    /sys/devices/system/cpu/cpu8/cache/index0/shared_cpu_list: 8,136
+    /sys/devices/system/cpu/cpu8/cache/index1/shared_cpu_list: 8,136
+    /sys/devices/system/cpu/cpu8/cache/index2/shared_cpu_list: 8,136
+    /sys/devices/system/cpu/cpu8/cache/index3/shared_cpu_list: 8-15,136-143
+
+  # echo 0 > /sys/devices/system/cpu/cpu8/online
+  # echo 1 > /sys/devices/system/cpu/cpu8/online
+
+  # for i in /sys/devices/system/cpu/cpu8/cache/index*/shared_cpu_list; do echo -n "$i: "; cat $i; done
+    /sys/devices/system/cpu/cpu8/cache/index0/shared_cpu_list: 8
+    /sys/devices/system/cpu/cpu8/cache/index1/shared_cpu_list: 8
+    /sys/devices/system/cpu/cpu8/cache/index2/shared_cpu_list: 8
+    /sys/devices/system/cpu/cpu8/cache/index3/shared_cpu_list: 8
+
+  # cat /sys/devices/system/cpu/cpu136/cache/index0/shared_cpu_list
+    136
+
+  # cat /sys/devices/system/cpu/cpu136/cache/index3/shared_cpu_list
+    9-15,136-143
+
+Clear the flag when the CPU is removed from shared_cpu_map when
+cache_shared_cpu_map_remove() is called during CPU hotplug. This will
+allow cache_shared_cpu_map_setup() to add the CPU coming back online in
+the shared_cpu_map. Set the flag again when the shared_cpu_map is setup.
+Following are results of performing the same test as described above with
+the changes:
+
+  # for i in /sys/devices/system/cpu/cpu8/cache/index*/shared_cpu_list; do echo -n "$i: "; cat $i; done
+    /sys/devices/system/cpu/cpu8/cache/index0/shared_cpu_list: 8,136
+    /sys/devices/system/cpu/cpu8/cache/index1/shared_cpu_list: 8,136
+    /sys/devices/system/cpu/cpu8/cache/index2/shared_cpu_list: 8,136
+    /sys/devices/system/cpu/cpu8/cache/index3/shared_cpu_list: 8-15,136-143
+
+  # echo 0 > /sys/devices/system/cpu/cpu8/online
+  # echo 1 > /sys/devices/system/cpu/cpu8/online
+
+  # for i in /sys/devices/system/cpu/cpu8/cache/index*/shared_cpu_list; do echo -n "$i: "; cat $i; done
+    /sys/devices/system/cpu/cpu8/cache/index0/shared_cpu_list: 8,136
+    /sys/devices/system/cpu/cpu8/cache/index1/shared_cpu_list: 8,136
+    /sys/devices/system/cpu/cpu8/cache/index2/shared_cpu_list: 8,136
+    /sys/devices/system/cpu/cpu8/cache/index3/shared_cpu_list: 8-15,136-143
+
+  # cat /sys/devices/system/cpu/cpu136/cache/index0/shared_cpu_list
+    8,136
+
+  # cat /sys/devices/system/cpu/cpu136/cache/index3/shared_cpu_list
+    8-15,136-143
+
+Fixes: 5c2712387d48 ("cacheinfo: Fix LLC is not exported through sysfs")
+Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
+Reviewed-by: Yicong Yang <yangyicong@hisilicon.com>
+Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
+Link: https://lore.kernel.org/r/20230508084115.1157-3-kprateek.nayak@amd.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/base/cacheinfo.c |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/drivers/base/cacheinfo.c
++++ b/drivers/base/cacheinfo.c
+@@ -365,11 +365,14 @@ static int cache_shared_cpu_map_setup(un
+                       coherency_max_size = this_leaf->coherency_line_size;
+       }
++      /* shared_cpu_map is now populated for the cpu */
++      this_cpu_ci->cpu_map_populated = true;
+       return 0;
+ }
+ static void cache_shared_cpu_map_remove(unsigned int cpu)
+ {
++      struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
+       struct cacheinfo *this_leaf, *sib_leaf;
+       unsigned int sibling, index, sib_index;
+@@ -404,6 +407,9 @@ static void cache_shared_cpu_map_remove(
+               if (of_have_populated_dt())
+                       of_node_put(this_leaf->fw_token);
+       }
++
++      /* cpu is no longer populated in the shared map */
++      this_cpu_ci->cpu_map_populated = false;
+ }
+ static void free_cache_attributes(unsigned int cpu)
index 8241965d011130a6640f391cef2ff3c623450dcb..445f36c7e7cbec54602981b6f91c966a39a1d036 100644 (file)
@@ -191,3 +191,6 @@ bus-fsl-mc-check-return-value-of-platform_get_resource.patch
 net-usb-asix-hold-pm-usage-ref-to-avoid-pm-mdio-rtnl-deadlock.patch
 usb-typec-tipd-clear-interrupts-first.patch
 usb-cdns3-cdnsp-pci-remove-redundant-pci_disable_device-call.patch
+cacheinfo-initialize-variables-in-fetch_cache_info.patch
+cacheinfo-fix-llc-is-not-exported-through-sysfs.patch
+drivers-base-cacheinfo-update-cpu_map_populated-during-cpu-hotplug.patch