+ cacheinfo-add-function-to-get-cacheinfo-for-a-given-cpu-cachelevel.patch added to mm-nonmm-unstable branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: cacheinfo: add function to get cacheinfo for a given (cpu, cachelevel)
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     cacheinfo-add-function-to-get-cacheinfo-for-a-given-cpu-cachelevel.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/cacheinfo-add-function-to-get-cacheinfo-for-a-given-cpu-cachelevel.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Tony Luck <tony.luck@xxxxxxxxx>
Subject: cacheinfo: add function to get cacheinfo for a given (cpu, cachelevel)
Date: Fri, 31 May 2024 12:57:18 -0700

Patch series "Add and use get_cpu_cacheinfo_level()".

This helper function came up in discussion of the resctrl patches for
Sub-NUMA Cluster (SNC) support.  Reinette pointed out[1] that there are
already two places where it would clean things up by avoiding open coding.
The SNC patches will add two additional call sites.

So rather than have this jammed up as part of the SNC series, I'm posting
it as a simple standalone cleanup.

[1] https://lore.kernel.org/all/050c64b3-20b3-4db6-b782-f5124ebaab31@xxxxxxxxx/


This patch (of 3):

Resctrl code open codes a search for information about a given cache level
in a couple of places (and more are on the way).

Provide a new inline function get_cpu_cacheinfo_level() in
<linux/cacheinfo.h> to do the search and return a pointer to the cacheinfo
structure.

Simplify the existing get_cpu_cacheinfo_id() by using this new function to
do the search.

Link: https://lkml.kernel.org/r/20240531195720.232561-1-tony.luck@xxxxxxxxx
Link: https://lkml.kernel.org/r/20240531195720.232561-2-tony.luck@xxxxxxxxx
Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
Cc: Babu Moger <babu.moger@xxxxxxx>
Cc: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Cc: Dave Martin <Dave.Martin@xxxxxxx>
Cc: Drew Fustini <dfustini@xxxxxxxxxxxx>
Cc: Fenghua Yu <fenghua.yu@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: James Morse <james.morse@xxxxxxx>
Cc: Maciej Wieczor-Retman <maciej.wieczor-retman@xxxxxxxxx>
Cc: Peter Newman <peternewman@xxxxxxxxxx>
Cc: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Tony Luck <tony.luck@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 include/linux/cacheinfo.h |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

--- a/include/linux/cacheinfo.h~cacheinfo-add-function-to-get-cacheinfo-for-a-given-cpu-cachelevel
+++ a/include/linux/cacheinfo.h
@@ -113,10 +113,10 @@ int acpi_get_cache_info(unsigned int cpu
 const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_leaf);
 
 /*
- * Get the id of the cache associated with @cpu at level @level.
+ * Get the cacheinfo structure for cache associated with @cpu at level @level.
  * cpuhp lock must be held.
  */
-static inline int get_cpu_cacheinfo_id(int cpu, int level)
+static inline struct cacheinfo *get_cpu_cacheinfo_level(int cpu, int level)
 {
 	struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu);
 	int i;
@@ -124,12 +124,23 @@ static inline int get_cpu_cacheinfo_id(i
 	for (i = 0; i < ci->num_leaves; i++) {
 		if (ci->info_list[i].level == level) {
 			if (ci->info_list[i].attributes & CACHE_ID)
-				return ci->info_list[i].id;
-			return -1;
+				return &ci->info_list[i];
+			return NULL;
 		}
 	}
 
-	return -1;
+	return NULL;
+}
+
+/*
+ * Get the id of the cache associated with @cpu at level @level.
+ * cpuhp lock must be held.
+ */
+static inline int get_cpu_cacheinfo_id(int cpu, int level)
+{
+	struct cacheinfo *ci = get_cpu_cacheinfo_level(cpu, level);
+
+	return ci ? ci->id : -1;
 }
 
 #ifdef CONFIG_ARM64
_

Patches currently in -mm which might be from tony.luck@xxxxxxxxx are

cacheinfo-add-function-to-get-cacheinfo-for-a-given-cpu-cachelevel.patch
x86-resctrl-replace-open-code-cacheinfo-search-in-pseudo_lock_region_init.patch
x86-resctrl-replace-open-code-cacheinfo-search-in-rdtgroup_cbm_to_size.patch





[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux