Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 C72FA5024A for ; Tue, 28 Nov 2023 22:44:05 +0000 (UTC) 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="fC1INcOa" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-28555b0c7afso5475191a91.1 for ; Tue, 28 Nov 2023 14:44:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701211445; x=1701816245; darn=lists.linux.dev; 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=nXjMwGJOTkljMWbpWbtfy+MFlrEsEVawrZBroCEMVlA=; b=fC1INcOaPifcxfyUDfT86PRUcPLCZgy3qyYgYfRFMb67FxKbhKwPCIcqwC6rsWMmS2 J3+hXQ9fo4lrgHI8vJ2cS3xwax2Iya/Y8PYXJ++4zFlw60wA8yn/x19KI7tmWFsFC9gD CoWVuIazT42PRHBf60HtVJEbsfPMQtW6atBEplPJBQgacdraluzsEvMU5Iuyp48Ym51v pww2d8pu3A2l585XRL9cBVJbnrzmTI/z7zjuTeVi62CaKq9f8HEiFI5NJ+DDnGF3/w2N gilKmpYe6uZLJX01ausBwRRqjjNfjHY0WgPqP39wYXO+dTS25Vnw3T3FJT7s6sR5xMo0 omlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701211445; x=1701816245; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nXjMwGJOTkljMWbpWbtfy+MFlrEsEVawrZBroCEMVlA=; b=kdchH6eCJ3/QWMF53gYfTxpLF4sdGrJofmry9mF52fgo4lZ77iPJvLvwbh/aDNJCAs ASy1HA0rWnpsx35B6A9wz2fwqOQY52+ZreycSTM94wBgOAVtDmpvjvS6mxzsWSdeb19y VRSGJ81jSdERxNGgOCntT6q7mpL/4NVRG8whDxgcepCjjkXMzCN7GdLVJUO+I/iNZ4SB 0kO20xCA2kAX9X3ukBuYBA8giH8LKwaAUhcmsjgMp+ygKZ+3B/4Yynyg2M/2NvadZ8Z0 e+5vIPU6owldoTtmU8o4Bxkbfi0lCgXgQNCUdQ2GvrkR2Q+6V7+eCL5oOcdsNOuOLkeJ uJtQ== X-Gm-Message-State: AOJu0YwlgyTiDQDwXZCt+HrUgRKyCG8BGDPs4rjS/Z+8reC02mtxRkpT HQ+JLX4P4bFl2D7eLDrvmLGmvFHhPqw= X-Google-Smtp-Source: AGHT+IEByt6ZoHz+kzdDzM923YCiPYpiv4aDYVOrBHR8RfShsGDCmV+qjDkcl+bNcBY7Bgnvx6eTCA== X-Received: by 2002:a17:90b:4b4c:b0:285:9833:d1af with SMTP id mi12-20020a17090b4b4c00b002859833d1afmr18664559pjb.26.1701211445082; Tue, 28 Nov 2023 14:44:05 -0800 (PST) Received: from DT.local (c-71-202-158-162.hsd1.ca.comcast.net. [71.202.158.162]) by smtp.gmail.com with ESMTPSA id s5-20020a17090a5d0500b00280469602bcsm9868120pji.2.2023.11.28.14.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 14:44:04 -0800 (PST) From: nifan.cxl@gmail.com To: mcgrof@kernel.org Cc: nmtadam.samsung@gmail.com, kdevops@lists.linux.dev, jlayton@kernel.org, a.manzanares@samsung.com, Fan Ni Subject: [PATCH 4/4] CXL: Setup DCD device as onlined system memory Date: Tue, 28 Nov 2023 14:42:04 -0800 Message-ID: <20231128224331.324500-5-nifan.cxl@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231128224331.324500-1-nifan.cxl@gmail.com> References: <20231128224331.324500-1-nifan.cxl@gmail.com> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Fan Ni 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". Signed-off-by: Fan Ni --- 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 diff --git a/playbooks/roles/cxl/defaults/main.yml b/playbooks/roles/cxl/defaults/main.yml index 1d230ebf..8bed9594 100644 --- a/playbooks/roles/cxl/defaults/main.yml +++ b/playbooks/roles/cxl/defaults/main.yml @@ -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" diff --git a/playbooks/roles/cxl/tasks/cxl-dcd-setup/main.yml b/playbooks/roles/cxl/tasks/cxl-dcd-setup/main.yml new file mode 100644 index 00000000..39660efb --- /dev/null +++ b/playbooks/roles/cxl/tasks/cxl-dcd-setup/main.yml @@ -0,0 +1,79 @@ +--- + +- name: Add DC extents to the hosts + shell: " \ + qmp_port_str={{ qmp_port_str }}; \ + qmp_port=`echo $qmp_port_str | awk -F'[^0-9]+' '{ print $2 }'`;\ + qmp_str=' \ + { \"execute\": \"qmp_capabilities\" } \ + { \"execute\": \"cxl-add-dynamic-capacity\", + \"arguments\": { + \"path\": \"/machine/peripheral/kdevops-cxl-dcd0\", + \"region-id\": 0, + \"extents\": [ + { + \"offset\": 0, + \"len\": 128 + }, + { + \"offset\": 128, + \"len\": 256 + } + ] + } + } '; \ + echo $qmp_str | ncat localhost $qmp_port" + register: command_output + tags: [ 'cxl-dcd-setup' ] + delegate_to: localhost + +- debug: var=command_output.stdout_lines + tags: [ 'cxl-dcd-setup' ] + +- name: Show DC extents added + become: no + shell: "ls /sys/bus/cxl/devices/decoder0.0/region0/dax_region0/ -lt" + register: command_output + tags: [ 'cxl-dcd-setup' ] + +- debug: var=command_output.stdout_lines + tags: [ 'cxl-dcd-setup' ] + +- name: Create dax devices for DC region + become: yes + become_method: sudo + shell: "daxctl create-device region0" + register: command_output + tags: [ 'cxl-dcd-setup' ] + +- debug: var=command_output.stdout_lines + tags: [ 'cxl-dcd-setup' ] + +- name: Show dax devices added + become: no + shell: "ls /dev/dax* -lt" + register: command_output + tags: [ 'cxl-dcd-setup' ] + +- debug: var=command_output.stdout_lines + tags: [ 'cxl-dcd-setup' ] + +- name: Convert dax devices to system RAM and online + become: yes + become_method: sudo + shell: "daxctl reconfigure-device --mode=system-ram --no-online dax0.1; \ + daxctl online-memory dax0.1;" + register: command_output + tags: [ 'cxl-dcd-setup' ] + +- debug: var=command_output.stdout_lines + tags: [ 'cxl-dcd-setup' ] + +- name: Show system memory with lsmem + become: no + shell: "lsmem" + register: command_output + tags: [ 'cxl-dcd-setup' ] + +- debug: var=command_output.stdout_lines + tags: [ 'cxl-dcd-setup' ] diff --git a/playbooks/roles/cxl/tasks/main.yml b/playbooks/roles/cxl/tasks/main.yml index 164bc2ad..9ac95fd9 100644 --- a/playbooks/roles/cxl/tasks/main.yml +++ b/playbooks/roles/cxl/tasks/main.yml @@ -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: diff --git a/workflows/cxl/Makefile b/workflows/cxl/Makefile index 86d17288..73d12b71 100644 --- a/workflows/cxl/Makefile +++ b/workflows/cxl/Makefile @@ -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 "" -- 2.42.0