summaryrefslogtreecommitdiffstats
path: root/src/hardware/LMI_MemoryProvider.c
diff options
context:
space:
mode:
authorPeter Schiffer <pschiffe@redhat.com>2013-04-30 15:09:33 +0200
committerPeter Schiffer <pschiffe@redhat.com>2013-04-30 16:58:58 +0200
commitb2d1d95ef4b0812aca631d11c2b08946c73203c8 (patch)
treed4943199a06715e1c8119c77ec71b265968eaf58 /src/hardware/LMI_MemoryProvider.c
parent9d055e9cec6a305d553fd88e74345d75f10fab1e (diff)
downloadopenlmi-providers-b2d1d95ef4b0812aca631d11c2b08946c73203c8.tar.gz
openlmi-providers-b2d1d95ef4b0812aca631d11c2b08946c73203c8.tar.xz
openlmi-providers-b2d1d95ef4b0812aca631d11c2b08946c73203c8.zip
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
Diffstat (limited to 'src/hardware/LMI_MemoryProvider.c')
-rw-r--r--src/hardware/LMI_MemoryProvider.c25
1 files changed, 25 insertions, 0 deletions
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 <konkret/konkret.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <limits.h>
#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);