mmzone: simplify zone_intersects()
Subsystems (4)
PATCH 1/2 mmzone: simplify zone_intersects()
To make sure a range intersects a zone, only two comparison is necessary.
This patch simplifies the function a little.
--- include/linux/mmzone.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
include/linux/mmzone.h +3 -7
@@ -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; }/*
Signature · 7 lines
2.11.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/2 mm/memory_hotplug: remove duplicate call for set_page_links
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.
--- mm/memory_hotplug.c | 4 ---- 1 file changed, 4 deletions(-)
mm/memory_hotplug.c +0 -4
@@ -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); }
Signature · 7 lines
2.11.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 2/2] mm/memory_hotplug: remove duplicate call for set_page_links
Quoted 2 lines · On Fri, 16 Jun 2017 17:23:35 +0800 Wei Yang <[email protected]> wrote:
In function
move_pfn_range_to_zone(),memmap_init_zone()will callset_page_linksfor 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?
Quoted 10 lines
This means we don't need to call it on each
page explicitly.This patch just removes the loop.
...
mm/memory_hotplug.c void __ref move_pfn_range_to_zone(struct zone *zone, · line 919
Quoted 10 lines
mm/memory_hotplug.c +0
-4@@ -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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/2] mm/memory_hotplug: remove duplicate call for set_page_links
Quoted 5 lines · Andrew Morton
Quoted 2 lines · On Fri, 16 Jun 2017 17:23:35 +0800 Wei Yang <[email protected]> wrote:
In function
move_pfn_range_to_zone(),memmap_init_zone()will callset_page_linksfor each page.
Quoted 7 lines
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?
Quoted 20 lines
Quoted 20 lines
This means we don't need to call it on each
page explicitly.This patch just removes the loop.
...
mm/memory_hotplug.c +0
-4@@ -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); }
Signature · 2 lines
Wei Yang Help you, Help me
Michal Hocko
Acked-byRe: [PATCH 2/2] mm/memory_hotplug: remove duplicate call for set_page_links
In reply to Andrew MortonQuoted 11 lines · Andrew Morton
Quoted 2 lines · On Fri, 16 Jun 2017 17:23:35 +0800 Wei Yang <[email protected]> wrote:
In function
move_pfn_range_to_zone(),memmap_init_zone()will callset_page_linksfor 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.
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 5 lines · 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 <[email protected]>
Quoted 29 lines
--- include/linux/mmzone.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)include/linux/mmzone.h +3
-7@@ -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; }/* Signature · 1 line
2.11.0
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>