From: linmiaohe <linmiaohe@huawei.com>
To: John Hubbard <jhubbard@nvidia.com>,
David Hildenbrand <david@redhat.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"richardw.yang@linux.intel.com" <richardw.yang@linux.intel.com>,
"sfr@canb.auug.org.au" <sfr@canb.auug.org.au>,
"rppt@linux.ibm.com" <rppt@linux.ibm.com>,
"jannh@google.com" <jannh@google.com>,
"steve.capper@arm.com" <steve.capper@arm.com>,
"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
"aarcange@redhat.com" <aarcange@redhat.com>,
"chenjianhong2@huawei.com" <chenjianhong2@huawei.com>,
"walken@google.com" <walken@google.com>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"tiny.windzz@gmail.com" <tiny.windzz@gmail.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: get rid of odd jump label in find_mergeable_anon_vma
Date: Mon, 18 Nov 2019 03:14:43 +0000 [thread overview]
Message-ID: <41506f6d6af44a7e937b0e56642bd9e7@huawei.com> (raw)
> On 11/15/19 4:58 AM, David Hildenbrand wrote:
>> On 15.11.19 07:36, linmiaohe wrote:
>>> From: Miaohe Lin <linmiaohe@huawei.com>
>>
>> I'm pro removing unnecessary jump labels.
>
>Thank you, simpler code is good--all other things being equal.
>The tradeoff is, as Qian points out: code churn and risk in critical code paths.
>
>In this case, I'd claim it's OK to improve this one, because we can likely get it right by visual inspection, and the pre-existing code is quite poor. And being in the kernel does not necessarily give weak code a free pass to remain there and incur maintenance and annoyance costs until the end of time. :)
>
>However, please spend equal time when you write your commit descriptions, because that's also very important. Commit logs should also be clear!
>
>>
>> Subject: "mm: get rid of jump labels in find_mergeable_anon_vma()"
>>
>>>
>>> The odd jump label try_prev and none is not really need
>
>s/need/needed/
>
>>
>> s/odd jump label/jump labels/
>>
>> s/is/are/
>>
>>> in func find_mergeable_anon_vma, eliminate them to improve
>>> readability.
>>>
>>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>>> ---
>>> mm/mmap.c | 18 +++++++-----------
>>> 1 file changed, 7 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/mm/mmap.c b/mm/mmap.c
>>> index 4d4db76a07da..ab980d468a10 100644
>>
>> Let me suggest the following instead:
>>
>> /* Try next first */
>> near = vma->vm_next;
>> if (near) {
>> anon_vma = reusable_anon_vma(near, vma, near);
>> if (anon_vma)
>> return anon_vma;
>> }
>> /* Try prev next */
>> near = vma->vm_prev;
>> if (near) {
>> anon_vma = reusable_anon_vma(near, vma, near);
>> if (anon_vma)
>> return anon_vma;
>> }
>>
>
>Actually, it can be further simplified, because you don't need that last "if" statement, because you're returning NULL after this.
>
>So just return anon_vma there. (And adjust the comment block at the end, so that it's clear that anon_vma might be null.)
>
>
Many Thanks for all of your precious advice. I will fix my patch and send a v2 patch. Thanks again.
next reply other threads:[~2019-11-18 3:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-18 3:14 linmiaohe [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-11-15 6:36 linmiaohe
2019-11-15 11:49 ` Qian Cai
2019-11-15 12:58 ` David Hildenbrand
2019-11-15 23:38 ` John Hubbard
2019-11-16 0:37 ` Wei Yang
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=41506f6d6af44a7e937b0e56642bd9e7@huawei.com \
--to=linmiaohe@huawei.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=chenjianhong2@huawei.com \
--cc=dave.hansen@linux.intel.com \
--cc=david@redhat.com \
--cc=jannh@google.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=richardw.yang@linux.intel.com \
--cc=rppt@linux.ibm.com \
--cc=sfr@canb.auug.org.au \
--cc=steve.capper@arm.com \
--cc=tiny.windzz@gmail.com \
--cc=walken@google.com \
/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