Re: [PATCH mm-new v8 4/4] mm: khugepaged: skip lazy-free folios
From: David Hildenbrand (Arm)
Date: Tue Feb 24 2026 - 05:14:54 EST
On 2/23/26 21:08, Barry Song wrote:
> On Mon, Feb 23, 2026 at 9:16 PM David Hildenbrand (Arm)
> <david@xxxxxxxxxx> wrote:
>>
>> On 2/21/26 14:38, Vernon Yang wrote:
>>>
>>> In folio_add_new_anon_rmap(), we know that the vma has the VM_DROPPABLE
>>> attribute, which is the root reason why Collapsing maintains that property.
>>> The above commit log clearly states "all folios in VM_DROPPABLE are lazyfree"
>>> ^^^^^^^^^^^^^^^
>>> (the "if" is redundant and should be removed), not "all folios are lazyfree".
>>
>>
>> Exactly. folio_add_new_anon_rmap() makes sure that all folios (except
>> the shared zero folios ;) ) in VM_DROPPABLE are lazyfree.
>>
>> In fact, MADV_FREE should be a NOP on VM_DROPPABLE, as
>> folio_mark_lazyfree() doesn't do anything.
>>
>
> Maybe we could do something like the following?
>
> diff --git a/mm/madvise.c b/mm/madvise.c
> index c0370d9b4e23..173b0e5308b5 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
> @@ -817,6 +817,11 @@ static int madvise_free_single_vma(struct
> madvise_behavior *madv_behavior)
> range.end = min(vma->vm_end, end_addr);
> if (range.end <= vma->vm_start)
> return -EINVAL;
> +
> + /* All folios in the VM_DROPPABLE VMA are already lazyfree */
> + if (vma->vm_flags & VM_DROPPABLE)
> + return 0;
We could, but it feels like optimizing for a case that likely nobody
triggers :)
--
Cheers,
David