[PATCH 6/6] cacheinfo: Add cacheinfo_get_cache_affinity() function
Rob Herring
robh at kernel.org
Thu Dec 16 15:31:25 PST 2021
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 at linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael at kernel.org>
Signed-off-by: Rob Herring <robh at 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
More information about the linux-arm-kernel
mailing list