summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Hassler <hadfl@omnios.org>2020-12-24 13:01:23 +0000
committerDominik Hassler <hadfl@omnios.org>2020-12-25 09:26:50 +0000
commit495f2292dcc958974984521c998fd1672bfc3d33 (patch)
treef9db48169b7266060628ab4e9b9301fd4bc342ec
parent1cc3f8074f710dbd30e82cdb3e558106535e51d1 (diff)
add support to display CPU frequencies on Solarish platforms
-rw-r--r--solaris/Platform.c2
-rw-r--r--solaris/SolarisProcessList.c38
-rw-r--r--solaris/SolarisProcessList.h1
3 files changed, 27 insertions, 14 deletions
diff --git a/solaris/Platform.c b/solaris/Platform.c
index 09747cd4..968e0133 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -205,7 +205,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
percent = isnan(percent) ? 0.0 : CLAMP(percent, 0.0, 100.0);
- v[CPU_METER_FREQUENCY] = NAN;
+ v[CPU_METER_FREQUENCY] = cpuData->frequency;
v[CPU_METER_TEMPERATURE] = NAN;
return percent;
diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c
index 793b1b3b..41554b99 100644
--- a/solaris/SolarisProcessList.c
+++ b/solaris/SolarisProcessList.c
@@ -72,11 +72,11 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) {
const SolarisProcessList* spl = (SolarisProcessList*) pl;
int cpus = pl->cpuCount;
kstat_t* cpuinfo = NULL;
- int kchain = 0;
kstat_named_t* idletime = NULL;
kstat_named_t* intrtime = NULL;
kstat_named_t* krnltime = NULL;
kstat_named_t* usertime = NULL;
+ kstat_named_t* cpu_freq = NULL;
double idlebuf = 0;
double intrbuf = 0;
double krnlbuf = 0;
@@ -94,21 +94,31 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) {
// Calculate per-CPU statistics first
for (int i = 0; i < cpus; i++) {
if (spl->kd != NULL) {
- cpuinfo = kstat_lookup(spl->kd, "cpu", i, "sys");
- }
- if (cpuinfo != NULL) {
- kchain = kstat_read(spl->kd, cpuinfo, NULL);
- }
- if (kchain != -1 ) {
- idletime = kstat_data_lookup(cpuinfo, "cpu_nsec_idle");
- intrtime = kstat_data_lookup(cpuinfo, "cpu_nsec_intr");
- krnltime = kstat_data_lookup(cpuinfo, "cpu_nsec_kernel");
- usertime = kstat_data_lookup(cpuinfo, "cpu_nsec_user");
+ if ((cpuinfo = kstat_lookup(spl->kd, "cpu", i, "sys")) != NULL) {
+ if (kstat_read(spl->kd, cpuinfo, NULL) != -1) {
+ idletime = kstat_data_lookup(cpuinfo, "cpu_nsec_idle");
+ intrtime = kstat_data_lookup(cpuinfo, "cpu_nsec_intr");
+ krnltime = kstat_data_lookup(cpuinfo, "cpu_nsec_kernel");
+ usertime = kstat_data_lookup(cpuinfo, "cpu_nsec_user");
+ }
+ }
}
assert( (idletime != NULL) && (intrtime != NULL)
&& (krnltime != NULL) && (usertime != NULL) );
+ if (pl->settings->showCPUFrequency) {
+ if (spl->kd != NULL) {
+ if ((cpuinfo = kstat_lookup(spl->kd, "cpu_info", i, NULL)) != NULL) {
+ if (kstat_read(spl->kd, cpuinfo, NULL) != -1) {
+ cpu_freq = kstat_data_lookup(cpuinfo, "current_clock_Hz");
+ }
+ }
+ }
+
+ assert( cpu_freq != NULL );
+ }
+
CPUData* cpuData = &(spl->cpus[i + arrskip]);
uint64_t totaltime = (idletime->value.ui64 - cpuData->lidle)
@@ -128,6 +138,8 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) {
cpuData->lkrnl = krnltime->value.ui64;
cpuData->lintr = intrtime->value.ui64;
cpuData->lidle = idletime->value.ui64;
+ // Add frequency in MHz
+ cpuData->frequency = pl->settings->showCPUFrequency ? (double)cpu_freq->value.ui64 / 1E6 : NAN;
// Accumulate the current percentages into buffers for later average calculation
if (cpus > 1) {
userbuf += cpuData->userPercent;
@@ -165,8 +177,8 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
// Part 1 - physical memory
if (spl->kd != NULL && meminfo == NULL) {
- // Look up the kstat chain just one, it never changes
- meminfo = kstat_lookup(spl->kd, "unix", 0, "system_pages");
+ // Look up the kstat chain just once, it never changes
+ meminfo = kstat_lookup(spl->kd, "unix", 0, "system_pages");
}
if (meminfo != NULL) {
ksrphyserr = kstat_read(spl->kd, meminfo, NULL);
diff --git a/solaris/SolarisProcessList.h b/solaris/SolarisProcessList.h
index f800d9da..78362b65 100644
--- a/solaris/SolarisProcessList.h
+++ b/solaris/SolarisProcessList.h
@@ -33,6 +33,7 @@ typedef struct CPUData_ {
double irqPercent;
double idlePercent;
double systemAllPercent;
+ double frequency;
uint64_t luser;
uint64_t lkrnl;
uint64_t lintr;

© 2014-2024 Faster IT GmbH | imprint | privacy policy