From 51b607866f8ef14338841e426198b446fa4e60d5 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 11 Apr 2008 17:46:36 +0000 Subject: [PATCH] add cpu_info.cores_per_socket --- bindings/SigarWrapper.pm | 4 ++++ bindings/java/src/org/hyperic/sigar/cmd/CpuInfo.java | 1 + include/sigar.h | 1 + src/os/aix/aix_sigar.c | 3 ++- src/os/darwin/darwin_sigar.c | 1 + src/os/hpux/hpux_sigar.c | 3 ++- src/os/linux/linux_sigar.c | 4 +++- src/os/solaris/solaris_sigar.c | 1 + src/os/win32/win32_sigar.c | 3 ++- 9 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bindings/SigarWrapper.pm b/bindings/SigarWrapper.pm index 7790c704..aef1edc5 100644 --- a/bindings/SigarWrapper.pm +++ b/bindings/SigarWrapper.pm @@ -509,6 +509,10 @@ use vars qw(%classes %cmds); name => 'total_sockets', type => 'Int', desc => 'Total CPU sockets (physical)', }, + { + name => 'cores_per_socket', type => 'Int', + desc => 'Number of CPU cores per CPU socket', + }, ], Uptime => [ { diff --git a/bindings/java/src/org/hyperic/sigar/cmd/CpuInfo.java b/bindings/java/src/org/hyperic/sigar/cmd/CpuInfo.java index ddf8f397..901a006b 100644 --- a/bindings/java/src/org/hyperic/sigar/cmd/CpuInfo.java +++ b/bindings/java/src/org/hyperic/sigar/cmd/CpuInfo.java @@ -66,6 +66,7 @@ public class CpuInfo extends SigarCommandBase { println("Total CPUs....." + info.getTotalCores()); if (info.getTotalCores() != info.getTotalSockets()) { println("Physical CPUs.." + info.getTotalSockets()); + println("Cores per CPU.." + info.getCoresPerSocket()); } if (cacheSize != Sigar.FIELD_NOTIMPL) { diff --git a/include/sigar.h b/include/sigar.h index 0011daf4..79d0a20e 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -188,6 +188,7 @@ typedef struct { sigar_uint64_t cache_size; int total_sockets; int total_cores; + int cores_per_socket; } sigar_cpu_info_t; typedef struct { diff --git a/src/os/aix/aix_sigar.c b/src/os/aix/aix_sigar.c index 755fc1f6..39be11cc 100644 --- a/src/os/aix/aix_sigar.c +++ b/src/os/aix/aix_sigar.c @@ -1987,8 +1987,9 @@ int sigar_cpu_info_list_get(sigar_t *sigar, info = &cpu_infos->data[cpu_infos->number++]; - info->total_sockets = ncpu; info->total_cores = ncpu; + info->cores_per_socket = 1; /*XXX*/ + info->total_sockets = ncpu; /*XXX*/ info->cache_size = SIGAR_CPU_CACHE_SIZE; diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index defb2267..7c8ba9da 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -2132,6 +2132,7 @@ int sigar_cpu_info_list_get(sigar_t *sigar, info->mhz = mhz; info->cache_size = cache_size; info->total_cores = sigar->ncpu; + info->cores_per_socket = sigar->lcpu; info->total_sockets = sigar_cpu_socket_count(sigar); } diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index 1dffd1e4..0a149202 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -679,8 +679,9 @@ int sigar_cpu_info_list_get(sigar_t *sigar, info = &cpu_infos->data[cpu_infos->number++]; - info->total_sockets = sigar->ncpu; info->total_cores = sigar->ncpu; + info->cores_per_socket = 1; /*XXX*/ + info->total_sockets = sigar->ncpu; /*XXX*/ #ifdef __ia64__ SIGAR_SSTRCPY(info->vendor, "Intel"); /*XXX*/ diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index a3e75a5e..a3b353d6 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -1589,8 +1589,10 @@ int sigar_cpu_info_list_get(sigar_t *sigar, cpu_info = &cpu_infos->data[cpu_infos->number]; get_cpuinfo_max_freq(cpu_info, cpu_infos->number); + + cpu_info->total_cores = sigar->ncpu; + info->cores_per_socket = sigar->lcpu; cpu_info->total_sockets = sigar_cpu_socket_count(sigar); - cpu_info->total_cores = sigar->ncpu; ++cpu_infos->number; SIGAR_CPU_INFO_LIST_GROW(cpu_infos); diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index e51b214f..802a8ea6 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -1799,6 +1799,7 @@ int sigar_cpu_info_list_get(sigar_t *sigar, sigar_cpu_info_t *info = &cpu_infos->data[i]; info->total_sockets = nsockets; info->total_cores = sigar->ncpu; + info->cores_per_socket = sigar->ncpu / nsockets; } return SIGAR_OK; diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 151e51aa..f56a5b73 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -2005,8 +2005,9 @@ static int sigar_cpu_info_get(sigar_t *sigar, sigar_cpu_info_t *info) RegCloseKey(key); RegCloseKey(cpu); + info->total_cores = sigar->ncpu; + info->cores_per_socket = sigar->lcpu; info->total_sockets = sigar_cpu_socket_count(sigar); - info->total_cores = sigar->ncpu; return SIGAR_OK; }