3cd12006bb
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
115 lines
3.3 KiB
Diff
115 lines
3.3 KiB
Diff
From 5885bd771fe2ef468139178e3dd5a62bb3d355a6 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <5885bd771fe2ef468139178e3dd5a62bb3d355a6.1507237259.git.Jim.Somerville@windriver.com>
|
|
In-Reply-To: <2a9fb6a58e40e8604d97223603111e869bb774b1.1507237258.git.Jim.Somerville@windriver.com>
|
|
References: <2a9fb6a58e40e8604d97223603111e869bb774b1.1507237258.git.Jim.Somerville@windriver.com>
|
|
From: Alex Kozyrev <alex.kozyrev@windriver.com>
|
|
Date: Wed, 19 Jul 2017 02:25:15 -0500
|
|
Subject: [PATCH 18/24] Fix cacheinfo compilation issues for 3.10
|
|
|
|
Had to revert commit 7cc277b489b4fe91f42eb596b282879c2d13152e:
|
|
"Install the callbacks via the state machine and let the core invoke
|
|
the callbacks on the already online CPUs. No functional change."
|
|
There is no hotplug state machine in 3.10 kernel.
|
|
Also implemented cpumap_print_to_pagebuf() function in place.
|
|
|
|
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
|
|
---
|
|
drivers/base/cacheinfo.c | 65 ++++++++++++++++++++++++++++++++++++------------
|
|
1 file changed, 49 insertions(+), 16 deletions(-)
|
|
|
|
diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
|
|
index eb3af27..c924f7e 100644
|
|
--- a/drivers/base/cacheinfo.c
|
|
+++ b/drivers/base/cacheinfo.c
|
|
@@ -383,7 +383,12 @@ static ssize_t shared_cpumap_show_func(struct device *dev, bool list, char *buf)
|
|
struct cacheinfo *this_leaf = dev_get_drvdata(dev);
|
|
const struct cpumask *mask = &this_leaf->shared_cpu_map;
|
|
|
|
- return cpumap_print_to_pagebuf(list, buf, mask);
|
|
+ int len = list?
|
|
+ cpulist_scnprintf(buf, PAGE_SIZE-2, mask) :
|
|
+ cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
|
|
+ buf[len++] = '\n';
|
|
+ buf[len] = '\0';
|
|
+ return len;
|
|
}
|
|
|
|
static ssize_t shared_cpu_map_show(struct device *dev,
|
|
@@ -633,30 +638,58 @@ err:
|
|
return rc;
|
|
}
|
|
|
|
-static int cacheinfo_cpu_online(unsigned int cpu)
|
|
+static void cache_remove_dev(unsigned int cpu)
|
|
{
|
|
- int rc = detect_cache_attributes(cpu);
|
|
+ if (!cpumask_test_cpu(cpu, &cache_dev_map))
|
|
+ return;
|
|
+ cpumask_clear_cpu(cpu, &cache_dev_map);
|
|
|
|
- if (rc)
|
|
- return rc;
|
|
- rc = cache_add_dev(cpu);
|
|
- if (rc)
|
|
- free_cache_attributes(cpu);
|
|
- return rc;
|
|
+ cpu_cache_sysfs_exit(cpu);
|
|
}
|
|
|
|
-static int cacheinfo_cpu_pre_down(unsigned int cpu)
|
|
+static int cacheinfo_cpu_callback(struct notifier_block *nfb,
|
|
+ unsigned long action, void *hcpu)
|
|
{
|
|
- if (cpumask_test_and_clear_cpu(cpu, &cache_dev_map))
|
|
- cpu_cache_sysfs_exit(cpu);
|
|
+ unsigned int cpu = (unsigned long)hcpu;
|
|
+ int rc = 0;
|
|
|
|
- free_cache_attributes(cpu);
|
|
- return 0;
|
|
+ switch (action & ~CPU_TASKS_FROZEN) {
|
|
+ case CPU_ONLINE:
|
|
+ rc = detect_cache_attributes(cpu);
|
|
+ if (!rc)
|
|
+ rc = cache_add_dev(cpu);
|
|
+ break;
|
|
+ case CPU_DEAD:
|
|
+ cache_remove_dev(cpu);
|
|
+ if (per_cpu_cacheinfo(cpu))
|
|
+ free_cache_attributes(cpu);
|
|
+ break;
|
|
+ }
|
|
+ return notifier_from_errno(rc);
|
|
}
|
|
|
|
static int __init cacheinfo_sysfs_init(void)
|
|
{
|
|
- return cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "base/cacheinfo:online",
|
|
- cacheinfo_cpu_online, cacheinfo_cpu_pre_down);
|
|
+ int cpu, rc = 0;
|
|
+
|
|
+ cpu_notifier_register_begin();
|
|
+
|
|
+ for_each_online_cpu(cpu) {
|
|
+ rc = detect_cache_attributes(cpu);
|
|
+ if (rc)
|
|
+ goto out;
|
|
+ rc = cache_add_dev(cpu);
|
|
+ if (rc) {
|
|
+ free_cache_attributes(cpu);
|
|
+ pr_err("error populating cacheinfo..cpu%d\n", cpu);
|
|
+ goto out;
|
|
+ }
|
|
+ }
|
|
+ __hotcpu_notifier(cacheinfo_cpu_callback, 0);
|
|
+
|
|
+out:
|
|
+ cpu_notifier_register_done();
|
|
+ return rc;
|
|
}
|
|
+
|
|
device_initcall(cacheinfo_sysfs_init);
|
|
--
|
|
1.8.3.1
|
|
|