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

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