aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2017-12-12 18:52:07 -0600
committerLeandro A. F. Pereira <leandro@hardinfo.org>2018-02-27 07:43:20 -0800
commit9d126592569f7aabbf4d5125930a461f8aa64a7f (patch)
tree5a164ab4e62627d6fa86b5130c77d63db6aa6fd6
parent2f9dad39b0847991dd2b19dc3e999f89397f47f9 (diff)
x86: fix for kernels that don't provide cache id
Use shared_cpu_list as a unique cache id, but only in the case that kernel-supplied cache id is not available. Signed-off-by: Burt P <pburt0@gmail.com>
-rw-r--r--includes/x86/processor-platform.h1
-rw-r--r--modules/devices/x86/processor.c21
2 files changed, 19 insertions, 3 deletions
diff --git a/includes/x86/processor-platform.h b/includes/x86/processor-platform.h
index 2c0a8ffd..a89a831f 100644
--- a/includes/x86/processor-platform.h
+++ b/includes/x86/processor-platform.h
@@ -31,6 +31,7 @@ struct _ProcessorCache {
gchar *type;
gint ways_of_associativity;
gint uid; /* uid is unique among caches with the same (type, level) */
+ gchar *shared_cpu_list; /* some kernel's don't give a uid, so try shared_cpu_list */
gint phy_sock;
};
diff --git a/modules/devices/x86/processor.c b/modules/devices/x86/processor.c
index 46c524b9..a3f6b9fe 100644
--- a/modules/devices/x86/processor.c
+++ b/modules/devices/x86/processor.c
@@ -176,6 +176,7 @@ static void __cache_obtain_info(Processor *processor)
{
ProcessorCache *cache;
gchar *endpoint, *entry, *index;
+ gchar *uref = NULL;
gint i;
gint processor_number = processor->id;
@@ -216,8 +217,17 @@ static void __cache_obtain_info(Processor *processor)
cache->ways_of_associativity = h_sysfs_read_int(endpoint, entry);
g_free(entry);
+ /* unique cache references: id is nice, but share_cpu_list can be
+ * used if it is not available. */
entry = g_strconcat(index, "id", NULL);
- cache->uid = h_sysfs_read_int(endpoint, entry);
+ uref = h_sysfs_read_string(endpoint, entry);
+ g_free(entry);
+ if (uref != NULL && *uref != 0 )
+ cache->uid = atoi(uref);
+ else
+ cache->uid = -1;
+ entry = g_strconcat(index, "shared_cpu_list", NULL);
+ cache->shared_cpu_list = h_sysfs_read_string(endpoint, entry);
g_free(entry);
/* reacharound */
@@ -254,7 +264,7 @@ static gint cmp_cpufreq_data_ignore_affected(cpufreq_data *a, cpufreq_data *b) {
gchar *clocks_summary(GSList * processors)
{
- gchar *ret = g_strdup("[Clocks]\n");
+ gchar *ret = g_strdup_printf("[%s]\n", _("Clocks"));
GSList *all_clocks = NULL, *uniq_clocks = NULL;
GSList *tmp, *l;
Processor *p;
@@ -332,8 +342,13 @@ static gint cmp_cache(ProcessorCache *a, ProcessorCache *b) {
cmp_cache_test(phy_sock);
i = g_strcmp0(a->type, b->type); if (i!=0) return i;
cmp_cache_test(level);
- cmp_cache_test(uid); /* uid is unique among caches with the same (type, level) */
cmp_cache_test(size);
+ cmp_cache_test(uid); /* uid is unique among caches with the same (type, level) */
+ if (a->uid == -1) {
+ /* if id wasn't available, use shared_cpu_list as a unique ref */
+ i = g_strcmp0(a->shared_cpu_list, b->shared_cpu_list); if (i!=0)
+ return i;
+ }
return 0;
}