diff options
author | Nathan Scott <nathans@redhat.com> | 2021-08-09 19:24:29 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2021-08-09 19:24:29 +1000 |
commit | c31fd3c691019e438a2bfdbf1abe9bb895aefc83 (patch) | |
tree | 3f5ebe7ebd94790237b56e2b6a0dfc84a2697666 /pcp | |
parent | 324f9d048d2866dbdd74451ee988ec608d6677a8 (diff) | |
parent | ee831263c343bef80658aa806974be9ddfadbd57 (diff) |
Merge branch 'pcp-dynamic-cpu'
Diffstat (limited to 'pcp')
-rw-r--r-- | pcp/PCPProcessList.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/pcp/PCPProcessList.c b/pcp/PCPProcessList.c index b0fe7666..638ece21 100644 --- a/pcp/PCPProcessList.c +++ b/pcp/PCPProcessList.c @@ -23,22 +23,17 @@ in the source distribution for its full text. #include "pcp/PCPProcess.h" -static int PCPProcessList_computeCPUcount(void) { - int cpus; - if ((cpus = Platform_getMaxCPU()) <= 0) - cpus = Metric_instanceCount(PCP_PERCPU_SYSTEM); - return cpus > 1 ? cpus : 1; -} - static void PCPProcessList_updateCPUcount(PCPProcessList* this) { ProcessList* pl = &(this->super); - unsigned int cpus = PCPProcessList_computeCPUcount(); + pl->activeCPUs = Metric_instanceCount(PCP_PERCPU_SYSTEM); + unsigned int cpus = Platform_getMaxCPU(); if (cpus == pl->existingCPUs) return; - + if (cpus <= 0) + cpus = pl->activeCPUs; + if (cpus <= 1) + cpus = pl->activeCPUs = 1; pl->existingCPUs = cpus; - // TODO: support offline CPUs and hot swapping - pl->activeCPUs = pl->existingCPUs; free(this->percpu); free(this->values); @@ -695,9 +690,10 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) { assert(id < super->existingCPUs); + (void) super; - // TODO: support offline CPUs and hot swapping - (void) super; (void) id; - - return true; + pmAtomValue value; + if (Metric_instance(PCP_PERCPU_SYSTEM, id, id, &value, PM_TYPE_U32)) + return true; + return false; } |