anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

Blame SOURCES/0017-daxctl-emit-counts-of-total-and-online-memblocks.patch

e0018b
From e81f890c7ae1c940c7f52b8984e8728706489728 Mon Sep 17 00:00:00 2001
e0018b
From: Vishal Verma <vishal.l.verma@intel.com>
e0018b
Date: Wed, 31 Mar 2021 13:51:35 -0600
e0018b
Subject: [PATCH 017/217] daxctl: emit counts of total and online memblocks
e0018b
e0018b
Fir daxctl device listings, if in 'system-ram' mode, it is useful to
e0018b
know whether the memory associated with the device is online or not.
e0018b
Since the memory is comprised of a number of 'memblocks', and it is
e0018b
possible (albeit rare) to have a subset of them online, and the rest
e0018b
offline, we can't just use a boolean online-or-offline flag for the
e0018b
state.
e0018b
e0018b
Add a couple of counts, one for the total number of memblocks associated
e0018b
with the device, and another for the ones that are online.
e0018b
e0018b
Link: https://github.com/pmem/ndctl/issues/139
e0018b
Cc: Dan Williams <dan.j.williams@intel.com>
e0018b
Cc: Dave Hansen <dave.hansen@linux.intel.com>
e0018b
Reported-by: Steve Scargall <steve.scargall@intel.com>
e0018b
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
e0018b
---
e0018b
 util/json.c | 11 +++++++++++
e0018b
 1 file changed, 11 insertions(+)
e0018b
e0018b
diff --git a/util/json.c b/util/json.c
e0018b
index ca0167b..a8d2412 100644
e0018b
--- a/util/json.c
e0018b
+++ b/util/json.c
e0018b
@@ -482,6 +482,17 @@ struct json_object *util_daxctl_dev_to_json(struct daxctl_dev *dev,
e0018b
 		json_object_object_add(jdev, "mode", jobj);
e0018b
 
e0018b
 	if (mem && daxctl_dev_get_resource(dev) != 0) {
e0018b
+		int num_sections = daxctl_memory_num_sections(mem);
e0018b
+		int num_online = daxctl_memory_is_online(mem);
e0018b
+
e0018b
+		jobj = json_object_new_int(num_online);
e0018b
+		if (jobj)
e0018b
+			json_object_object_add(jdev, "online_memblocks", jobj);
e0018b
+
e0018b
+		jobj = json_object_new_int(num_sections);
e0018b
+		if (jobj)
e0018b
+			json_object_object_add(jdev, "total_memblocks", jobj);
e0018b
+
e0018b
 		movable = daxctl_memory_is_movable(mem);
e0018b
 		if (movable == 1)
e0018b
 			jobj = json_object_new_boolean(true);
e0018b
-- 
e0018b
2.27.0
e0018b