@@ -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 */
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(+)