Re: [RFC PATCH v1 0/4] mm: port MADV_VOLATILE and MADV_NONVOLATILE to v7.3-rc1
From: Lorenzo Stoakes (ARM)
Date: Mon Nov 30 2026 - 13:18:30 EST
On Mon, Nov 30, 2026 at 11:39:45AM +0100, David Hildenbrand (Arm) wrote:
> On 11/30/26 09:34, Hirotaka Yamagata wrote:
>
> Hi,
>
> > This RFC series revives and modernizes the volatile ranges patchset
> > originally proposed by John Stultz and Minchan Kim [1].
> >
> > Volatile ranges allow userspace caches holding regenerable data (such as
> > decoded image bitmaps or other private caches) to mark private anonymous
> > memory as safe for the kernel to discard under memory pressure,
> > bypassing swap. Such ranges are marked via madvise(MADV_VOLATILE).
> > Before reusing the buffer, userspace calls madvise(MADV_NONVOLATILE),
> > which unmarks the range and returns 1 if any pages in the range were
> > purged while volatile (or 0 if all pages remained intact).
>
> We have MAP_DROPPABLE nowadays, I don't think we want more of that.
Yes exactly.
And also absolutely no to this pattern of:
1. Create an unnecessary new file for something
2. Redirect an MADV_xxx to that file, maybe some hooks
3. ???
4. the control of what the MADV_xxx does sits outside of madvise now.
>
> >
> > Unlike MADV_FREE, which silently zero-fills dropped pages on re-access,
> > calling MADV_NONVOLATILE before reuse gives userspace deterministic
> > notification of whether cached data was lost without having to touch
> > every page.
>
> We do have userfaultfd missing faults + rwp (read-write-protection). Can't we
> build something based on that instead?
>
> We currently disable uffd with MAP_DROPPABLE, but maybe there could be a use
> case for it. Of course, you can also build it based on MADV_FREE instead.
Well we'd need to have a compelling reason to combine the two I think :P
But in general agree with - check to see what tooling there is already before
making a big, invasive change to mm.
--
Cheers, Lorenzo