All of lore.kernel.org
 help / color / mirror / Atom feed
From: Muchun Song <muchun.song@linux.dev>
To: "Gupta, Pankaj" <pankaj.gupta@amd.com>
Cc: Muchun Song <songmuchun@bytedance.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dan Williams <djbw@kernel.org>,
	David Hildenbrand <david@kernel.org>,
	linux-mm@kvack.org, nvdimm@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-cxl@vger.kernel.org,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Alison Schofield <alison.schofield@intel.com>,
	Mike Rapoport <rppt@kernel.org>,
	Oscar Salvador <osalvador@suse.de>, Ira Weiny <iweiny@kernel.org>,
	Jan Kara <jack@suse.cz>, Matthew Wilcox <willy@infradead.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Michal Hocko <mhocko@suse.com>, Qi Zheng <qi.zheng@linux.dev>
Subject: Re: [PATCH 3/4] mm: add shared read-only vmemmap support for FS-DAX
Date: Mon, 21 Sep 2026 17:33:56 +0800	[thread overview]
Message-ID: <8EA6782C-7A3D-411F-91CD-031AB97CD024@linux.dev> (raw)
In-Reply-To: <4bc1f4de-40ad-46f0-8d37-4c4e0cad0ad6@amd.com>



> On Sep 21, 2026, at 14:42, Gupta, Pankaj <pankaj.gupta@amd.com> wrote:
> 
>> 
>> FS-DAX registers persistent-memory ranges as ZONE_DEVICE memory, and the
>> kernel normally allocates and initializes vmemmap storage for every
>> advertised PFN up front. Sparse pmem images and workloads that only use the
>> DAX direct-access path may never need writable per-PFN state for most of
>> that range, but still pay the memory and initialization cost.
>> 
>> Add an opt-in dev_pagemap mode that populates FS-DAX vmemmap PTEs from a
>> shared read-only metadata page. The shared page is initialized with the
>> common ZONE_DEVICE and dev_pagemap state, so every PFN still has a valid
>> struct page representation while private metadata allocation is deferred.
>> 
>> This relies on sizeof(struct page) being a power of two, so each vmemmap
>> page contains a naturally aligned and repeatable set of struct page slots.
>> It also requires architecture support for runtime vmemmap remapping,
>> because shared mappings must be replaced with private writable pages before
>> a PFN can enter userspace mappings.
>> 
>> The initial implementation is deliberately limited to a single
>> memory-block-aligned range. That is not a fundamental requirement, but keeps
>> the registration and teardown paths simple; support for multiple ranges or
>> less strict alignment can be added later.
>> 
>> Provide vmemmap_materialize_page() to replace shared mappings in the
>> requested metadata range with private writable copies. A later patch will
>> call it from the FS-DAX fault path.
>> 
>> No caller enables the mode yet.
>> 
>> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
>> ---
>>  include/linux/memremap.h | 11 ++++++-
>>  mm/memremap.c            | 38 ++++++++++++++++++++++--
>>  mm/mm_init.c             | 11 +++++++
>>  mm/sparse-vmemmap.c      | 64 +++++++++++++++++++++++++++++++++++++---
>>  4 files changed, 116 insertions(+), 8 deletions(-)
>> 
>> diff --git a/include/linux/memremap.h b/include/linux/memremap.h
>> index e3c2ccf872a8..21c9b6aeef67 100644
>> --- a/include/linux/memremap.h
>> +++ b/include/linux/memremap.h
>> @@ -9,6 +9,7 @@
>>    struct resource;
>>  struct device;
>> +struct page;
>>    /**
>>   * struct vmem_altmap - pre-allocated storage for vmemmap_populate
>> @@ -108,7 +109,8 @@ struct dev_pagemap_ops {
>>   	void (*folio_split)(struct folio *head, struct folio *tail);
>>  };
>>  -#define PGMAP_ALTMAP_VALID (1 << 0)
>> +#define PGMAP_ALTMAP_VALID BIT(0)
>> +#define PGMAP_VMEMMAP_OPTIMIZATION BIT(1)
> 
> I liked the overall idea.
> 
> Minor naming suggestion I have:
> 
> 'PGMAP_VMEMMAP_OPTIMIZATION' feel too generic to me.
> 
> Maybe something on the lines to reflect the actual optimization:
> 
> |PGMAP_SHARED_VMEMMAP or PGMAP_VMEMMAP_ON_DEMAND or some_other_name?|

Maybe PGMAP_VMEMMAP_SHARED? It describes the shared vmemmap backing
more precisely. I prefer SHARED over ON_DEMAND.

If you are OK with this, I will keep it for the next version.

Thanks,
Muchun



  reply	other threads:[~2026-09-21  9:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 12:21 [PATCH 0/4] mm: Reduce struct page overhead for FS-DAX pmem Muchun Song
2026-09-03 12:21 ` [PATCH 1/4] mm: generalize vmemmap remap architecture support Muchun Song
2026-09-21 12:25   ` Oscar Salvador (SUSE)
2026-09-03 12:21 ` [PATCH 2/4] nvdimm/pmem: avoid HWPoison flag updates for clean pages Muchun Song
2026-09-03 12:41   ` sashiko-bot
2026-09-21  7:33   ` Gupta, Pankaj
2026-09-21 12:53   ` Oscar Salvador (SUSE)
2026-09-22  2:33     ` Muchun Song
2026-09-03 12:21 ` [PATCH 3/4] mm: add shared read-only vmemmap support for FS-DAX Muchun Song
2026-09-21  6:42   ` Gupta, Pankaj
2026-09-21  9:33     ` Muchun Song [this message]
2026-09-21 11:05       ` Gupta, Pankaj
2026-09-21 13:09   ` Oscar Salvador (SUSE)
2026-09-22  3:17     ` Muchun Song
2026-09-03 12:21 ` [PATCH 4/4] fsdax: materialize pmem vmemmap metadata on faults Muchun Song
2026-09-03 12:53   ` sashiko-bot
2026-09-05  3:26     ` Muchun Song

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=8EA6782C-7A3D-411F-91CD-031AB97CD024@linux.dev \
    --to=muchun.song@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=alison.schofield@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=david@kernel.org \
    --cc=djbw@kernel.org \
    --cc=iweiny@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-fsdevel@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=pankaj.gupta@amd.com \
    --cc=qi.zheng@linux.dev \
    --cc=rppt@kernel.org \
    --cc=songmuchun@bytedance.com \
    --cc=vbabka@kernel.org \
    --cc=vishal.l.verma@intel.com \
    --cc=willy@infradead.org \
    /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.