Re: + mm-compaction-use-async-migration-for-__gfp_no_kswapd-and-enforce-no-writeback.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrea,

I didn't follow up USB stick freeze issue but the patch's concept
looks good to me. But there are some comments about this patch.

1. __GFP_NO_KSWAPD

This patch is based on assumption that hugepage allocation have a good
fallback and now hugepage allocation uses __GFP_NO_KSWAPD.

__GFP_NO_KSWAPD's goal is just prevent unnecessary wakeup kswapd and
only user is just thp now so I can understand why you use it but how
about __GFP_NORETRY?

I think __GFP_NORETRY assume caller has a fallback mechanism(ex, SLUB)
and he think latency is important in such context.

2. LRU churn

By this patch, async migration can't migrate dirty page of normal fs.
It can move the victim page to head of LRU. I hope we can reduce LRU
churning as possible. For it, we can do it when we isolate the LRU
pages.
If compaction mode is async, we can exclude the dirty pages in
isolate_migratepages.


On Wed, Mar 23, 2011 at 6:53 AM,  <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> The patch titled
> Â Â mm: compaction: Use async migration for __GFP_NO_KSWAPD and enforce no writeback
> has been added to the -mm tree. ÂIts filename is
> Â Â mm-compaction-use-async-migration-for-__gfp_no_kswapd-and-enforce-no-writeback.patch
>
> Before you just go and hit "reply", please:
> Â a) Consider who else should be cc'ed
> Â b) Prefer to cc a suitable mailing list as well
> Â c) Ideally: find the original patch on the mailing list and do a
> Â Â Âreply-to-all to that, adding suitable additional cc's
>
> *** Remember to use Documentation/SubmitChecklist when testing your code ***
>
> See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
> out what to do about this
>
> The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
>
> ------------------------------------------------------
> Subject: mm: compaction: Use async migration for __GFP_NO_KSWAPD and enforce no writeback
> From: Andrea Arcangeli <aarcange@xxxxxxxxxx>
>
> __GFP_NO_KSWAPD allocations are usually very expensive and not mandatory
> to succeed as they have graceful fallback. ÂWaiting for I/O in those,
> tends to be overkill in terms of latencies, so we can reduce their latency
> by disabling sync migrate.
>
> Unfortunately, even with async migration it's still possible for the
> process to be blocked waiting for a request slot (e.g. Âget_request_wait
> in the block layer) when ->writepage is called. ÂTo prevent
> __GFP_NO_KSWAPD blocking, this patch prevents ->writepage being called on
> dirty page cache for asynchronous migration.
>
> [mel@xxxxxxxxx: Avoid writebacks for NFS, retry locked pages, use bool]
> Signed-off-by: Andrea Arcangeli <aarcange@xxxxxxxxxx>
> Signed-off-by: Mel Gorman <mel@xxxxxxxxx>
> Cc: Arthur Marsh <arthur.marsh@xxxxxxxxxxxxxxxx>
> Cc: Clemens Ladisch <cladisch@xxxxxxxxxxxxxx>
> Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> Cc: Minchan Kim <minchan.kim@xxxxxxxxx>
> Signed-off-by: Andrew Morton <>
> ---
>
> Âmm/migrate.c  Â|  48 +++++++++++++++++++++++++++++++---------------
> Âmm/page_alloc.c | Â Â2 -
> Â2 files changed, 34 insertions(+), 16 deletions(-)
>
> diff -puN mm/migrate.c~mm-compaction-use-async-migration-for-__gfp_no_kswapd-and-enforce-no-writeback mm/migrate.c
> --- a/mm/migrate.c~mm-compaction-use-async-migration-for-__gfp_no_kswapd-and-enforce-no-writeback
> +++ a/mm/migrate.c
> @@ -564,7 +564,7 @@ static int fallback_migrate_page(struct
> Â* Â== 0 - success
> Â*/
> Âstatic int move_to_new_page(struct page *newpage, struct page *page,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â int remap_swapcache)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â int remap_swapcache, bool sync)
> Â{
> Â Â Â Âstruct address_space *mapping;
> Â Â Â Âint rc;
> @@ -586,18 +586,28 @@ static int move_to_new_page(struct page
> Â Â Â Âmapping = page_mapping(page);
> Â Â Â Âif (!mapping)
> Â Â Â Â Â Â Â Ârc = migrate_page(mapping, newpage, page);
> - Â Â Â else if (mapping->a_ops->migratepage)
> + Â Â Â else {
> Â Â Â Â Â Â Â Â/*
> - Â Â Â Â Â Â Â Â* Most pages have a mapping and most filesystems
> - Â Â Â Â Â Â Â Â* should provide a migration function. Anonymous
> - Â Â Â Â Â Â Â Â* pages are part of swap space which also has its
> - Â Â Â Â Â Â Â Â* own migration function. This is the most common
> - Â Â Â Â Â Â Â Â* path for page migration.
> + Â Â Â Â Â Â Â Â* Do not writeback pages if !sync and migratepage is
> + Â Â Â Â Â Â Â Â* not pointing to migrate_page() which is nonblocking
> + Â Â Â Â Â Â Â Â* (swapcache/tmpfs uses migratepage = migrate_page).
> Â Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â rc = mapping->a_ops->migratepage(mapping,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newpage, page);
> - Â Â Â else
> - Â Â Â Â Â Â Â rc = fallback_migrate_page(mapping, newpage, page);
> + Â Â Â Â Â Â Â if (PageDirty(page) && !sync &&
> + Â Â Â Â Â Â Â Â Â mapping->a_ops->migratepage != migrate_page)
> + Â Â Â Â Â Â Â Â Â Â Â rc = -EBUSY;
> + Â Â Â Â Â Â Â else if (mapping->a_ops->migratepage)
> + Â Â Â Â Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â Â Â Â Â* Most pages have a mapping and most filesystems
> + Â Â Â Â Â Â Â Â Â Â Â Â* should provide a migration function. Anonymous
> + Â Â Â Â Â Â Â Â Â Â Â Â* pages are part of swap space which also has its
> + Â Â Â Â Â Â Â Â Â Â Â Â* own migration function. This is the most common
> + Â Â Â Â Â Â Â Â Â Â Â Â* path for page migration.
> + Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â rc = mapping->a_ops->migratepage(mapping,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newpage, page);
> + Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â rc = fallback_migrate_page(mapping, newpage, page);
> + Â Â Â }
>
> Â Â Â Âif (rc) {
> Â Â Â Â Â Â Â Ânewpage->mapping = NULL;
> @@ -641,7 +651,7 @@ static int unmap_and_move(new_page_t get
> Â Â Â Ârc = -EAGAIN;
>
> Â Â Â Âif (!trylock_page(page)) {
> - Â Â Â Â Â Â Â if (!force)
> + Â Â Â Â Â Â Â if (!force || !sync)
> Â Â Â Â Â Â Â Â Â Â Â Âgoto move_newpage;
>
> Â Â Â Â Â Â Â Â/*
> @@ -686,7 +696,15 @@ static int unmap_and_move(new_page_t get
> Â Â Â ÂBUG_ON(charge);
>
> Â Â Â Âif (PageWriteback(page)) {
> - Â Â Â Â Â Â Â if (!force || !sync)
> + Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â* For !sync, there is no point retrying as the retry loop
> + Â Â Â Â Â Â Â Â* is expected to be too short for PageWriteback to be cleared
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â if (!sync) {
> + Â Â Â Â Â Â Â Â Â Â Â rc = -EBUSY;
> + Â Â Â Â Â Â Â Â Â Â Â goto uncharge;
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â if (!force)
> Â Â Â Â Â Â Â Â Â Â Â Âgoto uncharge;
> Â Â Â Â Â Â Â Âwait_on_page_writeback(page);
> Â Â Â Â}
> @@ -757,7 +775,7 @@ static int unmap_and_move(new_page_t get
>
> Âskip_unmap:
> Â Â Â Âif (!page_mapped(page))
> - Â Â Â Â Â Â Â rc = move_to_new_page(newpage, page, remap_swapcache);
> + Â Â Â Â Â Â Â rc = move_to_new_page(newpage, page, remap_swapcache, sync);
>
> Â Â Â Âif (rc && remap_swapcache)
> Â Â Â Â Â Â Â Âremove_migration_ptes(page, page);
> @@ -850,7 +868,7 @@ static int unmap_and_move_huge_page(new_
> Â Â Â Âtry_to_unmap(hpage, TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS);
>
> Â Â Â Âif (!page_mapped(hpage))
> - Â Â Â Â Â Â Â rc = move_to_new_page(new_hpage, hpage, 1);
> + Â Â Â Â Â Â Â rc = move_to_new_page(new_hpage, hpage, 1, sync);
>
> Â Â Â Âif (rc)
> Â Â Â Â Â Â Â Âremove_migration_ptes(hpage, hpage);
> diff -puN mm/page_alloc.c~mm-compaction-use-async-migration-for-__gfp_no_kswapd-and-enforce-no-writeback mm/page_alloc.c
> --- a/mm/page_alloc.c~mm-compaction-use-async-migration-for-__gfp_no_kswapd-and-enforce-no-writeback
> +++ a/mm/page_alloc.c
> @@ -2103,7 +2103,7 @@ rebalance:
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âsync_migration);
> Â Â Â Âif (page)
> Â Â Â Â Â Â Â Âgoto got_pg;
> - Â Â Â sync_migration = true;
> + Â Â Â sync_migration = !(gfp_mask & __GFP_NO_KSWAPD);
>
> Â Â Â Â/* Try direct reclaim and then allocating */
> Â Â Â Âpage = __alloc_pages_direct_reclaim(gfp_mask, order,
> _
>
> Patches currently in -mm which might be from aarcange@xxxxxxxxxx are
>
> origin.patch
> mm-compaction-prevent-kswapd-compacting-memory-to-reduce-cpu-usage.patch
> mm-compaction-check-migrate_pagess-return-value-instead-of-list_empty.patch
> mm-deactivate-invalidated-pages.patch
> memcg-move-memcg-reclaimable-page-into-tail-of-inactive-list.patch
> memcg-move-memcg-reclaimable-page-into-tail-of-inactive-list-fix.patch
> mm-reclaim-invalidated-page-asap.patch
> pagewalk-only-split-huge-pages-when-necessary.patch
> smaps-break-out-smaps_pte_entry-from-smaps_pte_range.patch
> smaps-pass-pte-size-argument-in-to-smaps_pte_entry.patch
> smaps-teach-smaps_pte_range-about-thp-pmds.patch
> smaps-have-smaps-show-transparent-huge-pages.patch
> mm-vmscan-kswapd-should-not-free-an-excessive-number-of-pages-when-balancing-small-zones.patch
> mm-compaction-minimise-the-time-irqs-are-disabled-while-isolating-free-pages.patch
> mm-compaction-minimise-the-time-irqs-are-disabled-while-isolating-pages-for-migration.patch
> mm-compaction-minimise-the-time-irqs-are-disabled-while-isolating-pages-for-migration-fix.patch
> mm-compaction-use-async-migration-for-__gfp_no_kswapd-and-enforce-no-writeback.patch
> mm-add-__gfp_other_node-flag.patch
> mm-use-__gfp_other_node-for-transparent-huge-pages.patch
> ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages.patch
> ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix.patch
> ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix-fix.patch
> ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix-fix-fix.patch
> mm-add-vm-counters-for-transparent-hugepages.patch
> memcg-use-native-word-page-statistics-counters-fix-event-counter-breakage-with-thp.patch
>
>



-- 
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]