* [PATCH] mm/memblock.c: using judgment statement can reduce loop and enhance readability.
@ 2023-11-02 2:37 huanglllzu
2023-11-02 8:54 ` Mike Rapoport
0 siblings, 1 reply; 7+ messages in thread
From: huanglllzu @ 2023-11-02 2:37 UTC (permalink / raw)
To: linux-mm; +Cc: linux-kernel, akpm, rppt, Liangliang Huang, Liangliang Huang
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;
}
/* insert the remaining portion */
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/memblock.c: using judgment statement can reduce loop and enhance readability.
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 ` 黄亮亮
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Mike Rapoport @ 2023-11-02 8:54 UTC (permalink / raw)
To: huanglllzu; +Cc: linux-mm, linux-kernel, akpm, Liangliang Huang
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/memblock.c: using judgment statement can reduce loop and enhance readability.
2023-11-02 8:54 ` Mike Rapoport
@ 2023-11-03 3:19 ` 黄亮亮
2023-11-03 5:30 ` 黄亮亮
2023-11-03 5:31 ` 黄亮亮
2 siblings, 0 replies; 7+ messages in thread
From: 黄亮亮 @ 2023-11-03 3:19 UTC (permalink / raw)
To: Mike Rapoport; +Cc: linux-mm, linux-kernel, akpm, Liangliang Huang
[-- Attachment #1: Type: text/plain, Size: 1600 bytes --]
Hi, this patch can less loop once in this situation:
base more than rbase and end less than rend.
base end
rbase----|-------------| --------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: 2494 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/memblock.c: using judgment statement can reduce loop and enhance readability.
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 5:31 ` 黄亮亮
2 siblings, 1 reply; 7+ messages in thread
From: 黄亮亮 @ 2023-11-03 5:30 UTC (permalink / raw)
To: Mike Rapoport; +Cc: linux-mm, linux-kernel, akpm, Liangliang Huang
[-- Attachment #1: Type: text/plain, Size: 1598 bytes --]
Hi,this patch can less loop once in this situation:
base more than rbase and end less than rend.
base end
rbase-----|--------------|-------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: 2465 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/memblock.c: using judgment statement can reduce loop and enhance readability.
2023-11-02 8:54 ` Mike Rapoport
2023-11-03 3:19 ` 黄亮亮
2023-11-03 5:30 ` 黄亮亮
@ 2023-11-03 5:31 ` 黄亮亮
2 siblings, 0 replies; 7+ messages in thread
From: 黄亮亮 @ 2023-11-03 5:31 UTC (permalink / raw)
To: Mike Rapoport; +Cc: linux-mm, linux-kernel, akpm, Liangliang Huang
[-- 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 --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/memblock.c: using judgment statement can reduce loop and enhance readability.
2023-11-03 5:30 ` 黄亮亮
@ 2023-11-03 7:34 ` Mike Rapoport
2023-11-03 8:21 ` 黄亮亮
0 siblings, 1 reply; 7+ messages in thread
From: Mike Rapoport @ 2023-11-03 7:34 UTC (permalink / raw)
To: 黄亮亮; +Cc: linux-mm, linux-kernel, akpm, Liangliang Huang
On Fri, Nov 03, 2023 at 01:30:21PM +0800, 黄亮亮 wrote:
> Hi,this patch can less loop once in this situation:
> base more than rbase and end less than rend.
> base end
> rbase-----|--------------|-------rend
> | | | |
> -------------------------------------------------------->
The loop won't be executed anyway because there's similar condition in the
beginning of the loop.
Next time when you reply to the kernel mailing lists, please don't top post
and make sure your reply is text-only.
And there is no need to send 4 badly formatted replies.
> 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.
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/memblock.c: using judgment statement can reduce loop and enhance readability.
2023-11-03 7:34 ` Mike Rapoport
@ 2023-11-03 8:21 ` 黄亮亮
0 siblings, 0 replies; 7+ messages in thread
From: 黄亮亮 @ 2023-11-03 8:21 UTC (permalink / raw)
To: Mike Rapoport; +Cc: linux-mm, linux-kernel, akpm, Liangliang Huang
[-- Attachment #1: Type: text/plain, Size: 2388 bytes --]
Mike Rapoport <rppt@kernel.org> 于2023年11月3日周五 15:35写道:
> On Fri, Nov 03, 2023 at 01:30:21PM +0800, 黄亮亮 wrote:
> > Hi,this patch can less loop once in this situation:
> > base more than rbase and end less than rend.
> > base end
> > rbase-----|--------------|-------rend
> > | | | |
> > -------------------------------------------------------->
>
> The loop won't be executed anyway because there's similar condition in the
> beginning of the loop.
>
> Next time when you reply to the kernel mailing lists, please don't top post
> and make sure your reply is text-only.
>
> And there is no need to send 4 badly formatted replies.
>
> > 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.
> >
>
> --
> Sincerely yours,
> Mike.
>
I get your meanings, thanks.
[-- Attachment #2: Type: text/html, Size: 3611 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-11-03 8:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).