From b2d1d95ef4b0812aca631d11c2b08946c73203c8 Mon Sep 17 00:00:00 2001 From: Peter Schiffer Date: Tue, 30 Apr 2013 15:09:33 +0200 Subject: Hardware: Added additional information to the Memory provider Added information: * detect NUMA layout * standard memory page size * all supported sizes of huge memory pages * current state of transparent huge pages --- src/hardware/LMI_MemoryProvider.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/hardware/LMI_MemoryProvider.c') diff --git a/src/hardware/LMI_MemoryProvider.c b/src/hardware/LMI_MemoryProvider.c index 0d77c17..4f2ab7f 100644 --- a/src/hardware/LMI_MemoryProvider.c +++ b/src/hardware/LMI_MemoryProvider.c @@ -19,11 +19,15 @@ */ #include +#include +#include +#include #include "LMI_Memory.h" #include "LMI_Hardware.h" #include "globals.h" #include "dmidecode.h" #include "procfs.h" +#include "sysfs.h" static const CMPIBroker* _cb = NULL; @@ -59,8 +63,10 @@ static CMPIStatus LMI_MemoryEnumInstances( LMI_Memory lmi_mem; const char *ns = KNameSpace(cop), *name = "System Memory"; char *error_msg = NULL; + long page_size; unsigned long fallback_memory_size = 0; DmiMemory dmi_memory; + unsigned i, *huge_page_sizes = NULL, huge_page_sizes_nb; if (dmi_get_memory(&dmi_memory) != 0) { fallback_memory_size = meminfo_get_memory_size(); @@ -70,6 +76,9 @@ static CMPIStatus LMI_MemoryEnumInstances( } } + page_size = sysconf(_SC_PAGESIZE); + sysfs_get_sizes_of_hugepages(&huge_page_sizes, &huge_page_sizes_nb); + LMI_Memory_Init(&lmi_mem, _cb, ns); LMI_Memory_Set_SystemCreationClassName(&lmi_mem, @@ -107,10 +116,26 @@ static CMPIStatus LMI_MemoryEnumInstances( LMI_Memory_Set_NumberOfBlocks(&lmi_mem, fallback_memory_size); } + LMI_Memory_Set_HasNUMA(&lmi_mem, sysfs_has_numa()); + if (page_size > 0) { + LMI_Memory_Set_StandardMemoryPageSize(&lmi_mem, page_size / 1024); + } + if (huge_page_sizes_nb > 0) { + LMI_Memory_Init_SupportedHugeMemoryPageSizes(&lmi_mem, + huge_page_sizes_nb); + for (i = 0; i < huge_page_sizes_nb; i++) { + LMI_Memory_Set_SupportedHugeMemoryPageSizes(&lmi_mem, i, + huge_page_sizes[i]); + } + } + LMI_Memory_Set_TransparentHugeMemoryPageStatus(&lmi_mem, + sysfs_get_transparent_hugepages_status()); + KReturnInstance(cr, lmi_mem); done: dmi_free_memory(&dmi_memory); + free(huge_page_sizes); if (error_msg) { KReturn2(_cb, ERR_FAILED, error_msg); -- cgit