CXL: add test workflow for dynamic capacity device
cover CXL: add test workflow for dynamic capacity device
From: Fan Ni <[email protected]>
The patch series add test workflow for CXL dynamic capacity device (DCD) in Qemu.
Patch 1: add new options in kconfig to enable qmp interface for qemu so qemu can be launched with qmp interface enabled, which is needed for CXL test like error injection, dynamic capacity extent add/release.
Patch 2: add a new cxl topology where a DCD device is directly attached to the root port of a host bridge. For the device itself, it has no static volatile or non-volatile capacity but only dynamic regions with no DC extents added yet. Path 3: add a new make command "cxl-create-dc-region" to create DC region for dynamic capacity, which is needed before dc extents can be added. We also fixed "make cxl" command as the regular cxl-mem-setup worklfow does not work for dcd device.
Patch 4: add a new make command "cxl-dcd-setup" to add dc extents, and convert dynamic capacity to system ram and online it.
With the patch series, we can play with DCD device in two ways, First workflow:
After system bringup, run "make cxl" which will create DC region, create dax device and convert it to system ram.
The other workflow:
After system bringup, and if ndctl is already available in the guest, perform the following two steps:
1) make cxl-create-dc-region: create a DC region;
2) make cxl-dcd-setup: add dc extents, create dax device and convert it to system ram.
Fan Ni (4):
qemu: Add QMP connection option for QMP interface access
CXL: Add a new topology to support DCD device emulation
CXL: Add new make command to create DC region for DCD device
CXL: Setup DCD device as onlined system memory
playbooks/roles/cxl/defaults/main.yml | 2 + .../cxl/tasks/cxl-create-dc-region/main.yml | 27 +++++++ .../roles/cxl/tasks/cxl-dcd-setup/main.yml | 79 +++++++++++++++++++ playbooks/roles/cxl/tasks/main.yml | 16 ++++ playbooks/roles/gen_nodes/defaults/main.yml | 4 + .../roles/gen_nodes/templates/Vagrantfile.j2 | 19 ++++- scripts/gen-nodes.Makefile | 12 +++ vagrant/Kconfig | 23 ++++++ workflows/cxl/Makefile | 19 ++++- 9 files changed, 197 insertions(+), 4 deletions(-) create mode 100644 playbooks/roles/cxl/tasks/cxl-create-dc-region/main.yml create mode 100644 playbooks/roles/cxl/tasks/cxl-dcd-setup/main.yml
Signature · 1 line
2.42.0
PATCH 1/4 qemu: Add QMP connection option for QMP interface access
From: Fan Ni <[email protected]>
In Qemu, QMP interface allows applications to control a QEMU instance. Currently, QMP interface has been used to inject poison, add/release dynamic capacity extents, etc.
With the change, we add a Qemu configuration option to allow user to use the QMP interface. By default, we start QMP on a TCP socket and let Qemu instance go through without waiting for QMP connection.
--- playbooks/roles/gen_nodes/defaults/main.yml | 3 +++ .../roles/gen_nodes/templates/Vagrantfile.j2 | 8 ++++++++ scripts/gen-nodes.Makefile | 9 +++++++++ vagrant/Kconfig | 15 +++++++++++++++ 4 files changed, 35 insertions(+)
playbooks/roles/gen_nodes/defaults/main.yml +3 -0
@@ -48,6 +48,9 @@ libvirt_qemu_group: libvirt-qemu libvirt_machine_type: 'pc' libvirt_host_passthrough: False libvirt_enable_cxl: False +libvirt_enable_qmp: False +libvirt_qemu_qmp_string: "" +libvirt_qemu_qmp_wait: False libvirt_enable_cxl_demo_topo1: False libvirt_enable_cxl_demo_topo2: False libvirt_enable_cxl_switch_topo1: False
playbooks/roles/gen_nodes/templates/Vagrantfile.j2 +8 -0
@@ -325,6 +325,14 @@ Vagrant.configure("2") do |config| {% endif %} # !switch topo1 libvirt.qemuargs :value => "-M" libvirt.qemuargs :value => "cxl-fmw.0.targets.0=cxl.0,cxl-fmw.0.size=512M" +{% if libvirt_enable_qmp %} + libvirt.qemuargs :value => "-qmp" +{% if libvirt_qemu_qmp_wait %} + libvirt.qemuargs :value => "{{ libvirt_qemu_qmp_string }},wait=on" +{% else %} # !qmp_wait + libvirt.qemuargs :value => "{{ libvirt_qemu_qmp_string }},wait=off" +{% endif %} # libvirt_qemu_qmp_wait +{% endif %} # libvirt_enable_qmp {% endif %} # CXL {% endif %}
scripts/gen-nodes.Makefile +9 -0
@@ -190,6 +190,15 @@ GEN_NODES_EXTRA_ARGS += libvirt_machine_type='q35' ifeq (y,$(CONFIG_QEMU_ENABLE_CXL)) GEN_NODES_EXTRA_ARGS += libvirt_enable_cxl='True' +ifeq (y,$(CONFIG_QEMU_START_QMP_ON_TCP_SOCKET)) +GEN_NODES_EXTRA_ARGS += libvirt_enable_qmp='True' +GEN_NODES_EXTRA_ARGS += libvirt_qemu_qmp_string='$(subst ",,$(CONFIG_QEMU_QMP_COMMAND_LINE_STRING))' +ifeq (y,$(CONFIG_QEMU_QMP_WAIT_ON)) +GEN_NODES_EXTRA_ARGS += libvirt_qemu_qmp_wait='True' +else +GEN_NODES_EXTRA_ARGS += libvirt_qemu_qmp_wait='False' +endif # CONFIG_QEMU_QMP_WAIT_ON +endif # CONFIG_QEMU_START_QMP_ON_TCP_SOCKET ifeq (y,$(CONFIG_QEMU_ENABLE_CXL_DEMO_TOPOLOGY_1)) GEN_NODES_EXTRA_ARGS += libvirt_enable_cxl_demo_topo1='True' endif # QEMU_ENABLE_CXL_DEMO_TOPOLOGY_1
vagrant/Kconfig +15 -0
@@ -1635,6 +1635,21 @@ config QEMU_ENABLE_CXL if QEMU_ENABLE_CXL +config QEMU_START_QMP_ON_TCP_SOCKET + bool "Start QMP on a TCP socket" + default n + if QEMU_START_QMP_ON_TCP_SOCKET + config QEMU_QMP_COMMAND_LINE_STRING + string "Qemu command line string for qmp" + default "tcp:localhost:4444,server" + help + Option for qmp interface (from https://wiki.qemu.org/Documentation/QMP). + + config QEMU_QMP_WAIT_ON + bool "Let Qemu instance wait for qmp connection" + default n + endif # QEMU_START_QMP_ON_TCP_SOCKET + choice prompt "CXL topology to enable" default QEMU_ENABLE_CXL_DEMO_TOPOLOGY_1
Signature · 1 line
2.42.0
PATCH 2/4 CXL: Add a new topology to support DCD device emulation
In reply to [email protected]From: Fan Ni <[email protected]>
The change adds a new cxl topology to enable dynamic capacity device emulation in Qemu. The device includes no static volatile/non-volatile capacity but 2 dynamic capacity regions where dynamic capacity extents can be added. Also, increase the fixed memory window size and host backend size which gives more room for testing as the dc extents needs to be a least one memory block (256MB).
--- playbooks/roles/gen_nodes/defaults/main.yml | 1 + playbooks/roles/gen_nodes/templates/Vagrantfile.j2 | 11 ++++++++--- scripts/gen-nodes.Makefile | 3 +++ vagrant/Kconfig | 8 ++++++++ 4 files changed, 20 insertions(+), 3 deletions(-)
playbooks/roles/gen_nodes/defaults/main.yml +1 -0
@@ -54,6 +54,7 @@ libvirt_qemu_qmp_wait: False libvirt_enable_cxl_demo_topo1: False libvirt_enable_cxl_demo_topo2: False libvirt_enable_cxl_switch_topo1: False +libvirt_enable_cxl_dcd_topo1: False libvirt_extra_drive_id_prefix: 'drv' libvirt_extra_storage_drive_nvme: True libvirt_extra_storage_drive_virtio: False
playbooks/roles/gen_nodes/templates/Vagrantfile.j2 +8 -3
@@ -292,7 +292,7 @@ Vagrant.configure("2") do |config| cxl_mem1_path = cxl_path + "/cxl-mem1.raw" libvirt.qemuargs :value => "-object" - libvirt.qemuargs :value => "memory-backend-file,id=kdevops-cxl-mem1,share=on,mem-path=#{cxl_mem1_path},size=256M" + libvirt.qemuargs :value => "memory-backend-file,id=kdevops-cxl-mem1,share=on,mem-path=#{cxl_mem1_path},size=4G" # Label Storage Area, used to store CXL namespace labels and region labels cxl_lsa1_path = cxl_path + "/cxl-lsa1.raw"
@@ -319,12 +319,17 @@ Vagrant.configure("2") do |config| libvirt.qemuargs :value => "cxl-downstream,port=1,bus=kdevops_cxl_us0,id=kdevops_cxl_swport1,chassis=0,slot=5" libvirt.qemuargs :value => "-device" libvirt.qemuargs :value => "cxl-type3,bus=kdevops_cxl_swport0,memdev=kdevops-cxl-mem1,lsa=kdevops-cxl-lsa1,id=kdevops-cxl-pmem0" -{% else %} # switch topo1 +{% else %} # !switch topo1 + {% if not libvirt_enable_cxl_dcd_topo1 %} libvirt.qemuargs :value => "-device" libvirt.qemuargs :value => "cxl-type3,bus=kdevops_cxl_root_port0,memdev=kdevops-cxl-mem1,lsa=kdevops-cxl-lsa1,id=kdevops-cxl-pmem0" + {% else %} # dcd_topo1 + libvirt.qemuargs :value => "-device" + libvirt.qemuargs :value => "cxl-type3,bus=kdevops_cxl_root_port0,nonvolatile-dc-memdev=kdevops-cxl-mem1,lsa=kdevops-cxl-lsa1,id=kdevops-cxl-dcd0,num-dc-regions=2" + {% endif %} # dcd topo1 {% endif %} # !switch topo1 libvirt.qemuargs :value => "-M" - libvirt.qemuargs :value => "cxl-fmw.0.targets.0=cxl.0,cxl-fmw.0.size=512M" + libvirt.qemuargs :value => "cxl-fmw.0.targets.0=cxl.0,cxl-fmw.0.size=8G" {% if libvirt_enable_qmp %} libvirt.qemuargs :value => "-qmp" {% if libvirt_qemu_qmp_wait %}
scripts/gen-nodes.Makefile +3 -0
@@ -208,6 +208,9 @@ endif # QEMU_ENABLE_CXL_DEMO_TOPOLOGY_2 ifeq (y,$(CONFIG_QEMU_ENABLE_CXL_SWITCH_TOPOLOGY_1)) GEN_NODES_EXTRA_ARGS += libvirt_enable_cxl_switch_topo1='True' endif # QEMU_ENABLE_CXL_SWITCH_TOPOLOGY_1 +ifeq (y,$(CONFIG_QEMU_ENABLE_CXL_DEMO_DCD_TOPOLOGY_1)) +GEN_NODES_EXTRA_ARGS += libvirt_enable_cxl_dcd_topo1='True' +endif # QEMU_ENABLE_CXL_DEMO_DCD_TOPOLOGY_1 endif # CONFIG_QEMU_ENABLE_CXL endif # CONFIG_LIBVIRT_MACHINE_TYPE_Q35
vagrant/Kconfig +8 -0
@@ -1681,6 +1681,14 @@ config QEMU_ENABLE_CXL_SWITCH_TOPOLOGY_1 is connected to one of the down stream ports. The upstream port is connected to a root port on the host bridge. +config QEMU_ENABLE_CXL_DEMO_DCD_TOPOLOGY_1 + bool "CXL DCD demo directly attached to a single-port HB" + help + This topology adds a DCD device in the topology, directly attached to + a host bridge with only one root port. + The device has zero (volatile or non-volatile) static capacity + and 2 dynamic capacity regions where dynamic extents can be added. + endchoice endif # QEMU_ENABLE_CXL
Signature · 1 line
2.42.0
PATCH 3/4 CXL: Add new make command to create DC region for DCD device
In reply to [email protected]From: Fan Ni <[email protected]>
For a dynamic capacity device (DCD), before a dynamic capacity (DC) extent can be added and used by the system, a DC region needs to be created to cover the DC address range.
This change add support to a new make command "cxl-create-dc-region" for creating a dc region.
--- .../cxl/tasks/cxl-create-dc-region/main.yml | 27 +++++++++++++++++++ playbooks/roles/cxl/tasks/main.yml | 4 +++ workflows/cxl/Makefile | 6 +++++ 3 files changed, 37 insertions(+) create mode 100644 playbooks/roles/cxl/tasks/cxl-create-dc-region/main.yml
playbooks/roles/cxl/tasks/cxl-create-dc-region/main.yml new file +27 -0
@@ -0,0 +1,27 @@ +--- + +- name: Create a DC region before DC extents can be added + become: yes + become_method: sudo + shell: "rid=0; \ + region=$(cat /sys/bus/cxl/devices/decoder0.0/create_dc_region); \ + echo $region > /sys/bus/cxl/devices/decoder0.0/create_dc_region; \ + echo 256 > /sys/bus/cxl/devices/$region/interleave_granularity; \ + echo 1 > /sys/bus/cxl/devices/$region/interleave_ways; \ + echo dc$rid >/sys/bus/cxl/devices/decoder2.0/mode; \ + echo 0x40000000 >/sys/bus/cxl/devices/decoder2.0/dpa_size; \ + echo 0x40000000 > /sys/bus/cxl/devices/$region/size; \ + echo decoder2.0 > /sys/bus/cxl/devices/$region/target0; \ + echo 1 > /sys/bus/cxl/devices/$region/commit; \ + echo $region > /sys/bus/cxl/drivers/cxl_region/bind" + tags: [ 'cxl-create-dc-region' ] + +- name: Show the DC region created + become: no + shell: "cxl list -uR" + register: command_output + tags: [ 'cxl-create-dc-region' ] + +- debug: + var: command_output.stdout_lines + tags: [ 'cxl-create-dc-region' ]
playbooks/roles/cxl/tasks/main.yml +4 -0
@@ -57,6 +57,10 @@ include_tasks: cxl-mem-setup/main.yml tags: [ 'cxl-mem-setup' ] +- name: Create a dynamic capacity region for further dc extent add operations + include_tasks: cxl-create-dc-region/main.yml + tags: [ 'cxl-create-dc-region' ] + - name: Set the path to cxl workflow set_fact: cxl_workflow_target: "../workflows/cxl/"
workflows/cxl/Makefile +6 -0
@@ -43,6 +43,11 @@ cxl-mem-setup: -f 30 -i hosts playbooks/cxl.yml \ --tags cxl-mem-setup $(LIMIT_HOSTS) +cxl-create-dc-region: + $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \ + -f 30 -i hosts playbooks/cxl.yml \ + --tags cxl-create-dc-region $(LIMIT_HOSTS) + cxl-help-menu: @echo "cxl development:" @echo "cxl - Git clones ncdtl to compile and install the /usr/bin/cxl binary"
@@ -50,6 +55,7 @@ cxl-help-menu: @echo "cxl-test-meson - Runs the ndctl meson unit tests for the CXL test suite" @echo "cxl-results - Get results for all tests runs" @echo "cxl-mem-setup - Convert cxl memory to cpu-less numa node" + @echo "cxl-create-dc-region - Create a DC region so DC extents can be added further" cxl-help-end: @echo ""
Signature · 1 line
2.42.0
PATCH 4/4 CXL: Setup DCD device as onlined system memory
In reply to [email protected]From: Fan Ni <[email protected]>
In order to use dynamic capacity of DCD device as system memory, following steps are needed:
1. Offer DC extents to the host; (Assuming region is already created for the DC region where the extents to be added).
2. Create DAX device for the region with daxctl.
3. Convert dax memory to system ram.
4. Online the memory for use.
The change sets up the dynamic capacity offered to the host as system memory and online it. After the above 4 steps, we should see the memory onlined with command "lsmem".
--- playbooks/roles/cxl/defaults/main.yml | 2 + .../roles/cxl/tasks/cxl-dcd-setup/main.yml | 79 +++++++++++++++++++ playbooks/roles/cxl/tasks/main.yml | 12 +++ workflows/cxl/Makefile | 15 +++- 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 playbooks/roles/cxl/tasks/cxl-dcd-setup/main.yml
playbooks/roles/cxl/defaults/main.yml +2 -0
@@ -5,3 +5,5 @@ ndctl_data: "{{ data_path }}/ndctl" ndctl_version: "pending" ndctl_meson_testlog: "build/meson-logs/testlog.txt" kdevops_run_cxl_tests: False +kdevops_enable_cxl_dcd: False +kdevops_qmp_str: "tcp:localhost:4444,server"
playbooks/roles/cxl/tasks/cxl-dcd-setup/main.yml new file +79 -0
79 lines not on this page · raw message
playbooks/roles/cxl/tasks/main.yml +12 -0
@@ -56,10 +56,22 @@ - name: Convert cxl memory to kernel managed memory include_tasks: cxl-mem-setup/main.yml tags: [ 'cxl-mem-setup' ] + when: + - not kdevops_enable_cxl_dcd|bool - name: Create a dynamic capacity region for further dc extent add operations include_tasks: cxl-create-dc-region/main.yml tags: [ 'cxl-create-dc-region' ] + when: + - kdevops_enable_cxl_dcd|bool + +- name: Setup CXL DCD device as system ram + include_tasks: cxl-dcd-setup/main.yml + vars: + qmp_port_str: "{{ kdevops_qmp_str }}" + tags: [ 'cxl-dcd-setup' ] + when: + - kdevops_enable_cxl_dcd|bool - name: Set the path to cxl workflow set_fact:
workflows/cxl/Makefile +13 -2
@@ -7,6 +7,11 @@ CXL_ARGS += ndctl_git='$(subst ",,$(CONFIG_NDCTL_GIT))' CXL_ARGS += ndctl_data=\"$(subst ",,$(CONFIG_NDCTL_DATA))\" CXL_ARGS += ndctl_version='$(subst ",,$(CONFIG_NDCTL_VERSION))' +ifeq (y,$(CONFIG_QEMU_ENABLE_CXL_DEMO_DCD_TOPOLOGY_1)) + CXL_ARGS += kdevops_enable_cxl_dcd="True" + CXL_ARGS += kdevops_qmp_str=$(CONFIG_QEMU_QMP_COMMAND_LINE_STRING) +endif + DYNAMIC_RUNTIME_VARS := "kdevops_run_cxl_tests": $(CONFIG_ENABLE_CXL_TEST) WORKFLOW_ARGS += $(CXL_ARGS) BOOTLINUX_CXL_HELP :=
@@ -41,12 +46,17 @@ cxl-results: cxl-mem-setup: $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \ -f 30 -i hosts playbooks/cxl.yml \ - --tags cxl-mem-setup $(LIMIT_HOSTS) + --tags vars,extra-vars,cxl-mem-setup $(LIMIT_HOSTS) cxl-create-dc-region: $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \ -f 30 -i hosts playbooks/cxl.yml \ - --tags cxl-create-dc-region $(LIMIT_HOSTS) + --tags vars,cxl-create-dc-region $(LIMIT_HOSTS) + +cxl-dcd-setup: + $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \ + -f 30 -i hosts playbooks/cxl.yml \ + --tags vars,cxl-dcd-setup $(LIMIT_HOSTS) cxl-help-menu: @echo "cxl development:"
@@ -56,6 +66,7 @@ cxl-help-menu: @echo "cxl-results - Get results for all tests runs" @echo "cxl-mem-setup - Convert cxl memory to cpu-less numa node" @echo "cxl-create-dc-region - Create a DC region so DC extents can be added further" + @echo "cxl-dcd-setup - Add DC extents to DC region, create dax device and convert to system RAM and online" cxl-help-end: @echo ""
Signature · 1 line
2.42.0
Quoted 23 lines · On Tue, Nov 28, 2023 at 02:42:00PM -0800, [email protected] wrote:
From: Fan Ni <[email protected]>
The patch series add test workflow for CXL dynamic capacity device (DCD) in Qemu.
Patch 1: add new options in kconfig to enable qmp interface for qemu so qemu can be launched with qmp interface enabled, which is needed for CXL test like error injection, dynamic capacity extent add/release.
Patch 2: add a new cxl topology where a DCD device is directly attached to the root port of a host bridge. For the device itself, it has no static volatile or non-volatile capacity but only dynamic regions with no DC extents added yet. Path 3: add a new make command "cxl-create-dc-region" to create DC region for dynamic capacity, which is needed before dc extents can be added. We also fixed "make cxl" command as the regular cxl-mem-setup worklfow does not work for dcd device.
Patch 4: add a new make command "cxl-dcd-setup" to add dc extents, and convert dynamic capacity to system ram and online it.With the patch series, we can play with DCD device in two ways, First workflow:
After system bringup, run "make cxl" which will create DC region, create dax device and convert it to system ram.
Quoted 6 lines
The other workflow:
After system bringup, and if ndctl is already available in the guest, perform the following two steps:
1) make cxl-create-dc-region: create a DC region;
2) make cxl-dcd-setup: add dc extents, create dax device and convert it to system ram.
Applied and pushed. I made some minor changes after this to clean this a tiny bit up.
Thanks!
Luis