linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	akpm@linux-foundation.org, Liam.Howlett@oracle.com,
	vbabka@suse.cz, jannh@google.com, linux-mm@kvack.org
Subject: Re: [PATCH] mm/vma: check retry_merge only for new vma case
Date: Tue, 19 Nov 2024 00:59:23 +0000	[thread overview]
Message-ID: <20241119005923.jgaunkxm6od54gil@master> (raw)
In-Reply-To: <7e550e5d-88f7-4407-91e5-2b4ae177b05e@lucifer.local>

On Mon, Nov 18, 2024 at 12:52:48PM +0000, Lorenzo Stoakes wrote:
>On Mon, Nov 18, 2024 at 12:34:39PM +0000, Wei Yang wrote:
>> On Mon, Nov 18, 2024 at 10:04:44AM +0000, Lorenzo Stoakes wrote:
>> >On Mon, Nov 18, 2024 at 02:18:23AM +0000, Wei Yang wrote:
>> >> Current code logic looks like this:
>> >>
>> >> __mmap_region()
>> >>   vma = vma_merge_new_range(&vmg)
>> >>   if (!vma)
>> >>     __mmap_new_vma(&map, &vma)
>> >>       __mmap_new_file_vma(map, vma)
>> >>         map->retry_merge = xxx               --- (1)
>> >>   if (map.retry_merge)
>> >>     vma_merge_existing_range(vmg, &map, vma)
>> >>
>> >> Location (1) is the only place where map.retry_merge is set, this means
>> >> it is not necessary to check it if already merged with adjacent vma.
>> >>
>> >> Let's move the check and following operation into new vma case.
>> >>
>> >> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> >
>> >Nack.
>> >
>> >As I said to you in another patch, the aim isn't to find the mathematically
>> >smallest size of patch. The aim is to keep things readable and nesting
>> >things like this works against that aim.
>> >
>>
>> IMHO, by nesting it, readers will notice this case only happens for new vma
>> case. So we don't need to retry if vma_merge_new_range() succeed.
>
>By this logic we should not split up the functions any more, because the
>reader won't know that it's only if you create a new VMA AND it's
>file-backed AND that succeeded AND etc. etc. etc.
>
>So by your logic, we should undo every refactoring here since we need the
>reader to understand precisely the conditions under which this can occur
>right?
>
>Or where do we stop? Because now it's 'misleading' to imply it might always
>happen in this situation without stipulating that there are other
>conditions?
>
>Do you see how this breaks down?
>
>We encapsulate the circumstances under which a retry_merge occurs, using
>the map.retry_merge variable. That's it.
>
>It's simple, it documents itself, and a reader wishing to know when this
>happens can very easily find out.
>
>The purpose of this code is - again - not to be as small as possible or to
>avoid all possible branches (unless perf numbers guide us to do so) - it's
>to be readable.
>
>In the original refactoring I can see:
>
>- prepare for mmap
>- try to merge
>- if merge failed, create new
>- maybe do a deferred merge
>- mmap complete, do 'after mmap' tasks.

Thanks for your explanation. This looks neat.

So it hide the reason of deferred merge from user, we would think both two
cases would lead to a deferred merge. This is what we want to have, right?

>
>In your proposed code I see:
>
>- prepare for mmap
>- try to merge
>- if merge failed, create new
>  - if merge failed, created new, and we required a deferred merge, do a deferred merge

Maybe here is

   - maybe do a deferred merge

>- mmap complete, do 'after mmap' tasks.
>
>It's about humans reading this and being able to understand what is going
>on.
>
-- 
Wei Yang
Help you, Help me


  reply	other threads:[~2024-11-19  0:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-18  2:18 Wei Yang
2024-11-18  3:56 ` Liam R. Howlett
2024-11-18  9:31   ` Wei Yang
2024-11-18 10:06     ` Lorenzo Stoakes
2024-11-18 10:04 ` Lorenzo Stoakes
2024-11-18 12:34   ` Wei Yang
2024-11-18 12:52     ` Lorenzo Stoakes
2024-11-19  0:59       ` Wei Yang [this message]
2024-11-19 10:14         ` Lorenzo Stoakes

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=20241119005923.jgaunkxm6od54gil@master \
    --to=richard.weiyang@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=jannh@google.com \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=vbabka@suse.cz \
    /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