This patch removes the redundant sysfs cacheinfo code by reusing
the recently introduced generic cacheinfo infrastructure through the
commit 246246cbde5e ("drivers: base: support cpu cache information
interface to userspace via sysfs")
Signed-off-by: Sudeep Holla
Cc: Tony Luck
Cc: Fenghua Yu
Cc: Hanjun Guo
Cc: linux-i...@vger.kernel.org
---
arch/ia64/kernel/topology.c | 384 ++--
1 file changed, 117 insertions(+), 267 deletions(-)
v1->v2:
- Rebased on top -next that has a patch introducing
cpu_map_populated
- Also added SMP related macros that I missed in v1
Hi,
This is repost of the patch that was posted before several times to
remove duplicate code. Since I don't have the platform to test, I was
hoping to get some testing. This time Hanjun has kindly agreed to do
some testing. Thanks a lot Hanjun in advance. You need to base this on
top linux-next as there are few patches there. Take your time as this is
not urgent at all.
Just compare the result of:
grep "" /sys/devices/system/cpu/cpu*/cache/index*/*
before and after applying the patch. They should match except there will
be new "/sys/devices/system/cpu/cpu*/cache/index*/power" directory which
is fine.
Regards,
Sudeep
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index 1a68f012a6dc..df8685acb203 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -13,6 +13,7 @@
* Populate cpu cache entries in sysfs for cpu cache info
*/
+#include
#include
#include
#include
@@ -21,7 +22,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -103,60 +103,25 @@ subsys_initcall(topology_init);
/*
* Export cpu cache information through sysfs
*/
-
-/*
- * A bunch of string array to get pretty printing
- */
-static const char *cache_types[] = {
- "", /* not used */
- "Instruction",
- "Data",
- "Unified" /* unified */
-};
-
-static const char *cache_mattrib[]={
- "WriteThrough",
- "WriteBack",
- "", /* reserved */
- "" /* reserved */
-};
-
-struct cache_info {
- pal_cache_config_info_t cci;
- cpumask_t shared_cpu_map;
- int level;
- int type;
- struct kobject kobj;
-};
-
-struct cpu_cache_info {
- struct cache_info *cache_leaves;
- int num_cache_leaves;
- struct kobject kobj;
-};
-
-static struct cpu_cache_info all_cpu_cache_info[NR_CPUS];
-#define LEAF_KOBJECT_PTR(x,y)(&all_cpu_cache_info[x].cache_leaves[y])
-
#ifdef CONFIG_SMP
-static void cache_shared_cpu_map_setup(unsigned int cpu,
- struct cache_info * this_leaf)
+static int __cache_cpumap_setup(unsigned int cpu, struct cacheinfo *this_leaf)
{
pal_cache_shared_info_t csi;
- int num_shared, i = 0;
- unsigned int j;
+ int num_shared, i = 0, j;
+ enum cache_type type = this_leaf->type;
if (cpu_data(cpu)->threads_per_core <= 1 &&
cpu_data(cpu)->cores_per_socket <= 1) {
cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map);
- return;
+ return 0;
}
- if (ia64_pal_cache_shared_info(this_leaf->level,
- this_leaf->type,
- 0,
- &csi) != PAL_STATUS_SUCCESS)
- return;
+ if (type == CACHE_TYPE_UNIFIED)
+ type = CACHE_TYPE_DATA;
+
+ if (ia64_pal_cache_shared_info(this_leaf->level, type, 0,
+ &csi) != PAL_STATUS_SUCCESS)
+ return -EIO;
num_shared = (int) csi.num_shared;
do {
@@ -165,266 +130,151 @@ static void cache_shared_cpu_map_setup(unsigned int cpu,
&& cpu_data(j)->core_id == csi.log1_cid
&& cpu_data(j)->thread_id == csi.log1_tid)
cpumask_set_cpu(j, &this_leaf->shared_cpu_map);
-
i++;
} while (i < num_shared &&
- ia64_pal_cache_shared_info(this_leaf->level,
- this_leaf->type,
- i,
- &csi) == PAL_STATUS_SUCCESS);
-}
-#else
-static void cache_shared_cpu_map_setup(unsigned int cpu,
- struct cache_info * this_leaf)
-{
- cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map);
- return;
-}
-#endif
-
-static ssize_t show_coherency_line_size(struct cache_info *this_leaf,
- char *buf)
-{
- return sprintf(buf, "%u\n", 1 << this_leaf->cci.pcci_line_size);
+ia64_pal_cache_shared_info(this_leaf->level, type, i,
+ &csi) == PAL_STATUS_SUCCESS);
+ return 0;
}
-static ssize_t show_ways_of_associativity(struct cache_info *