* [PATCH] powerpc/mm: simplify loop control in parse_numa_properties()
@ 2016-10-13 18:45 Reza Arbab
2016-10-14 0:33 ` Michael Ellerman
2017-02-01 1:05 ` Michael Ellerman
0 siblings, 2 replies; 4+ messages in thread
From: Reza Arbab @ 2016-10-13 18:45 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras; +Cc: linuxppc-dev
The flow of the main loop in parse_numa_properties() is overly
complicated. Simplify it to be less confusing and easier to read.
No functional change.
Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com>
---
arch/powerpc/mm/numa.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index d7ac419..b30ced8 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -786,14 +786,9 @@ new_range:
fake_numa_create_new_node(((start + size) >> PAGE_SHIFT), &nid);
node_set_online(nid);
- if (!(size = numa_enforce_memory_limit(start, size))) {
- if (--ranges)
- goto new_range;
- else
- continue;
- }
-
- memblock_set_node(start, size, &memblock.memory, nid);
+ size = numa_enforce_memory_limit(start, size);
+ if (size)
+ memblock_set_node(start, size, &memblock.memory, nid);
if (--ranges)
goto new_range;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc/mm: simplify loop control in parse_numa_properties()
2016-10-13 18:45 [PATCH] powerpc/mm: simplify loop control in parse_numa_properties() Reza Arbab
@ 2016-10-14 0:33 ` Michael Ellerman
2016-10-14 15:43 ` Reza Arbab
2017-02-01 1:05 ` Michael Ellerman
1 sibling, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2016-10-14 0:33 UTC (permalink / raw)
To: Reza Arbab, Benjamin Herrenschmidt, Paul Mackerras; +Cc: linuxppc-dev
Reza Arbab <arbab@linux.vnet.ibm.com> writes:
> The flow of the main loop in parse_numa_properties() is overly
> complicated. Simplify it to be less confusing and easier to read.
> No functional change.
I think you're right, but it's not obvious from the diff. Please explain
in more detail why the old and new code is equivalent.
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc/mm: simplify loop control in parse_numa_properties()
2016-10-14 0:33 ` Michael Ellerman
@ 2016-10-14 15:43 ` Reza Arbab
0 siblings, 0 replies; 4+ messages in thread
From: Reza Arbab @ 2016-10-14 15:43 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev
On Fri, Oct 14, 2016 at 11:33:12AM +1100, Michael Ellerman wrote:
>Reza Arbab <arbab@linux.vnet.ibm.com> writes:
>> The flow of the main loop in parse_numa_properties() is overly
>> complicated. Simplify it to be less confusing and easier to read.
>> No functional change.
>
>I think you're right, but it's not obvious from the diff. Please explain
>in more detail why the old and new code is equivalent.
I'm not sure if being this verbose helps, but...
The end of the main loop in parse_numa_properties() looks like this:
for_each_node_by_type(...) {
...
if (!condition) {
if (--ranges)
goto new_range;
else
continue;
}
statement();
if (--ranges)
goto new_range;
/* else
* continue; <- implicit, this is the end of the loop
*/
}
The only effect of !condition is to skip execution of statement(). This can be
rewritten in a simpler way:
for_each_node_by_type(...) {
...
if (condition)
statement();
if (--ranges)
goto new_range;
}
--
Reza Arbab
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: powerpc/mm: simplify loop control in parse_numa_properties()
2016-10-13 18:45 [PATCH] powerpc/mm: simplify loop control in parse_numa_properties() Reza Arbab
2016-10-14 0:33 ` Michael Ellerman
@ 2017-02-01 1:05 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2017-02-01 1:05 UTC (permalink / raw)
To: Reza Arbab, Benjamin Herrenschmidt, Paul Mackerras; +Cc: linuxppc-dev
On Thu, 2016-10-13 at 18:45:30 UTC, Reza Arbab wrote:
> The flow of the main loop in parse_numa_properties() is overly
> complicated. Simplify it to be less confusing and easier to read.
> No functional change.
>
> Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/7656cd8e8e23ac4b059f4d96939cb7
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-01 1:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-13 18:45 [PATCH] powerpc/mm: simplify loop control in parse_numa_properties() Reza Arbab
2016-10-14 0:33 ` Michael Ellerman
2016-10-14 15:43 ` Reza Arbab
2017-02-01 1:05 ` Michael Ellerman
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).