From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Gregory Price <gourry@gourry.net>,
linux-mm@kvack.org, vishal.l.verma@intel.com,
dave.jiang@intel.com, akpm@linux-foundation.org,
osalvador@suse.de
Cc: dan.j.williams@intel.com, ljs@kernel.org,
Liam.Howlett@oracle.com, vbabka@kernel.org, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, linux-kernel@vger.kernel.org,
nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH 2/8] mm/memory: add memory_block_align_range() helper
Date: Mon, 13 Apr 2026 17:12:07 +0200 [thread overview]
Message-ID: <ec284a03-755b-4110-b8f3-c924f3dcb839@kernel.org> (raw)
In-Reply-To: <20260321150404.3288786-3-gourry@gourry.net>
On 3/21/26 16:03, Gregory Price wrote:
> Memory hotplug operations require ranges aligned to memory block
> boundaries. This is a generic operation for hotplug.
>
> Add memory_block_align_range() as a common helper in <linux/memory.h>
> that aligns the start address up and end address down to memory block
> boundaries.
>
> Update dax/kmem to use this helper.
>
> Signed-off-by: Gregory Price <gourry@gourry.net>
> ---
> drivers/dax/kmem.c | 4 +---
> include/linux/memory.h | 22 ++++++++++++++++++++++
> 2 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
> index eb693a581961..798f389df992 100644
> --- a/drivers/dax/kmem.c
> +++ b/drivers/dax/kmem.c
> @@ -26,9 +26,7 @@ static int dax_kmem_range(struct dev_dax *dev_dax, int i, struct range *r)
> struct dev_dax_range *dax_range = &dev_dax->ranges[i];
> struct range *range = &dax_range->range;
>
> - /* memory-block align the hotplug range */
> - r->start = ALIGN(range->start, memory_block_size_bytes());
> - r->end = ALIGN_DOWN(range->end + 1, memory_block_size_bytes()) - 1;
> + *r = memory_block_align_range(range);
> if (r->start >= r->end) {
> r->start = range->start;
> r->end = range->end;
> diff --git a/include/linux/memory.h b/include/linux/memory.h
> index 5bb5599c6b2b..17cdf6ba3823 100644
> --- a/include/linux/memory.h
> +++ b/include/linux/memory.h
> @@ -20,6 +20,7 @@
> #include <linux/compiler.h>
> #include <linux/mutex.h>
> #include <linux/memory_hotplug.h>
> +#include <linux/range.h>
>
> #define MIN_MEMORY_BLOCK_SIZE (1UL << SECTION_SIZE_BITS)
>
> @@ -100,6 +101,27 @@ int arch_get_memory_phys_device(unsigned long start_pfn);
> unsigned long memory_block_size_bytes(void);
> int set_memory_block_size_order(unsigned int order);
>
> +/**
> + * memory_block_align_range - align a physical address range to memory blocks
> + * @range: the input range to align
> + *
> + * Aligns the start address up and the end address down to memory block
> + * boundaries. This is required for memory hotplug operations which must
> + * operate on memory-block aligned ranges.
> + *
> + * Returns the aligned range. Callers should check that the returned
> + * range is valid (aligned.start < aligned.end) before using it.
> + */
> +static inline struct range memory_block_align_range(const struct range *range)
Reads as if you would be passing in a memory block.
Maybe
"align_range_to_memory_blocks()"
"range_align_to_memory_blocks()"
Maybe what also works:
"memory_block_aligned_range()"
In general, LGTM.
--
Cheers,
David
next prev parent reply other threads:[~2026-04-13 15:12 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-21 15:03 [PATCH 0/8] dax/kmem: atomic whole-device hotplug via sysfs Gregory Price
2026-03-21 15:03 ` [PATCH 1/8] mm/memory-tiers: consolidate memory type dedup into mt_get_memory_type() Gregory Price
2026-04-13 15:06 ` David Hildenbrand (Arm)
2026-03-21 15:03 ` [PATCH 2/8] mm/memory: add memory_block_align_range() helper Gregory Price
2026-04-13 15:12 ` David Hildenbrand (Arm) [this message]
2026-03-21 15:03 ` [PATCH 3/8] mm/memory_hotplug: pass online_type to online_memory_block() via arg Gregory Price
2026-03-21 15:04 ` [PATCH 4/8] mm/memory_hotplug: export mhp_get_default_online_type Gregory Price
2026-04-13 15:18 ` David Hildenbrand (Arm)
2026-03-21 15:04 ` [PATCH 5/8] mm/memory_hotplug: add __add_memory_driver_managed() with online_type arg Gregory Price
2026-04-13 15:21 ` David Hildenbrand (Arm)
2026-03-21 15:04 ` [PATCH 6/8] dax: plumb hotplug online_type through dax Gregory Price
2026-04-13 15:23 ` David Hildenbrand (Arm)
2026-03-21 15:04 ` [PATCH 7/8] dax/kmem: extract hotplug/hotremove helper functions Gregory Price
2026-03-21 15:04 ` [PATCH 8/8] dax/kmem: add sysfs interface for atomic whole-device hotplug Gregory Price
2026-03-21 17:40 ` [PATCH 0/8] dax/kmem: atomic whole-device hotplug via sysfs Andrew Morton
2026-03-21 20:26 ` Gregory Price
2026-04-13 15:47 ` David Hildenbrand (Arm)
2026-04-13 14:49 ` David Hildenbrand (Arm)
2026-04-13 14:53 ` David Hildenbrand (Arm)
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=ec284a03-755b-4110-b8f3-c924f3dcb839@kernel.org \
--to=david@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=gourry@gourry.net \
--cc=kernel-team@meta.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=nvdimm@lists.linux.dev \
--cc=osalvador@suse.de \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=vishal.l.verma@intel.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