* [PATCH 1/2] mmzone: simplify zone_intersects()
@ 2017-06-16 9:23 Wei Yang
2017-06-16 9:23 ` [PATCH 2/2] mm/memory_hotplug: remove duplicate call for set_page_links Wei Yang
2017-06-18 16:59 ` [PATCH 1/2] mmzone: simplify zone_intersects() Michal Hocko
0 siblings, 2 replies; 6+ messages in thread
From: Wei Yang @ 2017-06-16 9:23 UTC (permalink / raw)
To: mhocko; +Cc: linux-mm, akpm, Wei Yang
To make sure a range intersects a zone, only two comparison is necessary.
This patch simplifies the function a little.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
include/linux/mmzone.h | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 0176a2933c61..7e8f100cb56d 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -541,15 +541,11 @@ static inline bool zone_intersects(struct zone *zone,
{
if (zone_is_empty(zone))
return false;
- if (start_pfn >= zone_end_pfn(zone))
+ if (start_pfn >= zone_end_pfn(zone) ||
+ start_pfn + nr_pages <= zone->zone_start_pfn)
return false;
- if (zone->zone_start_pfn <= start_pfn)
- return true;
- if (start_pfn + nr_pages > zone->zone_start_pfn)
- return true;
-
- return false;
+ return true;
}
/*
--
2.11.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] mm/memory_hotplug: remove duplicate call for set_page_links
2017-06-16 9:23 [PATCH 1/2] mmzone: simplify zone_intersects() Wei Yang
@ 2017-06-16 9:23 ` Wei Yang
2017-06-16 17:33 ` Andrew Morton
2017-06-18 16:59 ` [PATCH 1/2] mmzone: simplify zone_intersects() Michal Hocko
1 sibling, 1 reply; 6+ messages in thread
From: Wei Yang @ 2017-06-16 9:23 UTC (permalink / raw)
To: mhocko; +Cc: linux-mm, akpm, Wei Yang
In function move_pfn_range_to_zone(), memmap_init_zone() will call
set_page_links for each page. This means we don't need to call it on each
page explicitly.
This patch just removes the loop.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
mm/memory_hotplug.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index d61509752112..4fb1fb2b2b53 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -914,10 +914,6 @@ void __ref move_pfn_range_to_zone(struct zone *zone,
* are reserved so nobody should be touching them so we should be safe
*/
memmap_init_zone(nr_pages, nid, zone_idx(zone), start_pfn, MEMMAP_HOTPLUG);
- for (i = 0; i < nr_pages; i++) {
- unsigned long pfn = start_pfn + i;
- set_page_links(pfn_to_page(pfn), zone_idx(zone), nid, pfn);
- }
set_zone_contiguous(zone);
}
--
2.11.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] mm/memory_hotplug: remove duplicate call for set_page_links
2017-06-16 9:23 ` [PATCH 2/2] mm/memory_hotplug: remove duplicate call for set_page_links Wei Yang
@ 2017-06-16 17:33 ` Andrew Morton
2017-06-17 2:55 ` Wei Yang
2017-06-22 6:50 ` Michal Hocko
0 siblings, 2 replies; 6+ messages in thread
From: Andrew Morton @ 2017-06-16 17:33 UTC (permalink / raw)
To: Wei Yang; +Cc: mhocko, linux-mm
On Fri, 16 Jun 2017 17:23:35 +0800 Wei Yang <richard.weiyang@gmail.com> wrote:
> In function move_pfn_range_to_zone(), memmap_init_zone() will call
> set_page_links for each page.
Well, no. There are several types of pfn's for which
memmap_init_zone() will not call
__init_single_page()->set_page_links(). Probably the code is OK, as
those are pretty screwy pfn types. But I'd like to see some
confirmation that this patch is OK for all such pfns, now and in the
future?
> This means we don't need to call it on each
> page explicitly.
>
> This patch just removes the loop.
>
> ...
>
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -914,10 +914,6 @@ void __ref move_pfn_range_to_zone(struct zone *zone,
> * are reserved so nobody should be touching them so we should be safe
> */
> memmap_init_zone(nr_pages, nid, zone_idx(zone), start_pfn, MEMMAP_HOTPLUG);
> - for (i = 0; i < nr_pages; i++) {
> - unsigned long pfn = start_pfn + i;
> - set_page_links(pfn_to_page(pfn), zone_idx(zone), nid, pfn);
> - }
>
> set_zone_contiguous(zone);
> }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] mm/memory_hotplug: remove duplicate call for set_page_links
2017-06-16 17:33 ` Andrew Morton
@ 2017-06-17 2:55 ` Wei Yang
2017-06-22 6:50 ` Michal Hocko
1 sibling, 0 replies; 6+ messages in thread
From: Wei Yang @ 2017-06-17 2:55 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wei Yang, mhocko, linux-mm
[-- Attachment #1: Type: text/plain, Size: 1433 bytes --]
On Fri, Jun 16, 2017 at 10:33:50AM -0700, Andrew Morton wrote:
>On Fri, 16 Jun 2017 17:23:35 +0800 Wei Yang <richard.weiyang@gmail.com> wrote:
>
>> In function move_pfn_range_to_zone(), memmap_init_zone() will call
>> set_page_links for each page.
>
>Well, no. There are several types of pfn's for which
>memmap_init_zone() will not call
>__init_single_page()->set_page_links(). Probably the code is OK, as
>those are pretty screwy pfn types. But I'd like to see some
>confirmation that this patch is OK for all such pfns, now and in the
>future?
>
Hmm... when memmap_init_zone() is called during hotplug, this means
(context != MEMMAP_EARLY). So it will jump to the end and call
__init_single_page().
Is my understanding corrent?
>> This means we don't need to call it on each
>> page explicitly.
>>
>> This patch just removes the loop.
>>
>> ...
>>
>> --- a/mm/memory_hotplug.c
>> +++ b/mm/memory_hotplug.c
>> @@ -914,10 +914,6 @@ void __ref move_pfn_range_to_zone(struct zone *zone,
>> * are reserved so nobody should be touching them so we should be safe
>> */
>> memmap_init_zone(nr_pages, nid, zone_idx(zone), start_pfn, MEMMAP_HOTPLUG);
>> - for (i = 0; i < nr_pages; i++) {
>> - unsigned long pfn = start_pfn + i;
>> - set_page_links(pfn_to_page(pfn), zone_idx(zone), nid, pfn);
>> - }
>>
>> set_zone_contiguous(zone);
>> }
--
Wei Yang
Help you, Help me
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] mm/memory_hotplug: remove duplicate call for set_page_links
2017-06-16 17:33 ` Andrew Morton
2017-06-17 2:55 ` Wei Yang
@ 2017-06-22 6:50 ` Michal Hocko
1 sibling, 0 replies; 6+ messages in thread
From: Michal Hocko @ 2017-06-22 6:50 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wei Yang, linux-mm
On Fri 16-06-17 10:33:50, Andrew Morton wrote:
> On Fri, 16 Jun 2017 17:23:35 +0800 Wei Yang <richard.weiyang@gmail.com> wrote:
>
> > In function move_pfn_range_to_zone(), memmap_init_zone() will call
> > set_page_links for each page.
>
> Well, no. There are several types of pfn's for which
> memmap_init_zone() will not call
> __init_single_page()->set_page_links(). Probably the code is OK, as
> those are pretty screwy pfn types. But I'd like to see some
> confirmation that this patch is OK for all such pfns, now and in the
> future?
Yes it work properly for the hotplugable memory. If not then it is
memmap_init_zone to be fixed rather than duplicate the thig outside of
this function.
Acked-by: Michal Hocko <mhocko@suse.com>
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] mmzone: simplify zone_intersects()
2017-06-16 9:23 [PATCH 1/2] mmzone: simplify zone_intersects() Wei Yang
2017-06-16 9:23 ` [PATCH 2/2] mm/memory_hotplug: remove duplicate call for set_page_links Wei Yang
@ 2017-06-18 16:59 ` Michal Hocko
1 sibling, 0 replies; 6+ messages in thread
From: Michal Hocko @ 2017-06-18 16:59 UTC (permalink / raw)
To: Wei Yang; +Cc: linux-mm, akpm
On Fri 16-06-17 17:23:34, Wei Yang wrote:
> To make sure a range intersects a zone, only two comparison is necessary.
>
> This patch simplifies the function a little.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> include/linux/mmzone.h | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 0176a2933c61..7e8f100cb56d 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -541,15 +541,11 @@ static inline bool zone_intersects(struct zone *zone,
> {
> if (zone_is_empty(zone))
> return false;
> - if (start_pfn >= zone_end_pfn(zone))
> + if (start_pfn >= zone_end_pfn(zone) ||
> + start_pfn + nr_pages <= zone->zone_start_pfn)
> return false;
>
> - if (zone->zone_start_pfn <= start_pfn)
> - return true;
> - if (start_pfn + nr_pages > zone->zone_start_pfn)
> - return true;
> -
> - return false;
> + return true;
> }
>
> /*
> --
> 2.11.0
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-06-22 6:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-16 9:23 [PATCH 1/2] mmzone: simplify zone_intersects() Wei Yang
2017-06-16 9:23 ` [PATCH 2/2] mm/memory_hotplug: remove duplicate call for set_page_links Wei Yang
2017-06-16 17:33 ` Andrew Morton
2017-06-17 2:55 ` Wei Yang
2017-06-22 6:50 ` Michal Hocko
2017-06-18 16:59 ` [PATCH 1/2] mmzone: simplify zone_intersects() Michal Hocko
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).