Re: [PATCH v2] mm/mremap: Don't account pages in vma_to_resize()

From: Dmitry Safonov
Date: Wed Jul 21 2021 - 16:18:36 EST


On 7/21/21 9:08 PM, Dmitry Safonov wrote:
> On 7/21/21 9:05 PM, Andrew Morton wrote:
>> On Wed, 21 Jul 2021 14:21:54 +0100 Dmitry Safonov <0x7f454c46@xxxxxxxxx> wrote:
>>
>>>> Let's not do this.
>>>> Account memory in mremap() fast-path for growing VMAs or in move_vma()
>>>> for actually moving things. The same simpler way as it's done by
>>>> vm_stat_account(), but with a difference to call
>>>> security_vm_enough_memory_mm() before copying/adjusting VMA.
>>>>
>>>> Originally noticed by Chen Wandun:
>>>> https://lkml.kernel.org/r/20210717101942.120607-1-chenwandun@xxxxxxxxxx
>>>
>>> The patch by Chen Wandun still makes sense with this v2.
>>> Heh :-)
>>
>> Should
>> https://lkml.kernel.org/r/20210717101942.120607-1-chenwandun@xxxxxxxxxx
>> still be applied then? Did you ack it?
>>
>
> Yes, please keep that patch with
> Acked-by: Dmitry Safonov <dima@xxxxxxxxxx>
>
> This one comes on the top to correct accounting for MREMAP_DONTUNMAP.

Please, also wait for reviews for this one.
I think it's correct and simplifies the complex code, but now I look
into the code again, I see that:
: /*
: * MREMAP_DONTUNMAP is always a move and it does not allow resizing
: * in the process.
: */
: if (flags & MREMAP_DONTUNMAP &&
: (!(flags & MREMAP_MAYMOVE) || old_len != new_len))
: return ret;

So, this part can be dropped:
> Fixes: e346b3813067 ("mm/mremap: add MREMAP_DONTUNMAP to mremap()")

But I think the patch still makes sense.

Brian, can I have your review on it?

Thanks,
Dmitry