From: Dave Jiang <dave.jiang@intel.com>
To: "Cao, Quanquan/曹 全全" <caoqq@fujitsu.com>, vishal.l.verma@intel.com
Cc: <linux-cxl@vger.kernel.org>, <nvdimm@lists.linux.dev>,
<dan.j.williams@intel.com>, <yangx.jy@fujitsu.com>
Subject: Re: [NDCTL PATCH v3] cxl/region: Add -f option for disable-region
Date: Mon, 27 Nov 2023 10:13:46 -0700 [thread overview]
Message-ID: <1c5f9602-7226-42f9-937c-671947ccdb73@intel.com> (raw)
In-Reply-To: <4910174f-4cda-a664-62ee-a6b37f96efac@fujitsu.com>
On 11/27/23 02:34, Cao, Quanquan/曹 全全 wrote:
>
>
>> +static int disable_region(struct cxl_region *region)
>> +{
>> + const char *devname = cxl_region_get_devname(region);
>> + struct daxctl_region *dax_region;
>> + struct daxctl_memory *mem;
>> + struct daxctl_dev *dev;
>> + int failed = 0, rc;
>> +
>> + dax_region = cxl_region_get_daxctl_region(region);
>> + if (!dax_region)
>> + goto out;
>> +
>> + daxctl_dev_foreach(dax_region, dev) {
>> + mem = daxctl_dev_get_memory(dev);
>> + if (!mem)
>> + return -ENXIO;
>> +
>> + /*
>> + * If memory is still online and user wants to force it, attempt
>> + * to offline it.
>> + */
>> + if (daxctl_memory_is_online(mem)) {
>> + rc = daxctl_memory_offline(mem);
>> + if (rc < 0) {
>> + log_err(&rl, "%s: unable to offline %s: %s\n",
>> + devname,
>> + daxctl_dev_get_devname(dev),
>> + strerror(abs(rc)));
>> + if (!param.force)
>> + return rc;
>> +
>> + failed++;
>> + }
>> + }
>> + }
>> +
>> + if (failed) {
>> + log_err(&rl, "%s: Forcing region disable without successful offline.\n",
>> + devname);
>> + log_err(&rl, "%s: Physical address space has now been permanently leaked.\n",
>> + devname);
>> + log_err(&rl, "%s: Leaked address cannot be recovered until a reboot.\n",
>> + devname);
>> + }
>> +
>
>> static int do_region_xable(struct cxl_region *region, enum region_actions action)
>> {
>> switch (action) {
>> case ACTION_ENABLE:
>> return cxl_region_enable(region);
>> case ACTION_DISABLE:
>> - return cxl_region_disable(region);
>> + return disable_region(region);
>> case ACTION_DESTROY:
>> return destroy_region(region);
>> default:
>
> Hi Dave
>
> In this patch, a new function 'disable_region(region)' has been added. When using the 'cxl destroy-region region0 -f' command, there's a check first, followed by the 'destroy-region' operation. In terms of user-friendliness, which function is more user-friendly: 'cxl_region_disable(region)' or 'disable_region(region)'?
>
> Attach destroy_region section code
> static int destroy_region(struct cxl_region *region)
> {
> const char *devname = cxl_region_get_devname(region);
> unsigned int ways, i;
> int rc;
>
> /* First, unbind/disable the region if needed */
> if (cxl_region_is_enabled(region)) {
> if (param.force) {
> rc = cxl_region_disable(region);
> if (rc) {
> log_err(&rl, "%s: error disabling region: %s\n",
> devname, strerror(-rc));
> return rc;
> }
> } else {
> log_err(&rl, "%s active. Disable it or use --force\n",
> devname);
> return -EBUSY;
> }
> }
>
> I have considered two options for your reference:
>
> 1.Assuming the user hasn't executed the 'cxl disable-region region0' command and directly runs 'cxl destroy-region region0 -f', using the 'disable_region(region)' function to first take the region offline and then disable it might be more user-friendly.
> 2.If the user executes the 'cxl disable-region region0' command but fails to take it offline successfully, then runs 'cxl destroy-region region0 -f', using the 'cxl_region_disable(region)' function to directly 'disable region' and then 'destroy region' would also be reasonable.
To make the behavior consistent, I think we should use disable_region() with the check for the destroy_region() path.
What do you think Vishal?
>
>
>
>
>
next prev parent reply other threads:[~2023-11-27 17:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-31 21:20 [NDCTL PATCH v3] cxl/region: Add -f option for disable-region Dave Jiang
2023-11-02 22:51 ` Alison Schofield
2023-11-09 11:26 ` 回复: " Xiao Yang (Fujitsu)
2023-11-09 19:32 ` fan
2023-11-27 9:34 ` Cao, Quanquan/曹 全全
2023-11-27 17:13 ` Dave Jiang [this message]
2023-11-27 17:58 ` Verma, Vishal L
2023-11-27 23:28 ` Dave Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1c5f9602-7226-42f9-937c-671947ccdb73@intel.com \
--to=dave.jiang@intel.com \
--cc=caoqq@fujitsu.com \
--cc=dan.j.williams@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
--cc=yangx.jy@fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox