From: "David Hildenbrand (Arm)" <david@kernel.org>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Jann Horn <jannh@google.com>,
Pedro Falcato <pfalcato@suse.de>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Jan Kara <jack@suse.cz>, Miaohe Lin <linmiaohe@huawei.com>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
Rik van Riel <riel@surriel.com>, Harry Yoo <harry@kernel.org>,
Lance Yang <lance.yang@linux.dev>, Kees Cook <kees@kernel.org>,
Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Nico Pache <npache@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>, Usama Arif <usama.arif@linux.dev>,
Matthew Brost <matthew.brost@intel.com>,
Joshua Hahn <joshua.hahnjy@gmail.com>,
Rakie Kim <rakie.kim@sk.com>, Byungchul Park <byungchul@sk.com>,
Gregory Price <gourry@gourry.net>,
Ying Huang <ying.huang@linux.alibaba.com>,
Alistair Popple <apopple@nvidia.com>,
Peter Xu <peterx@redhat.com>, Xu Xin <xu.xin16@zte.com.cn>,
Chengming Zhou <chengming.zhou@linux.dev>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v2 00/15] mm/rmap: index MAP_PRIVATE file-backed folios by virt pgoff
Date: Mon, 27 Jul 2026 16:44:06 +0200 [thread overview]
Message-ID: <880981b5-ef79-4c9a-a8bd-7540002fcd15@kernel.org> (raw)
In-Reply-To: <20260720-b4-scalable-cow-virt-pgoff-v2-0-2d549757a76f@kernel.org>
On 7/20/26 16:38, Lorenzo Stoakes (ARM) wrote:
> In memory management we've managed to manufacture a great deal of confusion
> around the concept of anonymous memory. We have:
>
> 1. 'Pure anon' memory - anonymous VMAs whose folios are anonymous and
> swap-backed (thus for reclaim purposes, treated as anonymous). These are
> simple enough.
>
> 2. shmem - file-backed VMAs, file-backed folios (from rmap perspective) so
> present in the page cache and mapped by an address_space object, but
> whose folios are also swap-backed (thus treated as anonymous for reclaim
> purposes).
>
> 3. MAP_PRIVATE-mapped /dev/zero - a strange beast whose VMAs have
> vma->vm_file set, but whose mmap_prepare callback clears vma->vm_ops to
> satisfy vma_is_anonymous(), which results in VMAs that were mmap()'d
> referencing a file, but are in every other sense anonymous, including the
> folios.
>
> 4. Other MAP_PRIVATE-file backed mappings - These possess file-backed VMAs
> and have file-backed folios until CoW'd, at which point those CoW'd
> folios are anonymous.
>
> This series fixes issues 3 and 4.
>
> In order for us to traverse VMAs using the reverse mapping, we require two
> fields - folio->mapping and folio->index. The first tells the rmap code
> where to look for VMAs, and the second tells it at which offset the folio
> starts within the referenced object.
>
> For anonymous folios, folio->mapping points at an anon_vma object. For
> file-backed folios, it points at an address_space. And:
>
> * For file-backed folios folio->index is simply the page offset of the start
> of the folio within the file.
>
> * For anonymous folios belonging to pure anon mappings, folio->index is
> equal to the virtual page offset of the folio.
>
> * For anonymous folios belonging to file-backed mappings (i.e. CoW'd folios
> of a MAP_PRIVATE file-backed mapping), folio->index is equal to the file
> page offset.
>
> This series establishes a new virtual page offset property of VMAs to
> allow us to map anonymous folios at their virtual page offset, consistent
> with pure anon.
As raised off-list, I consider the "virtual page offset" concept hard to grasp.
Maybe it's just me :)
Skimming over the code, I read "vmg->anon_pgoff", which is pretty intuitive to
me. Similarly vma_start_anon_pgoff() / vmg_end_anon_pgoff().
Could we similarly just call this "anon_pgoff" / "(linear) anon page index"
even on the VMA level.
IOW, in patch #9 for example:
static inline pgoff_t linear_folio_page_index(const struct folio *folio,
const struct vm_area_struct *vma,
const unsigned long address)
{
if (folio_test_anon(folio))
+ return linear_anon_page_index(vma, address);
+
return linear_page_index(vma, address);
}
Or is there another user for the the "virtual page offset" concept? I'd assume
it's only used for anon folios (including KSM), but maybe I am missing some
corner case.
--
Cheers,
David
next prev parent reply other threads:[~2026-07-27 14:44 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 14:38 [PATCH v2 00/15] mm/rmap: index MAP_PRIVATE file-backed folios by virt pgoff Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 01/15] mm/vma: introduce VMA virtual page offset field and add helpers Lorenzo Stoakes (ARM)
2026-07-20 15:49 ` Gregory Price
2026-07-20 16:56 ` Lorenzo Stoakes (ARM)
2026-07-20 17:26 ` Gregory Price
2026-07-27 12:03 ` Lorenzo Stoakes (ARM)
2026-07-25 8:08 ` xu.xin16
2026-07-20 14:38 ` [PATCH v2 02/15] mm: introduce linear_virt_page_index() Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 03/15] mm: abstract vma_address() and introduce vma_anon_address() Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 04/15] mm: update print_bad_page_map() to show virtual page index Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 05/15] mm: introduce and use vma_filebacked_address() Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 06/15] mm: propagate VMA virtual page offset on map, remap, split + merge Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 07/15] mm/rmap: track whether the page VMA mapped walk is anonymous Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 08/15] mm: introduce and use linear_folio_page_index() Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 09/15] mm/rmap: use virt pgoff for MAP_PRIVATE file-backed anon folios Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 10/15] tools/testing/vma: expand VMA merge tests to assert virt pgoff Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 11/15] tools/testing/selftests/mm: test virtual page offset merge behaviour Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 12/15] mm/vma: only permit MAP_PRIVATE /dev/zero to be mapped anonymous Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 13/15] mm/vma: make MAP_PRIVATE-mapped /dev/zero mappings truly anonymous Lorenzo Stoakes (ARM)
2026-07-27 11:48 ` Mark Brown
2026-07-27 12:03 ` Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 14/15] tools/testing/vma: add test to assert MAP_PRIVATE-/dev/zero is anon Lorenzo Stoakes (ARM)
2026-07-20 14:38 ` [PATCH v2 15/15] tools/testing/selftests/mm: add MAP_PRIVATE-/dev/zero merge tests Lorenzo Stoakes (ARM)
2026-07-20 19:48 ` [PATCH v2 00/15] mm/rmap: index MAP_PRIVATE file-backed folios by virt pgoff Andrew Morton
2026-07-27 12:04 ` Lorenzo Stoakes (ARM)
2026-07-27 14:44 ` David Hildenbrand (Arm) [this message]
2026-07-27 15:57 ` Lorenzo Stoakes (ARM)
2026-07-27 15:59 ` Matthew Wilcox
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=880981b5-ef79-4c9a-a8bd-7540002fcd15@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=arnd@arndb.de \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=byungchul@sk.com \
--cc=chengming.zhou@linux.dev \
--cc=dev.jain@arm.com \
--cc=gourry@gourry.net \
--cc=gregkh@linuxfoundation.org \
--cc=harry@kernel.org \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=joshua.hahnjy@gmail.com \
--cc=kees@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linmiaohe@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=matthew.brost@intel.com \
--cc=mhocko@suse.com \
--cc=nao.horiguchi@gmail.com \
--cc=npache@redhat.com \
--cc=peterx@redhat.com \
--cc=pfalcato@suse.de \
--cc=rakie.kim@sk.com \
--cc=riel@surriel.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=surenb@google.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=willy@infradead.org \
--cc=xu.xin16@zte.com.cn \
--cc=ying.huang@linux.alibaba.com \
--cc=ziy@nvidia.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