[Devel] [PATCH RH8] drivers/base: Adjust the total amount of RAM shown for a NUMA node

Evgenii Shatokhin eshatokhin at virtuozzo.com
Tue Jul 27 12:39:46 MSK 2021


... if it is incorrect.

(A temporary hack, to be dropped after the rebase on top of RHEL 8.4.)

vcmmd expects the total amount of RAM for a NUMA node shown in
cat /sys/devices/system/node/node*/meminfo to be no less than
amount_of_free_RAM + amount_of_reclaimable_memory.

The hack from 28c689b8581f ("mm/page_alloc: Adjust the number of
managed pages for a zone if it is wrong") did not take reclaimable
memory into account. This is another hack to fix it up.

The patch was prepared in the scope of
https://jira.sw.ru/browse/PSBM-129304.

The problem seems to be fixed in the kernel from RHEL 8.4, so the patch
should be dropped after rebase on top of that kernel.

Signed-off-by: Evgenii Shatokhin <eshatokhin at virtuozzo.com>
---
 drivers/base/node.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index d75862546c4e..0c69b32d300e 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -365,10 +365,21 @@ static ssize_t node_read_meminfo(struct device *dev,
 	struct pglist_data *pgdat = NODE_DATA(nid);
 	struct sysinfo i;
 	unsigned long sreclaimable, sunreclaimable;
+	unsigned long totalram;
+	unsigned long kreclaimable;
+	unsigned long usableram;
 
 	si_meminfo_node(&i, nid);
 	sreclaimable = node_page_state(pgdat, NR_SLAB_RECLAIMABLE);
 	sunreclaimable = node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE);
+	totalram = i.totalram;
+	kreclaimable = sreclaimable + node_page_state(pgdat,
+						      NR_KERNEL_MISC_RECLAIMABLE);
+	/* HACK, PSBM-129304 */
+	usableram = i.freeram + kreclaimable;
+	if (totalram < usableram)
+		totalram = usableram;
+
 	n = sprintf(buf,
 		       "Node %d MemTotal:       %8lu kB\n"
 		       "Node %d MemFree:        %8lu kB\n"
@@ -381,7 +392,7 @@ static ssize_t node_read_meminfo(struct device *dev,
 		       "Node %d Inactive(file): %8lu kB\n"
 		       "Node %d Unevictable:    %8lu kB\n"
 		       "Node %d Mlocked:        %8lu kB\n",
-		       nid, K(i.totalram),
+		       nid, K(totalram),
 		       nid, K(i.freeram),
 		       nid, K(i.totalram - i.freeram),
 		       nid, K(node_page_state(pgdat, NR_ACTIVE_ANON) +
@@ -439,8 +450,7 @@ static ssize_t node_read_meminfo(struct device *dev,
 		       nid, K(node_page_state(pgdat, NR_UNSTABLE_NFS)),
 		       nid, K(sum_zone_node_page_state(nid, NR_BOUNCE)),
 		       nid, K(node_page_state(pgdat, NR_WRITEBACK_TEMP)),
-		       nid, K(sreclaimable +
-			      node_page_state(pgdat, NR_KERNEL_MISC_RECLAIMABLE)),
+		       nid, K(kreclaimable),
 		       nid, K(sreclaimable + sunreclaimable),
 		       nid, K(sreclaimable),
 		       nid, K(sunreclaimable)
-- 
2.29.0



More information about the Devel mailing list