diff options
author | Ondrej Čerman | 2020-01-09 20:21:50 +0100 |
---|---|---|
committer | Ondrej Čerman | 2020-01-09 20:21:50 +0100 |
commit | 5408b21e7a1a22b79e81a712e2e19d386f3c4d94 (patch) | |
tree | 50ca0ee7cfe272178196294281c961e3605ffb40 /src/ss | |
parent | fd9b1aacc43635f8e47966b28d705cd642081c18 (diff) |
get_cpu_dev_ids FIX #13
Diffstat (limited to 'src/ss')
-rw-r--r-- | src/ss/msr.c | 7 | ||||
-rw-r--r-- | src/ss/os.c | 15 |
2 files changed, 10 insertions, 12 deletions
diff --git a/src/ss/msr.c b/src/ss/msr.c index 2ef75ac..17c9530 100644 --- a/src/ss/msr.c +++ b/src/ss/msr.c @@ -18,6 +18,7 @@ static guint cores = 0; static gdouble energy_unit = 0; +static struct cpudev *cpu_dev_ids; static gint *msr_files = NULL; @@ -75,7 +76,6 @@ gulong get_core_energy(gint core) { } gboolean msr_init() { - gshort *cpu_dev_ids = NULL; guint i; if (!check_zen()) @@ -88,9 +88,8 @@ gboolean msr_init() { cpu_dev_ids = get_cpu_dev_ids(); msr_files = malloc(cores * sizeof (gint)); for (i = 0; i < cores; i++) { - msr_files[i] = open_msr(cpu_dev_ids[i]); + msr_files[i] = open_msr(cpu_dev_ids[i].cpuid); } - g_free(cpu_dev_ids); energy_unit = get_energy_unit(); if (energy_unit == 0) @@ -167,7 +166,7 @@ GSList* msr_get_sensors() { for (i = 0; i < cores; i++) { data = sensor_init_new(); - data->label = g_strdup_printf("Core %d Power", i); + data->label = g_strdup_printf("Core %d Power", cpu_dev_ids[i].coreid); data->value = &(core_power[i]); data->min = &(core_power_min[i]); data->max = &(core_power_max[i]); diff --git a/src/ss/os.c b/src/ss/os.c index 9b25a04..637c4ec 100644 --- a/src/ss/os.c +++ b/src/ss/os.c @@ -9,6 +9,7 @@ static gchar **frq_files = NULL; static guint cores; +static struct cpudev *cpu_dev_ids; gfloat *core_freq; gfloat *core_freq_min; @@ -22,8 +23,7 @@ static gdouble get_frequency(guint coreid) { return atoi(data) / 1000000.0; } -gboolean os_init() { - gshort *cpu_dev_ids = NULL; +gboolean os_init(void) { guint i; if (!check_zen()) @@ -38,9 +38,8 @@ gboolean os_init() { for (i = 0; i < cores; i++) { frq_files[i] = g_strdup_printf( "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", - cpu_dev_ids[i]); + cpu_dev_ids[i].cpuid); } - g_free(cpu_dev_ids); core_freq = malloc(cores * sizeof (gfloat)); core_freq_min = malloc(cores * sizeof (gfloat)); @@ -53,7 +52,7 @@ gboolean os_init() { return TRUE; } -void os_update() { +void os_update(void) { guint i; for (i = 0; i < cores; i++) { @@ -65,7 +64,7 @@ void os_update() { } } -void os_clear_minmax() { +void os_clear_minmax(void) { guint i; for (i = 0; i < cores; i++) { @@ -74,14 +73,14 @@ void os_clear_minmax() { } } -GSList* os_get_sensors() { +GSList* os_get_sensors(void) { GSList *list = NULL; SensorInit *data; guint i; for (i = 0; i < cores; i++) { data = sensor_init_new(); - data->label = g_strdup_printf("Core %d Frequency", i); + data->label = g_strdup_printf("Core %d Frequency", cpu_dev_ids[i].coreid); data->value = &(core_freq[i]); data->min = &(core_freq_min[i]); data->max = &(core_freq_max[i]); |