CPU: Only use active CPU count for generic CPU progress.
Some systems disable CPU cores. In the CPU tab this is fine, but for an accurate representation of CPU load we need to check for the number of active CPUs. E.g. OpenBSD disables HT on amd64 thus a 2-core system will only use 1 core.
This commit is contained in:
parent
a5355e5357
commit
f472733f06
20
src/system.c
20
src/system.c
|
@ -206,6 +206,26 @@ cpu_count(void)
|
|||
return cores;
|
||||
}
|
||||
|
||||
int
|
||||
system_cpu_online_count_get(void)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
return cpu_count();
|
||||
#endif
|
||||
static int cores = 0;
|
||||
|
||||
if (cores != 0) return cores;
|
||||
|
||||
size_t len;
|
||||
int mib[2] = { CTL_HW, HW_NCPUONLINE };
|
||||
|
||||
len = sizeof(cores);
|
||||
if (sysctl(mib, 2, &cores, &len, NULL, 0) < 0)
|
||||
return cpu_count();
|
||||
|
||||
return cores;
|
||||
}
|
||||
|
||||
static void
|
||||
_cpu_state_get(cpu_core_t **cores, int ncpu)
|
||||
{
|
||||
|
|
|
@ -74,4 +74,7 @@ int
|
|||
void
|
||||
system_power_state_get(power_t *power);
|
||||
|
||||
int
|
||||
system_cpu_online_count_get();
|
||||
|
||||
#endif
|
||||
|
|
2
src/ui.c
2
src/ui.c
|
@ -434,7 +434,7 @@ _system_stats_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
|
|||
free(results->cores[i]);
|
||||
}
|
||||
|
||||
cpu_usage = cpu_usage / results->cpu_count;
|
||||
cpu_usage = cpu_usage / system_cpu_online_count_get();
|
||||
|
||||
_progressbar_value_force_set(ui->progress_cpu, (double)cpu_usage / 100);
|
||||
|
||||
|
|
Loading…
Reference in New Issue