From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B1FA38736F for ; Sat, 23 May 2026 09:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779529863; cv=none; b=bOVQHoZBkoa3zW7eZJNflHbCD04CHfrGVOFcdCs6Qk6+l+I2OANR4/f9013waVQ53Qzkk6pP62ptysJu9J+CIumf9oK00PZafHl9wlCX0uxsFBgheWq3P4Kk70C+tKsgwlo/vvsem9Zsvo9deFNsP2eOHxoAu8tSBGVATmXHFl4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779529863; c=relaxed/simple; bh=XAtL8ZNQB+UMV46RTZI81AvySwEc98mjFW4sJB0Qh1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JAWIZDLJXHGMM38s0XuqKygs7IFTXF7FGtHhp5yNWRyAFxs5sQO0/xYxMS7LOOiu7UPhF0Hqbwzwkoj7m7oI7WkMmFx77dyoSmZ8eqt67yvqUZT5nkDi0KWBsWfulW14qMWnIv7X2Nljc47iwO+rcAMoCK5N7bBq2jqfnC1Kl8E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gDMW9WMc; arc=none smtp.client-ip=74.125.82.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gDMW9WMc" Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-303dbfbec77so9303339eec.0 for ; Sat, 23 May 2026 02:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779529861; x=1780134661; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8vCXGNdEs9vHqblHAZzawp3kqEBF6AaU1uhZMV0FElU=; b=gDMW9WMcCwOxPpm2/EVzWIW8b0YDu80CrKbNl0u7O4a2TIrA0ZlfH/k9ldnOM/SGur jGJTyZ7PnaInSYVdlQ4ABOHmR/vPNxvP4oeQBH5Xv0n/D2EIMA80DnertO9tu1GOZoRl eAcixaozjxs0ELbHwAstWI2ywN6Sa5XrzJNCcHOhCAFpILTBbyJKBwZROe9AY3C/3OsP 9PNVC4nGi1wzPu8iNPaWNuI3n/ik2pvON8+Z4sRwjzsbaF0oxE6C3GzPVPyJ0ptB/Tq6 BI60ggRu9r1ykH3uBml+xOPrQxW2aEtADTvdRpiyb+mtqH1lMtEkk/ucHNBLiRQHk6sw 7QxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779529861; x=1780134661; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8vCXGNdEs9vHqblHAZzawp3kqEBF6AaU1uhZMV0FElU=; b=qPns3I+bSvDAnrB1O/T9HvLsjhJIPL5g6CU+dhQXFnj+A+f9oJoXddiiVSjw0H57S8 rLCo1mDUr1T3ak9BtADH5NvQyb/y3zchkJDq0xw3PuCNh555UtRQwluFZABttDCzWVT4 tcjNXS57BLiESnFa503anhgI30XMwgW8XnhJtCqrSCA8VQi5wIagvsAgBYxEMyAAYSWt aLtOlBv37wUe831xBnAovV0qvAac2DarKZtoyepFJHzI05nMezbXFbqf/cKxdBwE0hoc ucsxPI/r1ETJVqvKwuet82ixAT3C2tR9/5jl8nV92CnvmvY5CV4czjhvGg7Mgqick3JY 5p1A== X-Forwarded-Encrypted: i=1; AFNElJ9J/GMJTyQKtTr45EC9Nozzi5N7GiHORkbkyFAPlizkhoWc+H+CMDhU6bUMTyfW0qJRFJc9RQYe2REqIco=@vger.kernel.org X-Gm-Message-State: AOJu0YzH9w0FCtgvbdyJlj0KlNP+nu1L7mjDQDyws9vs5VIsZABOrMrR N3Dbfggh/SAT3a85nRuPkiha0TjJPfomhcdXSS7MzXGs5DVhYof1SynF X-Gm-Gg: Acq92OE13UjP+eql+I7ON/zCgn4p4LYsVMZUEe67rM0UoiG6nTKUYAFGI7q9Ls/MdUw m4SdgQZJo1GoMJewH7ovDszCNw5MX0nLbG0U06NUIHYfH1EF9QiHeFg9dTq3O/4sGe/eV/QhXuj SmIG70B9EmZPgp74E0p492GIVBk36Uls5YGFGGtdp73+RlfY6VxK5bpDOzTUjh9v5bqZ8uTWBnJ RaG7lsSYglfPwZg2bBpVo9O7xoj1n+Jx/ZTeYhhXiJRO7CWB00nIok53jgegraZtrsFxJdizCEp ksHR1/3ySeWQp4pZS/CLx4tmHvO36+q8HBa+dQmGdTUVfsYtInOk+V8p1WFpuPkVyYz7qczmCJo nvlN7qdU00OOLry3xnIgDCcVsFRODKhMtz6eKGJR7xCsdCD/FeJt0S8A0jR4gfClc0QskLVDwE5 S2L/LMX/GgYvGpHwPEdkDyfllluXH0HOn5Gj9cZo54vk2qyBS9hCaf9OlOoYBTu4KAi2wfoJ/ga UWvHnso4ALR8bL9MA== X-Received: by 2002:a05:7300:ef89:b0:2da:45f8:1b41 with SMTP id 5a478bee46e88-30449051989mr3513344eec.19.1779529861205; Sat, 23 May 2026 02:51:01 -0700 (PDT) Received: from AnisaLaptop.localdomain (c-73-170-217-179.hsd1.ca.comcast.net. [73.170.217.179]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3045225b7b6sm4595756eec.25.2026.05.23.02.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2026 02:51:00 -0700 (PDT) From: Anisa Su X-Google-Original-From: Anisa Su To: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org Cc: nvdimm@lists.linux.dev, Dan Williams , Jonathan Cameron , Davidlohr Bueso , Dave Jiang , Ira Weiny , Alison Schofield , John Groves , Gregory Price , Ira Weiny Subject: [PATCH v6 5/7] cxl/region: Add extent output to region query Date: Sat, 23 May 2026 02:50:40 -0700 Message-ID: <20260523095043.471098-6-anisa.su@samsung.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260523095043.471098-1-anisa.su@samsung.com> References: <20260523095043.471098-1-anisa.su@samsung.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ira Weiny DCD regions have 0 or more extents. The ability to list those and their properties is useful to end users. Add an option for extent output to region queries. An example of this is: $ ./build/cxl/cxl list -r 8 -Nu { "region":"region8", ... "type":"dc", ... "extents":[ { "offset":"0x10000000", "length":"64.00 MiB (67.11 MB)", "tag":"00000000-0000-0000-0000-000000000000" }, { "offset":"0x8000000", "length":"64.00 MiB (67.11 MB)", "tag":"00000000-0000-0000-0000-000000000000" } ] } Signed-off-by: Ira Weiny --- Changes: [iweiny: s/tag/uuid/] --- Documentation/cxl/cxl-list.txt | 29 +++++++++++++++++++++ cxl/filter.h | 3 +++ cxl/json.c | 47 ++++++++++++++++++++++++++++++++++ cxl/json.h | 3 +++ cxl/list.c | 3 +++ util/json.h | 1 + 6 files changed, 86 insertions(+) diff --git a/Documentation/cxl/cxl-list.txt b/Documentation/cxl/cxl-list.txt index 193860b..7512687 100644 --- a/Documentation/cxl/cxl-list.txt +++ b/Documentation/cxl/cxl-list.txt @@ -426,6 +426,35 @@ OPTIONS } ---- +-N:: +--extents:: + Append Dynamic Capacity extent information. +---- +13:34:28 > ./build/cxl/cxl list -r 8 -Nu +{ + "region":"region8", + "resource":"0xf030000000", + "size":"512.00 MiB (536.87 MB)", + "type":"dc", + "interleave_ways":1, + "interleave_granularity":256, + "decode_state":"commit", + "extents":[ + { + "offset":"0x10000000", + "length":"64.00 MiB (67.11 MB)", + "uuid":"00000000-0000-0000-0000-000000000000" + }, + { + "offset":"0x8000000", + "length":"64.00 MiB (67.11 MB)", + "uuid":"00000000-0000-0000-0000-000000000000" + } + ] +} +---- + + -r:: --region:: Specify CXL region device name(s), or device id(s), to filter the listing. diff --git a/cxl/filter.h b/cxl/filter.h index 70463c4..30e7fe2 100644 --- a/cxl/filter.h +++ b/cxl/filter.h @@ -31,6 +31,7 @@ struct cxl_filter_params { bool alert_config; bool dax; bool media_errors; + bool extents; int verbose; struct log_ctx ctx; }; @@ -93,6 +94,8 @@ static inline unsigned long cxl_filter_to_flags(struct cxl_filter_params *param) flags |= UTIL_JSON_DAX | UTIL_JSON_DAX_DEVS; if (param->media_errors) flags |= UTIL_JSON_MEDIA_ERRORS; + if (param->extents) + flags |= UTIL_JSON_EXTENTS; return flags; } diff --git a/cxl/json.c b/cxl/json.c index e94c809..7922b32 100644 --- a/cxl/json.c +++ b/cxl/json.c @@ -1022,6 +1022,50 @@ void util_cxl_mappings_append_json(struct json_object *jregion, json_object_object_add(jregion, "mappings", jmappings); } +void util_cxl_extents_append_json(struct json_object *jregion, + struct cxl_region *region, + unsigned long flags) +{ + struct json_object *jextents; + struct cxl_region_extent *extent; + + jextents = json_object_new_array(); + if (!jextents) + return; + + cxl_extent_foreach(region, extent) { + struct json_object *jextent, *jobj; + unsigned long long val; + char uuid_str[40]; + uuid_t uuid; + + jextent = json_object_new_object(); + if (!jextent) + continue; + + val = cxl_extent_get_offset(extent); + jobj = util_json_object_hex(val, flags); + if (jobj) + json_object_object_add(jextent, "offset", jobj); + + val = cxl_extent_get_length(extent); + jobj = util_json_object_size(val, flags); + if (jobj) + json_object_object_add(jextent, "length", jobj); + + cxl_extent_get_uuid(extent, uuid); + uuid_unparse(uuid, uuid_str); + jobj = json_object_new_string(uuid_str); + if (jobj) + json_object_object_add(jextent, "uuid", jobj); + + json_object_array_add(jextents, jextent); + json_object_set_userdata(jextent, extent, NULL); + } + + json_object_object_add(jregion, "extents", jextents); +} + struct json_object *util_cxl_region_to_json(struct cxl_region *region, unsigned long flags) { @@ -1126,6 +1170,9 @@ struct json_object *util_cxl_region_to_json(struct cxl_region *region, } } + if (flags & UTIL_JSON_EXTENTS) + util_cxl_extents_append_json(jregion, region, flags); + if (cxl_region_qos_class_mismatch(region)) { jobj = json_object_new_boolean(true); if (jobj) diff --git a/cxl/json.h b/cxl/json.h index eb7572b..f9c07ab 100644 --- a/cxl/json.h +++ b/cxl/json.h @@ -20,6 +20,9 @@ struct json_object *util_cxl_region_to_json(struct cxl_region *region, void util_cxl_mappings_append_json(struct json_object *jregion, struct cxl_region *region, unsigned long flags); +void util_cxl_extents_append_json(struct json_object *jregion, + struct cxl_region *region, + unsigned long flags); void util_cxl_targets_append_json(struct json_object *jdecoder, struct cxl_decoder *decoder, const char *ident, const char *serial, diff --git a/cxl/list.c b/cxl/list.c index 0b25d78..47d1351 100644 --- a/cxl/list.c +++ b/cxl/list.c @@ -59,6 +59,8 @@ static const struct option options[] = { "include alert configuration information"), OPT_BOOLEAN('L', "media-errors", ¶m.media_errors, "include media-error information "), + OPT_BOOLEAN('N', "extents", ¶m.extents, + "include extent information (Dynamic Capacity regions only)"), OPT_INCR('v', "verbose", ¶m.verbose, "increase output detail"), #ifdef ENABLE_DEBUG OPT_BOOLEAN(0, "debug", &debug, "debug list walk"), @@ -135,6 +137,7 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) param.decoders = true; param.targets = true; param.regions = true; + param.extents = true; /*fallthrough*/ case 0: break; diff --git a/util/json.h b/util/json.h index 560f845..79ae324 100644 --- a/util/json.h +++ b/util/json.h @@ -21,6 +21,7 @@ enum util_json_flags { UTIL_JSON_TARGETS = (1 << 11), UTIL_JSON_PARTITION = (1 << 12), UTIL_JSON_ALERT_CONFIG = (1 << 13), + UTIL_JSON_EXTENTS = (1 << 14), }; void util_display_json_array(FILE *f_out, struct json_object *jarray, -- 2.43.0