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

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