hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/cacheinfo.h
....@@ -3,6 +3,7 @@
33 #define _LINUX_CACHEINFO_H
44
55 #include <linux/bitops.h>
6
+#include <linux/cpu.h>
67 #include <linux/cpumask.h>
78 #include <linux/smp.h>
89
....@@ -16,6 +17,8 @@
1617 CACHE_TYPE_SEPARATE = CACHE_TYPE_INST | CACHE_TYPE_DATA,
1718 CACHE_TYPE_UNIFIED = BIT(2),
1819 };
20
+
21
+extern unsigned int coherency_max_size;
1922
2023 /**
2124 * struct cacheinfo - represent a cache leaf node
....@@ -99,4 +102,24 @@
99102
100103 const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_leaf);
101104
105
+/*
106
+ * Get the id of the cache associated with @cpu at level @level.
107
+ * cpuhp lock must be held.
108
+ */
109
+static inline int get_cpu_cacheinfo_id(int cpu, int level)
110
+{
111
+ struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu);
112
+ int i;
113
+
114
+ for (i = 0; i < ci->num_leaves; i++) {
115
+ if (ci->info_list[i].level == level) {
116
+ if (ci->info_list[i].attributes & CACHE_ID)
117
+ return ci->info_list[i].id;
118
+ return -1;
119
+ }
120
+ }
121
+
122
+ return -1;
123
+}
124
+
102125 #endif /* _LINUX_CACHEINFO_H */