lkml.org 
[lkml]   [2021]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 6/6] cacheinfo: Add cacheinfo_get_cache_affinity() function
Date
Add a cacheinfo_get_cache_affinity() function to retrieve the CPU affinity
mask for a given cache identified by level and cache id.

This is needed by Arm MPAM to get the CPU affinity of MPAM enabled caches.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
---
include/linux/cacheinfo.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h
index 37652cfdd8dc..5e72420cdc75 100644
--- a/include/linux/cacheinfo.h
+++ b/include/linux/cacheinfo.h
@@ -123,4 +123,28 @@ static inline int get_cpu_cacheinfo_id(int cpu, int level)
return -1;
}

+/*
+ * Get the CPU affinity of the cache associated with @cpu at level @level and
+ * with identifier @id.
+ * cpuhp lock must be held.
+ */
+static inline int cacheinfo_get_cache_affinity(int cpu, int level, int id,
+ cpumask_t *mask)
+{
+ struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu);
+ int i;
+
+ for (i = 0; ci->info_list && i < ci->num_leaves; i++) {
+ if ((ci->info_list[i].level == level) &&
+ (ci->info_list[i].attributes & CACHE_ID) &&
+ (ci->info_list[i].id == id)) {
+ cpumask_copy(mask, &ci->info_list[i].cpu_affinity_map);
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+}
+
+
#endif /* _LINUX_CACHEINFO_H */
--
2.32.0
\
 
 \ /
  Last update: 2021-12-17 00:33    [W:0.145 / U:6.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site