From: lihanhui <hanhui.li@gmail.com>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Michal Nazarewicz <mina86@mina86.com>,
Rik van Riel <riel@redhat.com>, Mel Gorman <mgorman@suse.de>
Subject: Re: [PATCH 2/2] mm: support MIGRATE_DISCARD
Date: Fri, 21 Dec 2012 21:04:37 +0800 [thread overview]
Message-ID: <E270108E-B7EC-4A12-9662-4CF1CC7B69DE@gmail.com> (raw)
In-Reply-To: <1346832673-12512-2-git-send-email-minchan@kernel.org>
在 2012-9-5,下午4:11,Minchan Kim <minchan@kernel.org> 写道:
> This patch introudes MIGRATE_DISCARD mode in migration.
> It drops *clean cache pages* instead of migration so that
> migration latency could be reduced by avoiding (memcpy + page remapping).
> It's useful for CMA because latency of migration is very important rather
> than eviction of background processes's workingset. In addition, it needs
> less free pages for migration targets so it could avoid memory reclaiming
> to get free pages, which is another factor increase latency.
>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: Michal Nazarewicz <mina86@mina86.com>
> Cc: Rik van Riel <riel@redhat.com>
> Cc: Mel Gorman <mgorman@suse.de>
> Signed-off-by: Minchan Kim <minchan@kernel.org>
> ---
> include/linux/migrate_mode.h | 7 +++++++
> mm/migrate.c | 41 ++++++++++++++++++++++++++++++++++++++---
> mm/page_alloc.c | 2 +-
> 3 files changed, 46 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/migrate_mode.h b/include/linux/migrate_mode.h
> index 8848cad..4eb1646 100644
> --- a/include/linux/migrate_mode.h
> +++ b/include/linux/migrate_mode.h
> @@ -14,6 +14,13 @@
> */
> #define MIGRATE_SYNC ((__force migrate_mode_t)0x4)
>
> +/*
> + * MIGRTATE_DISCARD will discard clean cache page instead of migration.
> + * MIGRATE_ASYNC, MIGRATE_SYNC_LIGHT, MIGRATE_SYNC shouldn't be used
> + * together with OR flag in current implementation.
> + */
> +#define MIGRATE_DISCARD ((__force migrate_mode_t)0x8)
> +
> typedef unsigned __bitwise__ migrate_mode_t;
>
> #endif /* MIGRATE_MODE_H_INCLUDED */
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 28d464b..2de7709 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -678,6 +678,19 @@ static int move_to_new_page(struct page *newpage, struct page *page,
> return rc;
> }
>
> +static int discard_page(struct page *page)
> +{
> + int ret = -EAGAIN;
> +
> + struct address_space *mapping = page_mapping(page);
> + if (page_has_private(page))
> + if (!try_to_release_page(page, GFP_KERNEL))
> + return ret;
> + if (remove_mapping(mapping, page))
> + ret = 0;
> + return ret;
> +}
> +
> static int __unmap_and_move(struct page *page, struct page *newpage,
> int force, bool offlining, migrate_mode_t mode)
> {
> @@ -685,6 +698,9 @@ static int __unmap_and_move(struct page *page, struct page *newpage,
> int remap_swapcache = 1;
> struct mem_cgroup *mem;
> struct anon_vma *anon_vma = NULL;
> + enum ttu_flags ttu_flags;
> + bool discard_mode = false;
> + bool file = false;
>
> if (!trylock_page(page)) {
> if (!force || (mode & MIGRATE_ASYNC))
> @@ -799,12 +815,31 @@ static int __unmap_and_move(struct page *page, struct page *newpage,
> goto skip_unmap;
> }
>
> + file = page_is_file_cache(page);
> + ttu_flags = TTU_IGNORE_ACCESS;
> +retry:
> + if (!(mode & MIGRATE_DISCARD) || !file || PageDirty(page))
> + ttu_flags |= (TTU_MIGRATION | TTU_IGNORE_MLOCK);
> + else
> + discard_mode = true;
> +
> /* Establish migration ptes or remove ptes */
> - try_to_unmap(page, TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS);
> + rc = try_to_unmap(page, ttu_flags);
>
> skip_unmap:
> - if (!page_mapped(page))
> - rc = move_to_new_page(newpage, page, remap_swapcache, mode);
> + if (rc == SWAP_SUCCESS) {
> + if (!discard_mode) {
> + rc = move_to_new_page(newpage, page,
> + remap_swapcache, mode);
> + } else {
> + rc = discard_page(page);
> + goto uncharge;
> + }
> + } else if (rc == SWAP_MLOCK && discard_mode) {
> + mode &= ~MIGRATE_DISCARD;
> + discard_mode = false;
> + goto retry;
> + }
>
> if (rc && remap_swapcache)
> remove_migration_ptes(page, page);
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index ba3100a..e14b960 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5670,7 +5670,7 @@ static int __alloc_contig_migrate_range(unsigned long start, unsigned long end)
>
> ret = migrate_pages(&cc.migratepages,
> __alloc_contig_migrate_alloc,
> - 0, false, MIGRATE_SYNC);
> + 0, false, MIGRATE_SYNC|MIGRATE_DISCARD);
> }
>
> putback_lru_pages(&cc.migratepages);
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
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>
next prev parent reply other threads:[~2012-12-21 13:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 8:11 [PATCH 1/2] mm: change enum migrate_mode with bitwise type Minchan Kim
2012-09-05 8:11 ` [PATCH 2/2] mm: support MIGRATE_DISCARD Minchan Kim
2012-09-05 10:56 ` Mel Gorman
2012-09-06 5:31 ` Minchan Kim
2012-09-06 8:29 ` Mel Gorman
2012-09-06 9:03 ` Mel Gorman
2012-09-07 0:57 ` Kyungmin Park
2012-09-07 2:26 ` Minchan Kim
2012-09-07 8:10 ` Mel Gorman
2012-09-07 2:24 ` Minchan Kim
2012-09-07 5:57 ` Kyungmin Park
2012-09-07 7:31 ` Kyungmin Park
2012-09-07 8:17 ` Minchan Kim
2012-09-07 8:57 ` Kyungmin Park
2012-09-07 8:21 ` Mel Gorman
2012-09-07 9:32 ` Mel Gorman
2012-09-08 0:16 ` Minchan Kim
2012-09-05 12:43 ` Michal Nazarewicz
2012-12-21 13:04 ` lihanhui [this message]
2012-09-05 12:41 ` [PATCH 1/2] mm: change enum migrate_mode with bitwise type Michal Nazarewicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E270108E-B7EC-4A12-9662-4CF1CC7B69DE@gmail.com \
--to=hanhui.li@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=b.zolnierkie@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=m.szyprowski@samsung.com \
--cc=mgorman@suse.de \
--cc=mina86@mina86.com \
--cc=minchan@kernel.org \
--cc=riel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox