All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: "Gregory Price (Meta)" <gourry@gourry.net>,
	nvdimm@lists.linux.dev, alison.schofield@intel.com
Cc: linux-cxl@vger.kernel.org
Subject: Re: [ndctl PATCH] libdaxctl: check the zone of onlined memory blocks
Date: Thu, 29 Oct 2026 16:24:18 -0700	[thread overview]
Message-ID: <8a66bf6c-e0d8-4282-a279-4e2e6884a5f7@intel.com> (raw)
In-Reply-To: <179322248318.3398847.13424413341337264007@gourry.net>



On 10/28/26 2:21 PM, Gregory Price (Meta) wrote:
> daxctl_memory_online_with_zone() is meant to scan the device's blocks
> after onlining them and fail with -EBUSY if any block is not in the
> requested zone: an agent such as an auto-online policy or a udev rule
> may have onlined some blocks first, into a zone daxctl did not ask for.
> online_one_memblock() relies on that scan, it ignores a failed write
> for a block that someone else onlined ("There will be a full scan for
> zone correctness later").
> 
> But daxctl_memory_op() returns the number of blocks it onlined, and the
> function returns early on any non-zero value, so the scan only ever
> runs when no block was onlined at all.  Whenever daxctl does online
> memory, a zone mismatch goes unreported.
> 
> Example: 
>   memory_hotplug.online_policy=auto-movable
>   reconfigure-device --no-movable -m system-ram
> 
>   => reports success with the memory in ZONE_MOVABLE.
> 
> Return early only on errors, and return the number of onlined blocks
> after the scan.
> 
> Fixes: 0542201b5902 ("daxctl: detect races when onlining memory blocks")
> Signed-off-by: "Gregory Price (Meta)" <gourry@gourry.net>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> 
> ---
>  daxctl/lib/libdaxctl.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
> index 01b1915..f4b2fda 100644
> --- a/daxctl/lib/libdaxctl.c
> +++ b/daxctl/lib/libdaxctl.c
> @@ -1691,7 +1691,7 @@ static int daxctl_memory_online_with_zone(struct daxctl_memory *mem,
>  	struct daxctl_dev *dev = daxctl_memory_get_dev(mem);
>  	const char *devname = daxctl_dev_get_devname(dev);
>  	struct daxctl_ctx *ctx = daxctl_dev_get_ctx(dev);
> -	int rc;
> +	int rc, count;
>  
>  	switch (zone) {
>  	case MEM_ZONE_MOVABLE:
> @@ -1704,8 +1704,9 @@ static int daxctl_memory_online_with_zone(struct daxctl_memory *mem,
>  		err(ctx, "%s: BUG: invalid zone for onlining\n", devname);
>  		rc = -EINVAL;
>  	}
> -	if (rc)
> +	if (rc < 0)
>  		return rc;
> +	count = rc;
>  
>  	/*
>  	 * Detect any potential races when blocks were being brought online by
> @@ -1724,7 +1725,7 @@ static int daxctl_memory_online_with_zone(struct daxctl_memory *mem,
>  		return -EBUSY;
>  	}
>  
> -	return rc;
> +	return count;
>  }
>  
>  DAXCTL_EXPORT int daxctl_memory_online(struct daxctl_memory *mem)


  reply	other threads:[~2026-10-29 23:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 21:21 [ndctl PATCH] libdaxctl: check the zone of onlined memory blocks Gregory Price (Meta)
2026-10-29 23:24 ` Dave Jiang [this message]
2026-10-30  1:42 ` Alison Schofield

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=8a66bf6c-e0d8-4282-a279-4e2e6884a5f7@intel.com \
    --to=dave.jiang@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=gourry@gourry.net \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.