* [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func()
@ 2018-03-26 8:19 Wei Yang
2018-03-26 8:19 ` [PATCH 2/2] mm/sparse: check __highest_present_section_nr only for a present section Wei Yang
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Wei Yang @ 2018-03-26 8:19 UTC (permalink / raw)
To: dave.hansen, akpm, mhocko; +Cc: linux-mm, Wei Yang
In 'commit c4e1be9ec113 ("mm, sparsemem: break out of loops early")',
__highest_present_section_nr is introduced to reduce the loop counts for
present section. This is also helpful for usemap and memmap allocation.
This patch uses __highest_present_section_nr + 1 to optimize the loop.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
mm/sparse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/sparse.c b/mm/sparse.c
index 7af5e7a92528..505050346249 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -561,7 +561,7 @@ static void __init alloc_usemap_and_memmap(void (*alloc_func)
map_count = 1;
}
/* ok, last chunk */
- alloc_func(data, pnum_begin, NR_MEM_SECTIONS,
+ alloc_func(data, pnum_begin, __highest_present_section_nr+1,
map_count, nodeid_begin);
}
--
2.15.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] mm/sparse: check __highest_present_section_nr only for a present section
2018-03-26 8:19 [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func() Wei Yang
@ 2018-03-26 8:19 ` Wei Yang
2018-03-30 3:20 ` [PATCH] mm: check __highest_present_sectioin_nr directly in memory_dev_init() Wei Yang
2018-03-26 20:56 ` [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func() David Rientjes
2018-04-12 3:26 ` Wei Yang
2 siblings, 1 reply; 10+ messages in thread
From: Wei Yang @ 2018-03-26 8:19 UTC (permalink / raw)
To: dave.hansen, akpm, mhocko; +Cc: linux-mm, Wei Yang
When searching a present section, there are two boundaries:
* __highest_present_section_nr
* NR_MEM_SECTIONS
And it is konwn, __highest_present_section_nr is a more strict boundary
than NR_MEM_SECTIONS. This means it would be necessary to check
__highest_present_section_nr only.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
mm/sparse.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/mm/sparse.c b/mm/sparse.c
index 505050346249..b6560029a16c 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -190,15 +190,13 @@ static inline int next_present_section_nr(int section_nr)
section_nr++;
if (present_section_nr(section_nr))
return section_nr;
- } while ((section_nr < NR_MEM_SECTIONS) &&
- (section_nr <= __highest_present_section_nr));
+ } while ((section_nr <= __highest_present_section_nr));
return -1;
}
#define for_each_present_section_nr(start, section_nr) \
for (section_nr = next_present_section_nr(start-1); \
((section_nr >= 0) && \
- (section_nr < NR_MEM_SECTIONS) && \
(section_nr <= __highest_present_section_nr)); \
section_nr = next_present_section_nr(section_nr))
--
2.15.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func()
2018-03-26 8:19 [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func() Wei Yang
2018-03-26 8:19 ` [PATCH 2/2] mm/sparse: check __highest_present_section_nr only for a present section Wei Yang
@ 2018-03-26 20:56 ` David Rientjes
2018-03-26 22:30 ` Wei Yang
2018-04-12 3:26 ` Wei Yang
2 siblings, 1 reply; 10+ messages in thread
From: David Rientjes @ 2018-03-26 20:56 UTC (permalink / raw)
To: Wei Yang; +Cc: dave.hansen, akpm, mhocko, linux-mm
On Mon, 26 Mar 2018, Wei Yang wrote:
> In 'commit c4e1be9ec113 ("mm, sparsemem: break out of loops early")',
> __highest_present_section_nr is introduced to reduce the loop counts for
> present section. This is also helpful for usemap and memmap allocation.
>
> This patch uses __highest_present_section_nr + 1 to optimize the loop.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
> mm/sparse.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/sparse.c b/mm/sparse.c
> index 7af5e7a92528..505050346249 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -561,7 +561,7 @@ static void __init alloc_usemap_and_memmap(void (*alloc_func)
> map_count = 1;
> }
> /* ok, last chunk */
> - alloc_func(data, pnum_begin, NR_MEM_SECTIONS,
> + alloc_func(data, pnum_begin, __highest_present_section_nr+1,
> map_count, nodeid_begin);
> }
>
What happens if s/NR_MEM_SECTIONS/pnum/?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func()
2018-03-26 20:56 ` [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func() David Rientjes
@ 2018-03-26 22:30 ` Wei Yang
2018-03-26 22:47 ` David Rientjes
0 siblings, 1 reply; 10+ messages in thread
From: Wei Yang @ 2018-03-26 22:30 UTC (permalink / raw)
To: David Rientjes; +Cc: Wei Yang, dave.hansen, akpm, mhocko, linux-mm
On Mon, Mar 26, 2018 at 01:56:50PM -0700, David Rientjes wrote:
>On Mon, 26 Mar 2018, Wei Yang wrote:
>
>> In 'commit c4e1be9ec113 ("mm, sparsemem: break out of loops early")',
>> __highest_present_section_nr is introduced to reduce the loop counts for
>> present section. This is also helpful for usemap and memmap allocation.
>>
>> This patch uses __highest_present_section_nr + 1 to optimize the loop.
>>
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> ---
>> mm/sparse.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/sparse.c b/mm/sparse.c
>> index 7af5e7a92528..505050346249 100644
>> --- a/mm/sparse.c
>> +++ b/mm/sparse.c
>> @@ -561,7 +561,7 @@ static void __init alloc_usemap_and_memmap(void (*alloc_func)
>> map_count = 1;
>> }
>> /* ok, last chunk */
>> - alloc_func(data, pnum_begin, NR_MEM_SECTIONS,
>> + alloc_func(data, pnum_begin, __highest_present_section_nr+1,
>> map_count, nodeid_begin);
>> }
>>
>
>What happens if s/NR_MEM_SECTIONS/pnum/?
I have tried this :-)
The last pnum is -1 from next_present_section_nr().
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func()
2018-03-26 22:30 ` Wei Yang
@ 2018-03-26 22:47 ` David Rientjes
2018-03-26 22:56 ` Wei Yang
0 siblings, 1 reply; 10+ messages in thread
From: David Rientjes @ 2018-03-26 22:47 UTC (permalink / raw)
To: Wei Yang; +Cc: dave.hansen, akpm, mhocko, linux-mm
On Tue, 27 Mar 2018, Wei Yang wrote:
> >> In 'commit c4e1be9ec113 ("mm, sparsemem: break out of loops early")',
> >> __highest_present_section_nr is introduced to reduce the loop counts for
> >> present section. This is also helpful for usemap and memmap allocation.
> >>
> >> This patch uses __highest_present_section_nr + 1 to optimize the loop.
> >>
> >> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> >> ---
> >> mm/sparse.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/mm/sparse.c b/mm/sparse.c
> >> index 7af5e7a92528..505050346249 100644
> >> --- a/mm/sparse.c
> >> +++ b/mm/sparse.c
> >> @@ -561,7 +561,7 @@ static void __init alloc_usemap_and_memmap(void (*alloc_func)
> >> map_count = 1;
> >> }
> >> /* ok, last chunk */
> >> - alloc_func(data, pnum_begin, NR_MEM_SECTIONS,
> >> + alloc_func(data, pnum_begin, __highest_present_section_nr+1,
> >> map_count, nodeid_begin);
> >> }
> >>
> >
> >What happens if s/NR_MEM_SECTIONS/pnum/?
>
> I have tried this :-)
>
> The last pnum is -1 from next_present_section_nr().
>
Lol. I think it would make more sense for the second patch to come before
the first, but feel free to add
Acked-by: David Rientjes <rientjes@google.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func()
2018-03-26 22:47 ` David Rientjes
@ 2018-03-26 22:56 ` Wei Yang
2018-03-26 22:58 ` David Rientjes
0 siblings, 1 reply; 10+ messages in thread
From: Wei Yang @ 2018-03-26 22:56 UTC (permalink / raw)
To: David Rientjes; +Cc: Wei Yang, dave.hansen, akpm, mhocko, linux-mm
On Mon, Mar 26, 2018 at 03:47:03PM -0700, David Rientjes wrote:
>On Tue, 27 Mar 2018, Wei Yang wrote:
>
>> >> In 'commit c4e1be9ec113 ("mm, sparsemem: break out of loops early")',
>> >> __highest_present_section_nr is introduced to reduce the loop counts for
>> >> present section. This is also helpful for usemap and memmap allocation.
>> >>
>> >> This patch uses __highest_present_section_nr + 1 to optimize the loop.
>> >>
>> >> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> >> ---
>> >> mm/sparse.c | 2 +-
>> >> 1 file changed, 1 insertion(+), 1 deletion(-)
>> >>
>> >> diff --git a/mm/sparse.c b/mm/sparse.c
>> >> index 7af5e7a92528..505050346249 100644
>> >> --- a/mm/sparse.c
>> >> +++ b/mm/sparse.c
>> >> @@ -561,7 +561,7 @@ static void __init alloc_usemap_and_memmap(void (*alloc_func)
>> >> map_count = 1;
>> >> }
>> >> /* ok, last chunk */
>> >> - alloc_func(data, pnum_begin, NR_MEM_SECTIONS,
>> >> + alloc_func(data, pnum_begin, __highest_present_section_nr+1,
>> >> map_count, nodeid_begin);
>> >> }
>> >>
>> >
>> >What happens if s/NR_MEM_SECTIONS/pnum/?
>>
>> I have tried this :-)
>>
>> The last pnum is -1 from next_present_section_nr().
>>
>
>Lol. I think it would make more sense for the second patch to come before
>the first, but feel free to add
>
Thanks for your comment.
Do I need to reorder the patch and send v2?
>Acked-by: David Rientjes <rientjes@google.com>
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func()
2018-03-26 22:56 ` Wei Yang
@ 2018-03-26 22:58 ` David Rientjes
2018-03-26 23:15 ` Wei Yang
0 siblings, 1 reply; 10+ messages in thread
From: David Rientjes @ 2018-03-26 22:58 UTC (permalink / raw)
To: Wei Yang; +Cc: dave.hansen, akpm, mhocko, linux-mm
On Tue, 27 Mar 2018, Wei Yang wrote:
> >Lol. I think it would make more sense for the second patch to come before
> >the first
>
> Thanks for your comment.
>
> Do I need to reorder the patch and send v2?
>
I think we can just ask Andrew to apply backwards, but it's not crucial.
The ordering of patch 2 before patch 1 simply helped me to understand the
boundaries better.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func()
2018-03-26 22:58 ` David Rientjes
@ 2018-03-26 23:15 ` Wei Yang
0 siblings, 0 replies; 10+ messages in thread
From: Wei Yang @ 2018-03-26 23:15 UTC (permalink / raw)
To: David Rientjes; +Cc: Wei Yang, dave.hansen, akpm, mhocko, linux-mm
On Mon, Mar 26, 2018 at 03:58:28PM -0700, David Rientjes wrote:
>On Tue, 27 Mar 2018, Wei Yang wrote:
>
>> >Lol. I think it would make more sense for the second patch to come before
>> >the first
>>
>> Thanks for your comment.
>>
>> Do I need to reorder the patch and send v2?
>>
>
>I think we can just ask Andrew to apply backwards, but it's not crucial.
>The ordering of patch 2 before patch 1 simply helped me to understand the
>boundaries better.
Ah, got it.
Actually, the original order is what you expected. While for some mysterious
reasons, I reordered them :-(
Maybe you are right, it would be more easy to understand with patch 2 before
patch 1. :-)
Have a good day~
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] mm: check __highest_present_sectioin_nr directly in memory_dev_init()
2018-03-26 8:19 ` [PATCH 2/2] mm/sparse: check __highest_present_section_nr only for a present section Wei Yang
@ 2018-03-30 3:20 ` Wei Yang
0 siblings, 0 replies; 10+ messages in thread
From: Wei Yang @ 2018-03-30 3:20 UTC (permalink / raw)
To: dave.hansen, akpm, mhocko, rientjes; +Cc: linux-mm, Wei Yang
__highest_present_section_nr is a more strict boundary than
NR_MEM_SECTIONS. So check __highest_present_sectioin_nr directly is enough.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
drivers/base/memory.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index fe4b24f05f6a..e79e3361f632 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -833,11 +833,8 @@ int __init memory_dev_init(void)
* during boot and have been initialized
*/
mutex_lock(&mem_sysfs_mutex);
- for (i = 0; i < NR_MEM_SECTIONS; i += sections_per_block) {
- /* Don't iterate over sections we know are !present: */
- if (i > __highest_present_section_nr)
- break;
-
+ for (i = 0; i <= __highest_present_section_nr;
+ i += sections_per_block) {
err = add_memory_block(i);
if (!ret)
ret = err;
--
2.15.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func()
2018-03-26 8:19 [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func() Wei Yang
2018-03-26 8:19 ` [PATCH 2/2] mm/sparse: check __highest_present_section_nr only for a present section Wei Yang
2018-03-26 20:56 ` [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func() David Rientjes
@ 2018-04-12 3:26 ` Wei Yang
2 siblings, 0 replies; 10+ messages in thread
From: Wei Yang @ 2018-04-12 3:26 UTC (permalink / raw)
To: akpm; +Cc: dave.hansen, Wei Yang, mhocko, linux-mm
Hi, Andrew
I saw you merged one related patch recently, not sure you would take these two?
On Mon, Mar 26, 2018 at 04:19:55PM +0800, Wei Yang wrote:
>In 'commit c4e1be9ec113 ("mm, sparsemem: break out of loops early")',
>__highest_present_section_nr is introduced to reduce the loop counts for
>present section. This is also helpful for usemap and memmap allocation.
>
>This patch uses __highest_present_section_nr + 1 to optimize the loop.
>
>Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>---
> mm/sparse.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/mm/sparse.c b/mm/sparse.c
>index 7af5e7a92528..505050346249 100644
>--- a/mm/sparse.c
>+++ b/mm/sparse.c
>@@ -561,7 +561,7 @@ static void __init alloc_usemap_and_memmap(void (*alloc_func)
> map_count = 1;
> }
> /* ok, last chunk */
>- alloc_func(data, pnum_begin, NR_MEM_SECTIONS,
>+ alloc_func(data, pnum_begin, __highest_present_section_nr+1,
> map_count, nodeid_begin);
> }
>
>--
>2.15.1
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-04-12 3:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-26 8:19 [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func() Wei Yang
2018-03-26 8:19 ` [PATCH 2/2] mm/sparse: check __highest_present_section_nr only for a present section Wei Yang
2018-03-30 3:20 ` [PATCH] mm: check __highest_present_sectioin_nr directly in memory_dev_init() Wei Yang
2018-03-26 20:56 ` [PATCH 1/2] mm/sparse: pass the __highest_present_section_nr + 1 to alloc_func() David Rientjes
2018-03-26 22:30 ` Wei Yang
2018-03-26 22:47 ` David Rientjes
2018-03-26 22:56 ` Wei Yang
2018-03-26 22:58 ` David Rientjes
2018-03-26 23:15 ` Wei Yang
2018-04-12 3:26 ` Wei Yang
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).