mm: cma: Discard clean pages during contiguous allocation instead of migration
Subsystems (7)
PATCH 1/1 mm: cma: Discard clean pages during contiguous allocation instead of migration
This patch drops clean cache pages instead of migration during alloc_contig_range() to minimise allocation latency by reducing the amount of migration is necessary. It's useful for CMA because latency of migration is more important than evicting the background processes working set. In addition, as pages are reclaimed then fewer free pages for migration targets are required so it avoids memory reclaiming to get free pages, which is a contributory factor to increased latency.
* from v1
* drop migrate_mode_t
* add reclaim_clean_pages_from_list instad of MIGRATE_DISCARD support - Mel
I measured elapsed time of __alloc_contig_migrate_range which migrates 10M in 40M movable zone in QEMU machine.
Before - 146ms, After - 7ms
---
Andrew, this patch is based on (mmotm-2012-09-06-16-46 - drop mm-support-migrate_discard.patch removed from -mm tree + drop mm-support-migrate_discard.patch removed from -mm tree)
mm/internal.h | 3 ++- mm/page_alloc.c | 2 ++ mm/vmscan.c | 43 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 7 deletions(-)
mm/internal.h +2 -1
@@ -356,5 +356,6 @@ extern unsigned long vm_mmap_pgoff(struct file *, unsigned long, unsigned long, unsigned long);extern void set_pageblock_order (void ); - +unsigned long reclaim_clean_pages_from_list (struct zone *zone, +struct list_head *page_list);#endif /* __MM_INTERNAL_H */
mm/page_alloc.c +2 -0
@@ -5705,6 +5705,8 @@ static int __alloc_contig_migrate_range(unsigned long start, unsigned long end)break ; } +reclaim_clean_pages_from_list (cc.zone, &cc.migratepages); + ret =migrate_pages (&cc.migratepages, __alloc_contig_migrate_alloc,0 , false,MIGRATE_SYNC );
mm/vmscan.c +37 -6
83 lines not on this page · raw message
Signature · 7 lines
1.7.9.5 -- 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 15 lines · Minchan Kim
This patch drops clean cache pages instead of migration during
alloc_contig_range()to minimise allocation latency by reducing the amount of migration is necessary. It's useful for CMA because latency of migration is more important than evicting the background processes working set. In addition, as pages are reclaimed then fewer free pages for migration targets are required so it avoids memory reclaiming to get free pages, which is a contributory factor to increased latency.* from v1
* dropmigrate_mode_t
* addreclaim_clean_pages_from_listinstad ofMIGRATE_DISCARDsupport - MelI measured elapsed time of
__alloc_contig_migrate_rangewhich migrates 10M in 40M movable zone in QEMU machine.
Quoted 7 lines
Before - 146ms, After - 7ms
Cc Marek Szyprowski <[email protected]>Cc Michal Nazarewicz <[email protected]>Cc Rik van Riel <[email protected]>Signed-off-by Mel Gorman <[email protected]>Signed-off-by Minchan Kim <[email protected]>
My signed-off is already on this but in earlier versions I was still asking for changes. This time the patch looks good to me so even though it is a bit redundant.
Thanks Minchan.
Signature · 8 lines
Mel Gorman 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 12 lines · Minchan Kim
This patch drops clean cache pages instead of migration during
alloc_contig_range()to minimise allocation latency by reducing the amount of migration is necessary. It's useful for CMA because latency of migration is more important than evicting the background processes working set. In addition, as pages are reclaimed then fewer free pages for migration targets are required so it avoids memory reclaiming to get free pages, which is a contributory factor to increased latency.* from v1
* dropmigrate_mode_t
* addreclaim_clean_pages_from_listinstad ofMIGRATE_DISCARDsupport - Mel
Quoted 7 lines
I measured elapsed time of
__alloc_contig_migrate_rangewhich migrates 10M in 40M movable zone in QEMU machine.Before - 146ms, After - 7ms
Cc Marek Szyprowski <[email protected]>Cc Michal Nazarewicz <[email protected]>
Thanks!
Signature · 4 lines
Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +----<email/xmpp: [email protected]>--------------ooO--(_)--Ooo--
Kyungmin Park
Tested-byQuoted 20 lines · Michal Nazarewicz
Quoted 18 lines · Minchan Kim
This patch drops clean cache pages instead of migration during
alloc_contig_range()to minimise allocation latency by reducing the amount
of migration is necessary. It's useful for CMA because latency of migration
is more important than evicting the background processes working set. In addition, as pages are reclaimed then fewer free pages for migration targets are required so it avoids memory reclaiming to get free pages, which is a contributory factor to increased latency.* from v1
* dropmigrate_mode_t
* addreclaim_clean_pages_from_listinstad ofMIGRATE_DISCARDsupport -
MelI measured elapsed time of
__alloc_contig_migrate_rangewhich migrates 10M in 40M movable zone in QEMU machine.
Quoted 6 lines
Quoted 4 lines
Before - 146ms, After - 7ms
Cc Marek Szyprowski <[email protected]>Cc Michal Nazarewicz <[email protected]>
Quoted 8 lines
Thanks!
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +----<email/xmpp: [email protected]>--------------ooO--(_)--Ooo--
--
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
maintainerQuoted 20 lines · On Tue, 11 Sep 2012 09:41:52 +0900 Minchan Kim <[email protected]> wrote:
This patch drops clean cache pages instead of migration during
alloc_contig_range()to minimise allocation latency by reducing the amount of migration is necessary. It's useful for CMA because latency of migration is more important than evicting the background processes working set. In addition, as pages are reclaimed then fewer free pages for migration targets are required so it avoids memory reclaiming to get free pages, which is a contributory factor to increased latency.* from v1
* dropmigrate_mode_t
* addreclaim_clean_pages_from_listinstad ofMIGRATE_DISCARDsupport - MelI measured elapsed time of
__alloc_contig_migrate_rangewhich migrates 10M in 40M movable zone in QEMU machine.Before - 146ms, After - 7ms
...
mm/vmscan.c static unsigned long shrink_page_list(struct list_head *page_list, · line 764
Quoted 6 lines
mm/vmscan.c +2
-1@@ -758,7 +760,9 @@ static unsigned long shrink_page_list(struct list_head *page_list,wait_on_page_writeback (page); } - references =page_check_references (page, sc); +if (!force_reclaim) + references =page_check_references (page, sc);
grumble. Could we please document `enum page_references' and page_check_references()?
And the `force_reclaim' arg could do with some documentation. It only forces reclaim under certain circumstances. They should be described, and a reson should be provided.
Why didn't this patch use PAGEREF_RECLAIM_CLEAN? It is possible for someone to dirty one of these pages after we tested its cleanness and we'll then go off and write it out, but we won't be reclaiming it?
Quoted 3 lines
...
--
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 33 lines · Andrew Morton
Quoted 20 lines · On Tue, 11 Sep 2012 09:41:52 +0900 Minchan Kim <[email protected]> wrote:
This patch drops clean cache pages instead of migration during
alloc_contig_range()to minimise allocation latency by reducing the amount of migration is necessary. It's useful for CMA because latency of migration is more important than evicting the background processes working set. In addition, as pages are reclaimed then fewer free pages for migration targets are required so it avoids memory reclaiming to get free pages, which is a contributory factor to increased latency.* from v1
* dropmigrate_mode_t
* addreclaim_clean_pages_from_listinstad ofMIGRATE_DISCARDsupport - MelI measured elapsed time of
__alloc_contig_migrate_rangewhich migrates 10M in 40M movable zone in QEMU machine.Before - 146ms, After - 7ms
...
Review static unsigned long shrink_page_list(struct list_head *page_list, · line 764
Quoted 6 lines
(quoted diff) +2
-1@@ -758,7 +760,9 @@ static unsigned long shrink_page_list(struct list_head *page_list, wait_on_page_writeback(page); } - references = page_check_references(page, sc); + if (!force_reclaim) + references = page_check_references(page, sc);grumble. Could we please document `enum
page_references' andpage_check_references()?
Quoted 3 lines
And the `force_reclaim' arg could do with some documentation. It only forces reclaim under certain circumstances. They should be described, and a reson should be provided.
I will give it a shot by another patch.
Quoted 4 lines
Why didn't this patch use
PAGEREF_RECLAIM_CLEAN? It is possible for someone to dirty one of these pages after we tested its cleanness and we'll then go off and write it out, but we won't be reclaiming it?
Absolutely.
Thanks Andrew!
Here it goes.
====== 8< ======
mm/vmscan.c static enum page_references page_check_references(struct page *page, · line 677
Quoted 7 lines · Minchan Kim
mm/vmscan.c +1
-0@@ -674,8 +674,10 @@ static enum page_references page_check_references(struct page *page, static unsigned long shrink_page_list(struct list_head *page_list, struct zone *zone, struct scan_control *sc, + enum ttu_flags ttu_flags,
"enum ttu_flags" is defined on CONFIG_MMU=y only, causing on nommu:
mm/vmscan.c:677:26: error: parameter 4 ('ttu_flags') has incomplete type mm/vmscan.c:987:5: error: 'TTU_UNMAP' undeclared (first use in this function) mm/vmscan.c:987:15: error: 'TTU_IGNORE_ACCESS' undeclared (first use in this function)mm/vmscan.c:1312:56: error: 'TTU_UNMAP' undeclared (first use in this function)
E.g.
http://kisskb.ellerman.id.au/kisskb/buildresult/7191694/ (h8300-defconfig)
http://kisskb.ellerman.id.au/kisskb/buildresult/7191858/ (sh-allnoconfig)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
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
maintainerQuoted 17 lines · On Thu, 13 Sep 2012 21:17:19 +0200 Geert Uytterhoeven <[email protected]>…
mm/vmscan.c static enum page_references page_check_references(struct page *page, · line 677
Quoted 7 lines · Minchan Kim
mm/vmscan.c +1
-0@@ -674,8 +674,10 @@ static enum page_references page_check_references(struct page *page, static unsigned long shrink_page_list(struct list_head *page_list, struct zone *zone, struct scan_control *sc, + enum ttu_flags ttu_flags,"enum
ttu_flags" is defined onCONFIG_MMU=yonly, causing on nommu:
mm/vmscan.c:677:26: error: parameter 4 ('ttu_flags') has incomplete typemm/vmscan.c:987:5: error: 'TTU_UNMAP' undeclared (first use in this function)mm/vmscan.c:987:15: error: 'TTU_IGNORE_ACCESS' undeclared (first use in this function)mm/vmscan.c:1312:56: error: 'TTU_UNMAP' undeclared (first use in this function)
Quoted 3 lines
E.g.
http://kisskb.ellerman.id.au/kisskb/buildresult/7191694/ (h8300-defconfig)
http://kisskb.ellerman.id.au/kisskb/buildresult/7191858/ (sh-allnoconfig)
hm, OK, the means by which current mainline avoids build errors is either clever or lucky.
switch (try_to_unmap(page, TTU_UNMAP)) {gets preprocessed into
switch (2) {so the cmopiler never gets to see the TTU_ symbol at all. Because it happens to be inside the try_to_unmap() call.
I guess we can just make ttu_flags visible to NOMMU:
include/linux/rmap.h renamed from include/linux/rmap.h~mm-cma-discard-clean-pages-during-contiguous-allocation-instead-of-migration-fix-fix +11 -10
@@ -71,6 +71,17 @@ struct anon_vma_chain {#endif }; +enum ttu_flags { +TTU_UNMAP =0 ,/* unmap mode */ +TTU_MIGRATION =1 ,/* migration mode */ +TTU_MUNLOCK =2 ,/* munlock mode */ +TTU_ACTION_MASK =0xff , + +TTU_IGNORE_MLOCK = (1 <<8 ),/* ignore mlock */ +TTU_IGNORE_ACCESS = (1 <<9 ),/* don't age */ +TTU_IGNORE_HWPOISON = (1 <<10 ),/* corrupted page is recoverable */ +}; +#ifdef CONFIG_MMU static inline void get_anon_vma (struct anon_vma *anon_vma) {
@@ -164,16 +175,6 @@ int page_referenced(struct page *, int iint page_referenced_one (struct page *,struct vm_area_struct *,unsigned long address,unsigned int *mapcount,unsigned long *vm_flags); -enum ttu_flags { -TTU_UNMAP =0 ,/* unmap mode */ -TTU_MIGRATION =1 ,/* migration mode */ -TTU_MUNLOCK =2 ,/* munlock mode */ -TTU_ACTION_MASK =0xff , - -TTU_IGNORE_MLOCK = (1 <<8 ),/* ignore mlock */ -TTU_IGNORE_ACCESS = (1 <<9 ),/* don't age */ -TTU_IGNORE_HWPOISON = (1 <<10 ),/* corrupted page is recoverable */ -};#define TTU_ACTION (x) ((x) & TTU_ACTION_MASK)int try_to_unmap (struct page *,enum ttu_flags flags);
_
Quoted 31 lines · Andrew Morton
Quoted 17 lines · On Thu, 13 Sep 2012 21:17:19 +0200 Geert Uytterhoeven <[email protected]>…
mm/vmscan.c static enum page_references page_check_references(struct page *page, · line 677
Quoted 7 lines · Minchan Kim
mm/vmscan.c +1
-0@@ -674,8 +674,10 @@ static enum page_references page_check_references(struct page *page, static unsigned long shrink_page_list(struct list_head *page_list, struct zone *zone, struct scan_control *sc, + enum ttu_flags ttu_flags,"enum
ttu_flags" is defined onCONFIG_MMU=yonly, causing on nommu:
mm/vmscan.c:677:26: error: parameter 4 ('ttu_flags') has incomplete typemm/vmscan.c:987:5: error: 'TTU_UNMAP' undeclared (first use in this function)mm/vmscan.c:987:15: error: 'TTU_IGNORE_ACCESS' undeclared (first use in this function)mm/vmscan.c:1312:56: error: 'TTU_UNMAP' undeclared (first use in this function)Quoted 3 lines
E.g.
http://kisskb.ellerman.id.au/kisskb/buildresult/7191694/ (h8300-defconfig)
http://kisskb.ellerman.id.au/kisskb/buildresult/7191858/ (sh-allnoconfig)hm, OK, the means by which current mainline avoids build errors is either clever or lucky.
switch (try_to_unmap(page, TTU_UNMAP)) {gets preprocessed into
Quoted 7 lines
switch (2) {so the cmopiler never gets to see the
TTU_symbol at all. Because it happens to be inside thetry_to_unmap()call.I guess we can just make
ttu_flagsvisible to NOMMU:
I agree.
Geert, Andrew
Thanks for the reporting and quick fix!
Signature · 8 lines
Kind regards, Minchan Kim -- 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>