transparent hugepages monitoring; #3462
Costa Tsaousis (ktsaou) committed
Feb 24, 2018 at 14:27 UTC
9b710aca181e75d4a7bada7c029cebf9963b23cc
3 files changed
+58
-6
src/proc_meminfo.c
+45
-5
@@ -4,7 +4,7 @@ int do_proc_meminfo(int update_every, usec_t dt) {
4
(void)dt;
5
6
static procfile *ff = NULL;
7
- static int do_ram = -1, do_swap = -1, do_hwcorrupt = -1, do_committed = -1, do_writeback = -1, do_kernel = -1, do_slab = -1, do_hugepages = -1;
7
+ static int do_ram = -1, do_swap = -1, do_hwcorrupt = -1, do_committed = -1, do_writeback = -1, do_kernel = -1, do_slab = -1, do_hugepages = -1, do_transparent_hugepages = -1;
8
9
static ARL_BASE *arl_base = NULL;
10
static ARL_ENTRY *arl_hwcorrupted = NULL, *arl_memavailable = NULL;
@@ -44,7 +44,8 @@ int do_proc_meminfo(int update_every, usec_t dt) {
44
//VmallocTotal = 0,
45
VmallocUsed = 0,
46
//VmallocChunk = 0,
47
- //AnonHugePages = 0,
47
+ AnonHugePages = 0,
48
+ ShmemHugePages = 0,
49
HugePages_Total = 0,
50
HugePages_Free = 0,
51
HugePages_Rsvd = 0,
@@ -63,6 +64,7 @@ int do_proc_meminfo(int update_every, usec_t dt) {
64
do_kernel = config_get_boolean("plugin:proc:/proc/meminfo", "kernel memory", 1);
65
do_slab = config_get_boolean("plugin:proc:/proc/meminfo", "slab memory", 1);
66
do_hugepages = config_get_boolean("plugin:proc:/proc/meminfo", "hugepages", CONFIG_BOOLEAN_AUTO);
67
+ do_transparent_hugepages = config_get_boolean("plugin:proc:/proc/meminfo", "transparent hugepages", CONFIG_BOOLEAN_AUTO);
68
69
arl_base = arl_create("meminfo", NULL, 60);
70
arl_expect(arl_base, "MemTotal", &MemTotal);
@@ -100,7 +102,8 @@ int do_proc_meminfo(int update_every, usec_t dt) {
102
arl_expect(arl_base, "VmallocUsed", &VmallocUsed);
103
//arl_expect(arl_base, "VmallocChunk", &VmallocChunk);
104
arl_hwcorrupted = arl_expect(arl_base, "HardwareCorrupted", &HardwareCorrupted);
103
- //arl_expect(arl_base, "AnonHugePages", &AnonHugePages);
105
+ arl_expect(arl_base, "AnonHugePages", &AnonHugePages);
106
+ arl_expect(arl_base, "ShmemHugePages", &ShmemHugePages);
107
arl_expect(arl_base, "HugePages_Total", &HugePages_Total);
108
arl_expect(arl_base, "HugePages_Free", &HugePages_Free);
109
arl_expect(arl_base, "HugePages_Rsvd", &HugePages_Rsvd);
@@ -443,11 +446,11 @@ int do_proc_meminfo(int update_every, usec_t dt) {
446
, NULL
447
, "hugepages"
448
, NULL
446
- , "HugePages Memory"
449
+ , "Dedicated HugePages Memory"
450
, "MB"
451
, "proc"
452
, "meminfo"
450
- , NETDATA_CHART_PRIO_MEM_HUGEPAGES
453
+ , NETDATA_CHART_PRIO_MEM_HUGEPAGES + 1
454
, update_every
455
, RRDSET_TYPE_STACKED
456
);
@@ -469,6 +472,43 @@ int do_proc_meminfo(int update_every, usec_t dt) {
472
rrdset_done(st_mem_hugepages);
473
}
474
475
+ // --------------------------------------------------------------------
476
+
477
+ if(do_transparent_hugepages == CONFIG_BOOLEAN_YES || (do_transparent_hugepages == CONFIG_BOOLEAN_AUTO && (AnonHugePages != 0 || ShmemHugePages != 0))) {
478
+ do_transparent_hugepages = CONFIG_BOOLEAN_YES;
479
+
480
+ static RRDSET *st_mem_transparent_hugepages = NULL;
481
+ static RRDDIM *rd_anonymous = NULL, *rd_shared = NULL;
482
+
483
+ if(unlikely(!st_mem_transparent_hugepages)) {
484
+ st_mem_transparent_hugepages = rrdset_create_localhost(
485
+ "mem"
486
+ , "transparent_hugepages"
487
+ , NULL
488
+ , "hugepages"
489
+ , NULL
490
+ , "Transparent HugePages Memory"
491
+ , "MB"
492
+ , "proc"
493
+ , "meminfo"
494
+ , NETDATA_CHART_PRIO_MEM_HUGEPAGES
495
+ , update_every
496
+ , RRDSET_TYPE_STACKED
497
+ );
498
+
499
+ rrdset_flag_set(st_mem_transparent_hugepages, RRDSET_FLAG_DETAIL);
500
+
501
+ rd_anonymous = rrddim_add(st_mem_transparent_hugepages, "anonymous", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE);
502
+ rd_shared = rrddim_add(st_mem_transparent_hugepages, "shmem", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE);
503
+ }
504
+ else rrdset_next(st_mem_transparent_hugepages);
505
+
506
+ rrddim_set_by_pointer(st_mem_transparent_hugepages, rd_anonymous, AnonHugePages);
507
+ rrddim_set_by_pointer(st_mem_transparent_hugepages, rd_shared, ShmemHugePages);
508
+
509
+ rrdset_done(st_mem_transparent_hugepages);
510
+ }
511
+
512
return 0;
513
}
514
web/dashboard_info.js
+12
@@ -418,6 +418,10 @@ netdataDashboard.submenu = {
418
info: 'Kernel Same-page Merging (KSM) performance monitoring, read from several files in <code>/sys/kernel/mm/ksm/</code>. KSM is a memory-saving de-duplication feature in the Linux kernel (since version 2.6.32). The KSM daemon ksmd periodically scans those areas of user memory which have been registered with it, looking for pages of identical content which can be replaced by a single write-protected page (which is automatically copied if a process later wants to update its content). KSM was originally developed for use with KVM (where it was known as Kernel Shared Memory), to fit more virtual machines into physical memory, by sharing the data common between them. But it can be useful to any application which generates many instances of the same data.'
419
},
420
421
+ 'mem.hugepages': {
422
+ info: 'Hugepages is a feature that allows the kernel to utilize the multiple page size capabilities of modern hardware architectures. The kernel creates multiple pages of virtual memory, mapped from both physical RAM and swap. There is a mechanism in the CPU architecture called "Translation Lookaside Buffers" (TLB) to manage the mapping of virtual memory pages to actual physical memory addresses. The TLB is a limited hardware resource, so utilizing a large amount of physical memory with the default page size consumes the TLB and adds processing overhead. By utilizing Huge Pages, the kernel is able to create pages of much larger sizes, each page consuming a single resource in the TLB. Huge Pages are pinned to physical RAM and cannot be swapped/paged out.'
423
+ },
424
+
425
'mem.numa': {
426
info: 'Non-Uniform Memory Access (NUMA) is a hierarchical memory design the memory access time is dependent on locality. Under NUMA, a processor can access its own local memory faster than non-local memory (memory local to another processor or memory shared between processors). The individual metrics are described in the <a href="https://www.kernel.org/doc/Documentation/numastat.txt" target="_blank">Linux kernel documentation</a>.'
427
},
@@ -702,6 +706,14 @@ netdataDashboard.context = {
706
info: '<b>Reclaimable</b> is the amount of memory which the kernel can reuse. <b>Unreclaimable</b> can not be reused even when the kernel is lacking memory.'
707
},
708
709
+ 'mem.hugepages': {
710
+ info: 'Dedicated (or Direct) HugePages is memory reserved for applications configured to utilize huge pages.'
711
+ },
712
+
713
+ 'mem.transparent_hugepages': {
714
+ info: 'Transparent HugePages (THP) is backing virtual memory with huge pages, supporting automatic promotion and demotion of page sizes. It works for all applications for anonymous memory mappings and tmpfs/shmem.'
715
+ },
716
+
717
// ------------------------------------------------------------------------
718
// network interfaces
719
web/index.html
+1
-1
@@ -4399,7 +4399,7 @@
4399
});
4400
4401
NETDATA.requiredJs.push({
4402
- url: NETDATA.serverStatic + 'dashboard_info.js?v20180120-1',
4402
+ url: NETDATA.serverStatic + 'dashboard_info.js?v20180224-2',
4403
async: false,
4404
isAlreadyLoaded: function() { return false; }
4405
});