ndctl: Dynamic Capacity additions for cxl-cli
Subsystems (2)
v3 cover ndctl: Dynamic Capacity additions for cxl-cli
Feedback from v2 lead to the realization that cxl-cli required changes to address the region mode vs decoder mode difference properly.
While v2 separated these modes they were not sufficiently separated in the user interface of create-region. This has been corrected in this version. Specifically a new option has been added to cxl create-region. The option requires a decoder mode (DC partition) when the region type is 'dc'. The option is ignored, and can be omitted, for ram and pmem regions.
Other libcxl API changes were made to simplify the interface a bit.
Documentation was added both at the libcxl and cxl-cli levels.
cxl-dcd.sh was cleaned up quite a bit an enhanced.
https://github.com/weiny2/ndctl/tree/dcd-region2-2024-11-15
CXL Dynamic Capacity Device (DCD) support is close to landing in the upstream kernel. cxl-cli requires modifications to interact with those devices. This includes creating and operating on DCD regions. cxl-testing allows for quick regression testing as well as helping to design the cxl-cli interfaces.
Add preliminary patches with some fixes. Update libcxl, cxl-cli and cxl-test with DCD support.
---
Major changes in v3:
- [djiang: rework test script for clarity]
- [Alison: split patches between libcxl changes and cli changes]
- [Alison: fix lib symbol versioning]
- [iweiny: clarify region vs decoder mode with API to specify the
decoder mode]
- Link to v2: https://patch.msgid.link/[email protected]
---
Ira Weiny (7):
ndctl/cxl-events: Don't fail test until event counts are reported ndctl/cxl/region: Report max size for region creation
libcxl: Separate region mode from decoder mode cxl/region: Use new region mode in cxl-cli
libcxl: Add extent functionality to DC regions cxl/region: Add extent output to region query cxl/test: Add Dynamic Capacity tests
Navneet Singh (2):
libcxl: Add Dynamic Capacity region support cxl/region: Add cxl-cli support for DCD regions
Documentation/cxl/cxl-create-region.txt | 11 +- Documentation/cxl/cxl-list.txt | 29 ++ Documentation/cxl/lib/libcxl.txt | 62 ++- cxl/filter.h | 3 + cxl/json.c | 80 ++- cxl/json.h | 3 + cxl/lib/libcxl.c | 261 +++++++++- cxl/lib/libcxl.sym | 13 + cxl/lib/private.h | 17 +- cxl/libcxl.h | 96 +++- cxl/list.c | 3 + cxl/memdev.c | 4 +- cxl/region.c | 93 +++- test/cxl-dcd.sh | 879 ++++++++++++++++++++++++++++++++ test/cxl-events.sh | 8 +- test/meson.build | 2 + util/json.h | 1 + 17 files changed, 1519 insertions(+), 46 deletions(-)
---
base-commit: 04815e5f8b87e02a4fb5a61aeebaa5cad25a15c3
change-id: 20241030-dcd-region2-2d0149eb8efd
Best regards,
Signature · 1 line
Ira Weiny <[email protected]>
PATCH v3 2/9 ndctl/cxl/region: Report max size for region creation
When creating a region if the size exceeds the max an error is printed. However, the max available space is not reported which makes it harder to determine what is wrong.
Add the max size available to the output error.
--- cxl/region.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
cxl/region.c +2 -2
@@ -677,8 +677,8 @@ static int create_region(struct cxl_ctx *ctx, int *count, }if (!default_size && size > max_extent) {log_err (&rl, -"%s: region size %#lx exceeds max available space\n" , -cxl_decoder_get_devname (p->root_decoder), size); +"%s: region size %#lx exceeds max available space (%#lx)\n" , +cxl_decoder_get_devname (p->root_decoder), size, max_extent);return -ENOSPC ; }
Signature · 1 line
2.47.0
PATCH v3 1/9 ndctl/cxl-events: Don't fail test until event counts are reported
In reply to Ira WeinyIn testing DCD event modifications a failed cxl-event test lacked details on the event counts. This was because the greps were failing the test rather than the check against the counts.
Suppress the grep failure and rely on event count checks for pass/fail of the test.
--- test/cxl-events.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
test/cxl-events.sh +4 -4
@@ -71,10 +71,10 @@ echo 0 > /sys/kernel/tracing/tracing_on echo "TEST: Events seen" trace_out=$(cat /sys/kernel/tracing/trace) -num_overflow=$(grep -c "cxl_overflow" <<< "${trace_out}") -num_fatal=$(grep -c "log=Fatal" <<< "${trace_out}") -num_failure=$(grep -c "log=Failure" <<< "${trace_out}") -num_info=$(grep -c "log=Informational" <<< "${trace_out}") +num_overflow=$(grep -c "cxl_overflow" <<< "${trace_out}" || true) +num_fatal=$(grep -c "log=Fatal" <<< "${trace_out}" || true) +num_failure=$(grep -c "log=Failure" <<< "${trace_out}" || true) +num_info=$(grep -c "log=Informational" <<< "${trace_out}" || true) echo " LOG (Expected) : (Found)" echo " overflow ($num_overflow_expected) : $num_overflow" echo " Fatal ($num_fatal_expected) : $num_fatal"
Signature · 1 line
2.47.0
PATCH v3 3/9 libcxl: Separate region mode from decoder mode
In reply to Ira WeinyWith the introduction of DCD, region mode and decoder mode no longer remain a 1:1 relation. An interleaved region may be made up of Dynamic Capacity partitions with different indexes on each of the target devices.
Introduce a new region mode enumeration and access function to libcxl.
To maintain compatibility with existing software the region mode values are defined the same as the current decoder mode. In addition cxl_region_get_mode() is retained.
---
Changes:
[Alison/iweiny: Ensure correct libcxl symbol export version] [Alison/iweiny: Add new libcxl interfaces to documentation] [iweiny: Add deprecated cxl_region_get_mode() documentation]
--- Documentation/cxl/lib/libcxl.txt | 20 ++++++++++++++++++-- cxl/lib/libcxl.c | 25 +++++++++++++++---------- cxl/lib/libcxl.sym | 5 +++++ cxl/lib/private.h | 2 +- cxl/libcxl.h | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 13 deletions(-)
Documentation/cxl/lib/libcxl.txt +18 -2
@@ -553,11 +553,20 @@ struct cxl_region *cxl_region_get_next(struct cxl_region *region); ===== REGION: Attributes ---- +enum cxl_region_mode { + CXL_REGION_MODE_NONE = CXL_DECODER_MODE_NONE, + CXL_REGION_MODE_MIXED = CXL_DECODER_MODE_MIXED, + CXL_REGION_MODE_PMEM = CXL_DECODER_MODE_PMEM, + CXL_REGION_MODE_RAM = CXL_DECODER_MODE_RAM, +}; +const char *cxl_region_mode_name(enum cxl_region_mode mode); +enum cxl_region_mode cxl_region_mode_from_ident(const char *ident); +enum cxl_region_mode cxl_region_get_region_mode(struct cxl_region *region); + int cxl_region_get_id(struct cxl_region *region); const char *cxl_region_get_devname(struct cxl_region *region); void cxl_region_get_uuid(struct cxl_region *region, uuid_t uu); unsigned long long cxl_region_get_size(struct cxl_region *region); -enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region); unsigned long long cxl_region_get_resource(struct cxl_region *region); unsigned int cxl_region_get_interleave_ways(struct cxl_region *region); unsigned int cxl_region_get_interleave_granularity(struct cxl_region *region);
@@ -576,8 +585,12 @@ int cxl_region_clear_all_targets(struct cxl_region *region); int cxl_region_decode_commit(struct cxl_region *region); int cxl_region_decode_reset(struct cxl_region *region); struct daxctl_region *cxl_region_get_daxctl_region(struct cxl_region *region); ----- +DEPRECATED: + +enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region); + +---- A region's resource attribute is the Host Physical Address at which the region's address space starts. The region's address space is a subset of the parent root decoder's address space.
@@ -601,6 +614,9 @@ where its properties can be interrogated by daxctl. The helper cxl_region_get_daxctl_region() returns an 'struct daxctl_region *' that can be used with other libdaxctl APIs. +Regions now have a mode distinct from decoders. cxl_region_get_mode() is +deprecated in favor of cxl_region_get_region_mode(). + include::../../copyright.txt[] SEE ALSO
cxl/lib/libcxl.c +15 -10
@@ -431,10 +431,10 @@ CXL_EXPORT bool cxl_region_qos_class_mismatch(struct cxl_region *region)if (!memdev)continue ; -if (region->mode ==CXL_DECODER_MODE_RAM ) { +if (region->mode ==CXL_REGION_MODE_RAM ) {if (root_decoder->qos_class != memdev->ram_qos_class)return true; - }else if (region->mode ==CXL_DECODER_MODE_PMEM ) { + }else if (region->mode ==CXL_REGION_MODE_PMEM ) {if (root_decoder->qos_class != memdev->pmem_qos_class)return true; }
@@ -619,9 +619,9 @@ static void *add_cxl_region(void *parent, int id, const char *cxlregion_base)sprintf (path,"%s/mode" , cxlregion_base);if (sysfs_read_attr (ctx, path, buf) <0 ) - region->mode =CXL_DECODER_MODE_NONE ; + region->mode =CXL_REGION_MODE_NONE ;else - region->mode =cxl_decoder_mode_from_ident (buf); + region->mode =cxl_region_mode_from_ident (buf);sprintf (path,"%s/modalias" , cxlregion_base);if (sysfs_read_attr (ctx, path, buf) ==0 )
@@ -748,11 +748,16 @@ CXL_EXPORT unsigned long long cxl_region_get_resource(struct cxl_region *region)return region->start; } -CXL_EXPORT enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region) +CXL_EXPORT enum cxl_region_mode cxl_region_get_region_mode(struct cxl_region *region) {return region->mode; } +CXL_EXPORT enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region) +{ +return (enum cxl_decoder_mode )cxl_region_get_region_mode (region); +} + CXL_EXPORT unsigned intcxl_region_get_interleave_ways (struct cxl_region *region) {
@@ -2700,7 +2705,7 @@ cxl_decoder_get_region(struct cxl_decoder *decoder) }static struct cxl_region *cxl_decoder_create_region (struct cxl_decoder *decoder, -enum cxl_decoder_mode mode) +enum cxl_region_mode mode) {struct cxl_ctx *ctx =cxl_decoder_get_ctx (decoder);char *path = decoder->dev_buf;
@@ -2708,9 +2713,9 @@ static struct cxl_region *cxl_decoder_create_region(struct cxl_decoder *decoder,struct cxl_region *region;int rc; -if (mode ==CXL_DECODER_MODE_PMEM ) +if (mode ==CXL_REGION_MODE_PMEM )sprintf (path,"%s/create_pmem_region" , decoder->dev_path); -else if (mode ==CXL_DECODER_MODE_RAM ) +else if (mode ==CXL_REGION_MODE_RAM )sprintf (path,"%s/create_ram_region" , decoder->dev_path); rc =sysfs_read_attr (ctx, path, buf);
@@ -2754,13 +2759,13 @@ static struct cxl_region *cxl_decoder_create_region(struct cxl_decoder *decoder, CXL_EXPORT struct cxl_region *cxl_decoder_create_pmem_region (struct cxl_decoder *decoder) { -return cxl_decoder_create_region (decoder,CXL_DECODER_MODE_PMEM ); +return cxl_decoder_create_region (decoder,CXL_REGION_MODE_PMEM ); } CXL_EXPORT struct cxl_region *cxl_decoder_create_ram_region (struct cxl_decoder *decoder) { -return cxl_decoder_create_region (decoder,CXL_DECODER_MODE_RAM ); +return cxl_decoder_create_region (decoder,CXL_REGION_MODE_RAM ); } CXL_EXPORT int cxl_decoder_get_nr_targets(struct cxl_decoder *decoder)
cxl/lib/libcxl.sym +5 -0
@@ -288,3 +288,8 @@ global: cxl_memdev_trigger_poison_list; cxl_region_trigger_poison_list; } LIBCXL_7; + +LIBCXL_9 { +global: + cxl_region_get_region_mode; +} LIBECXL_8;
cxl/lib/private.h +1 -1
@@ -171,7 +171,7 @@ struct cxl_region {unsigned int interleave_ways;unsigned int interleave_granularity;enum cxl_decode_state decode_state; -enum cxl_decoder_mode mode; +enum cxl_region_mode mode;struct daxctl_region *dax_region;struct kmod_module *module;struct list_head mappings;
cxl/libcxl.h +35 -0
@@ -303,6 +303,39 @@ int cxl_memdev_is_enabled(struct cxl_memdev *memdev);for (endpoint =cxl_endpoint_get_first (port); endpoint !=NULL ; \ endpoint =cxl_endpoint_get_next (endpoint)) +enum cxl_region_mode { +CXL_REGION_MODE_NONE =CXL_DECODER_MODE_NONE , +CXL_REGION_MODE_MIXED =CXL_DECODER_MODE_MIXED , +CXL_REGION_MODE_PMEM =CXL_DECODER_MODE_PMEM , + CXL_REGION_MODE_RAM = CXL_DECODER_MODE_RAM, +}; + +static inline const char *cxl_region_mode_name (enum cxl_region_mode mode) +{ +static const char *names[] = { + [CXL_REGION_MODE_NONE ] ="none" , + [CXL_REGION_MODE_MIXED ] ="mixed" , + [CXL_REGION_MODE_PMEM ] ="pmem" , + [CXL_REGION_MODE_RAM ] ="ram" , + }; + +if (mode <CXL_REGION_MODE_NONE || mode >CXL_REGION_MODE_RAM ) + mode =CXL_REGION_MODE_NONE ; +return names[mode]; +} + +static inline enum cxl_region_mode +cxl_region_mode_from_ident (const char *ident) +{ +if (strcmp (ident,"ram" ) ==0 ) +return CXL_REGION_MODE_RAM ; +else if (strcmp (ident,"volatile" ) ==0 ) +return CXL_REGION_MODE_RAM ; +else if (strcmp (ident,"pmem" ) ==0 ) +return CXL_REGION_MODE_PMEM ; +return CXL_REGION_MODE_NONE ; +} +struct cxl_region ;struct cxl_region *cxl_region_get_first (struct cxl_decoder *decoder);struct cxl_region *cxl_region_get_next (struct cxl_region *region);
@@ -318,6 +351,8 @@ const char *cxl_region_get_devname(struct cxl_region *region);void cxl_region_get_uuid (struct cxl_region *region,uuid_t uu);unsigned long long cxl_region_get_size (struct cxl_region *region);unsigned long long cxl_region_get_resource (struct cxl_region *region); +enum cxl_region_mode cxl_region_get_region_mode (struct cxl_region *region); +/* Deprecated: use cxl_region_get_region_mode() */ enum cxl_decoder_mode cxl_region_get_mode (struct cxl_region *region);unsigned int cxl_region_get_interleave_ways (struct cxl_region *region);unsigned int cxl_region_get_interleave_granularity (struct cxl_region *region);
Signature · 1 line
2.47.0
PATCH v3 4/9 cxl/region: Use new region mode in cxl-cli
In reply to Ira WeinyWith the introduction of DCD, region mode and decoder mode no longer remain a 1:1 relation. An interleaved region may be made up of Dynamic Capacity partitions with different indexes on each of the target devices.
Modify cxl-cli to use the new region mode interface from libcxl. Modify parameter processing and variable name changes for clarity in the future.
Functionality remains the same.
---
Changes:
[Alison: split libcxl and cxl-cli changes]
[iweiny: Process region mode based on --type]
[iweiny: s/mode/decoder_mode for clarity]
--- cxl/json.c | 6 +++--- cxl/region.c | 50 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 21 deletions(-)
cxl/json.c +3 -3
@@ -1147,7 +1147,7 @@ void util_cxl_mappings_append_json(struct json_object *jregion,struct json_object *util_cxl_region_to_json (struct cxl_region *region,unsigned long flags) { -enum cxl_decoder_mode mode =cxl_region_get_mode (region); +enum cxl_region_mode mode =cxl_region_get_region_mode (region);const char *devname =cxl_region_get_devname (region);struct json_object *jregion, *jobj;u64 val;
@@ -1174,8 +1174,8 @@ struct json_object *util_cxl_region_to_json(struct cxl_region *region,json_object_object_add (jregion,"size" , jobj); } -if (mode !=CXL_DECODER_MODE_NONE ) { - jobj =json_object_new_string (cxl_decoder_mode_name (mode)); +if (mode !=CXL_REGION_MODE_NONE ) { + jobj =json_object_new_string (cxl_region_mode_name (mode));if (jobj)json_object_object_add (jregion,"type" , jobj); }
cxl/region.c +32 -18
124 lines not on this page · raw message
Signature · 1 line
2.47.0
Please ignore. smtp failed after only sending patch 5/9. This series was resent correctly it's entirety here:
https://lore.kernel.org/all/[email protected]/
Apologies,
Ira
Quoted 77 lines · Ira Weiny
Feedback from v2 lead to the realization that cxl-cli required changes to address the region mode vs decoder mode difference properly.
While v2 separated these modes they were not sufficiently separated in the user interface of create-region. This has been corrected in this version. Specifically a new option has been added to cxl create-region. The option requires a decoder mode (DC partition) when the region type is 'dc'. The option is ignored, and can be omitted, for ram and pmem regions.
Other libcxl API changes were made to simplify the interface a bit.
Documentation was added both at the libcxl and cxl-cli levels.
cxl-dcd.shwas cleaned up quite a bit an enhanced.https://github.com/weiny2/ndctl/tree/dcd-region2-2024-11-15
CXL Dynamic Capacity Device (DCD) support is close to landing in the upstream kernel. cxl-cli requires modifications to interact with those devices. This includes creating and operating on DCD regions. cxl-testing allows for quick regression testing as well as helping to design the cxl-cli interfaces.
Add preliminary patches with some fixes. Update libcxl, cxl-cli and cxl-test with DCD support.
Signed-off-by Ira Weiny <[email protected]>---
Major changes in v3:
- [djiang: rework test script for clarity]
- [Alison: split patches between libcxl changes and cli changes]
- [Alison: fix lib symbol versioning]
- [iweiny: clarify region vs decoder mode with API to specify the
decoder mode]
- Link to v2: https://patch.msgid.link/[email protected]---
Ira Weiny (7):
ndctl/cxl-events: Don't fail test until event counts are reported ndctl/cxl/region: Report max size for region creation
libcxl: Separate region mode from decoder mode cxl/region: Use new region mode in cxl-cli
libcxl: Add extent functionality to DC regions cxl/region: Add extent output to region query cxl/test: Add Dynamic Capacity testsNavneet Singh (2):
libcxl: Add Dynamic Capacity region support cxl/region: Add cxl-cli support for DCD regionsDocumentation/cxl/cxl-create-region.txt | 11 +- Documentation/cxl/cxl-list.txt | 29 ++ Documentation/cxl/lib/libcxl.txt | 62 ++- cxl/filter.h | 3 + cxl/json.c | 80 ++- cxl/json.h | 3 + cxl/lib/libcxl.c | 261 +++++++++- cxl/lib/libcxl.sym | 13 + cxl/lib/private.h | 17 +- cxl/libcxl.h | 96 +++- cxl/list.c | 3 + cxl/memdev.c | 4 +- cxl/region.c | 93 +++- test/cxl-dcd.sh | 879 ++++++++++++++++++++++++++++++++ test/cxl-events.sh | 8 +- test/meson.build | 2 + util/json.h | 1 + 17 files changed, 1519 insertions(+), 46 deletions(-)---
base-commit:04815e5f8b87e02a4fb5a61aeebaa5cad25a15c3
change-id: 20241030-dcd-region2-2d0149eb8efdBest regards,
Signature · 1 line
Ira Weiny <[email protected]>