Re: [PATCH v2 13/15] mm/vma: make MAP_PRIVATE-mapped /dev/zero mappings truly anonymous
From: Lorenzo Stoakes (ARM)
Date: Tue Jul 28 2026 - 09:44:37 EST
On Mon, Jul 27, 2026 at 02:26:32PM -0700, Yang Shi wrote:
> On Mon, Jul 20, 2026 at 8:30 AM Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx> wrote:
> >
> > When mapping /dev/zero with MAP_PRIVATE, one ends up with strange VMAs
> > originating from Linux's distant past.
> >
> > These have vma->vm_file set but NULL vma->vm_ops, meaning they satisfy
> > vma_is_anonymous() but otherwise resemble a file-backed VMA.
> >
> > The introduction of virtual page offsets and their subsequent use as
> > indexes for MAP_PRIVATE-file-backed mappings mean the rmap does the right
> > thing with these but we are left with inconsistencies.
> >
> > The vma_start_pgoff(vma) == vma_start_virt_pgoff(vma) invariant is true for
> > all other anonymous VMAs, but not these.
> >
> > These VMAs are also observable as files in /proc/<pid>/[s]maps but
> > otherwise behave like anonymous mappings.
> >
> > Therefore let's make these VMAs actually anonymous at mapping time which
> > will activate the anonymous code path for mappings.
> >
> > This means we no longer have to account for this discrepancy anywhere and
> > no longer have to think about these at all.
>
> I'm glad to see this is solved finally. But /proc/<pid>/smaps will not
> show /dev/zero anymore. It is user visible. I recalled you were
> concerned about it before.
> https://lore.kernel.org/linux-mm/c98f68c1-4bfd-4410-9b65-1eb5a1efe271@lucifer.local/
Well I mean they'll show but just as anon ranges so only disappear in that sense
which I think is what you mean of course!
But yeah I guess over time I've become less concerned about this side of it and
a lot more about the patent absurdity of this situation as-is :)
(Cringing at my facehugger analogy we all learn and develop on here don't we :)
>
> Anyway I don't think it is a big deal. It should be harmless. I would
> be surprised any real life workload would care whether the anonymous
> mapping is backed by /dev/zero or not in 2026.
Yeah exactly.
I was kinda hinting at this in the commit message with:
The impact of this change should be low as likely very few are relying upon
this in any case, and in using them are asking for anonymous memory, so no
longer seeing these as file mappings in smaps should have no meaningful
impact.
But perhaps I can be a little more explicit on respin!
>
> Thanks,
> Yang
Cheers, Lorenzo