From: 黄亮亮 <huanglllzu@gmail.com>
To: Mike Rapoport <rppt@kernel.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, Liangliang Huang <huangll@lemote.com>
Subject: Re: [PATCH] mm/memblock.c: using judgment statement can reduce loop and enhance readability.
Date: Fri, 3 Nov 2023 13:31:38 +0800 [thread overview]
Message-ID: <CAOneMZXbN_FtCN3mCxpRV_2bq7jEDjPBaLwDuD8WmWxXGNhiCQ@mail.gmail.com> (raw)
In-Reply-To: <20231102085418.GM2824@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 1408 bytes --]
Hi,this patch can less loop once in this situation:
base more than rbase and end less than rend.
Mike Rapoport <rppt@kernel.org> 于2023年11月2日周四 16:54写道:
> Hi,
>
> > Subject: [PATCH] mm/memblock.c: using judgment statement can reduce loop
> and enhance readability.
>
> I disagree.
>
> On Thu, Nov 02, 2023 at 10:37:10AM +0800, huanglllzu@gmail.com wrote:
> > From: Liangliang Huang <huangll@lemote.com>
> >
> > Signed-off-by: Liangliang Huang <huangll@lemote.com>
> > ---
> > mm/memblock.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/mm/memblock.c b/mm/memblock.c
> > index 913b2520a9a0..e48dea7144bb 100644
> > --- a/mm/memblock.c
> > +++ b/mm/memblock.c
> > @@ -655,7 +655,11 @@ static int __init_memblock
> memblock_add_range(struct memblock_type *type,
> > }
> > }
> > /* area below @rend is dealt with, forget about it */
> > - base = min(rend, end);
> > + if (end < rend) {
> > + base = end;
> > + break;
> > + } else
> > + base = rend;
>
> min() is perfectly clear and there no change in number of iterations of the
> loop.
>
> > }
> >
> > /* insert the remaining portion */
> > --
> > 2.25.1
> >
>
> --
> Sincerely yours,
> Mike.
>
[-- Attachment #2: Type: text/html, Size: 2179 bytes --]
prev parent reply other threads:[~2023-11-03 5:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-02 2:37 [PATCH] mm/memblock.c: using judgment statement can reduce loop and enhance readability huanglllzu
2023-11-02 8:54 ` Mike Rapoport
2023-11-03 3:19 ` 黄亮亮
2023-11-03 5:30 ` 黄亮亮
2023-11-03 7:34 ` Mike Rapoport
2023-11-03 8:21 ` 黄亮亮
2023-11-03 5:31 ` 黄亮亮 [this message]
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=CAOneMZXbN_FtCN3mCxpRV_2bq7jEDjPBaLwDuD8WmWxXGNhiCQ@mail.gmail.com \
--to=huanglllzu@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=huangll@lemote.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).