ACK
Are you going to patch sigar, too?
--
Russell Bryant
On Fri, Aug 12, 2011 at 11:30 AM, Zane Bitter <zbitter(a)redhat.com> wrote:
This patch reads the CPU Core count from sigar correctly.
Unfortunately it
does not completely resolve the issue, as sigar is counting each thread in
a HyperThreaded core as a separate core. A change to sigar will be required
to fix that.
Also modified the help for the schema to indicate that cpu_count is, in
fact, returning the logical CPU count (i.e. the number of threads), not the
number of physical CPU sockets.
Signed-off-by: Zane Bitter <zbitter(a)redhat.com>
---
src/host/schema.xml | 2 +-
src/lib/host.c | 19 ++++++++-----------
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/src/host/schema.xml b/src/host/schema.xml
index 932f3a1..0ddccc9 100644
--- a/src/host/schema.xml
+++ b/src/host/schema.xml
@@ -24,7 +24,7 @@
<property name="memory" type="uint64"
access="RO" desc="Amount of primary memory for host"
unit="kb" />
<property name="swap" type="uint64"
access="RO" desc="Amount of swap for host" unit="kb" />
- <property name="cpu_count" type="uint8"
access="RO" desc="The number of physical CPUs." />
+ <property name="cpu_count" type="uint8"
access="RO" desc="The number of logical CPUs." />
<property name="cpu_cores" type="uint8"
access="RO" desc="The total number of processor cores." />
<property name="cpu_model" type="lstr"
access="RO" desc="The processor(s) model description." />
<property name="cpu_flags" type="lstr"
access="RO" desc="The processor(s) CPU flags." />
diff --git a/src/lib/host.c b/src/lib/host.c
index a46f246..4ad28a1 100644
--- a/src/lib/host.c
+++ b/src/lib/host.c
@@ -227,26 +227,23 @@ mh_host_get_swap_free(void)
static void
host_get_cpu_details(void)
{
- int lpc = 0;
- sigar_cpu_info_list_t cpus;
+ sigar_cpu_info_list_t procs;
if (cpuinfo.cpus) {
return;
}
init();
- sigar_cpu_info_list_get(host_init.sigar, &cpus);
+ sigar_cpu_info_list_get(host_init.sigar, &procs);
- cpuinfo.cpus = cpus.number;
- for (lpc = 0; lpc < cpus.number; lpc++) {
- sigar_cpu_info_t *cpu = (sigar_cpu_info_t *) cpus.data;
- if (cpuinfo.model == NULL) {
- cpuinfo.model = g_strdup(cpu->model);
- }
- cpuinfo.cores += cpu->total_cores;
+ cpuinfo.cpus = procs.number;
+ if (procs.number) {
+ sigar_cpu_info_t *proc = (sigar_cpu_info_t *)procs.data;
+ cpuinfo.model = g_strdup(proc->model);
+ cpuinfo.cores = proc->total_cores;
}
- sigar_cpu_info_list_destroy(host_init.sigar, &cpus);
+ sigar_cpu_info_list_destroy(host_init.sigar, &procs);
}
int
_______________________________________________
Matahari mailing list
Matahari(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/matahari