From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Joonsoo Kim <js1304@gmail.com>, Minchan Kim <minchan@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: [PATCH 2/4] mm, migrate: allocation new page lazyily in unmap_and_move()
Date: Fri, 2 Aug 2013 11:07:57 +0900 [thread overview]
Message-ID: <1375409279-16919-2-git-send-email-iamjoonsoo.kim@lge.com> (raw)
In-Reply-To: <1375409279-16919-1-git-send-email-iamjoonsoo.kim@lge.com>
We don't need a new page and then go out immediately if some condition
is met. Allocation has overhead in comparison with some condition check,
so allocating lazyily is preferable solution.
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
diff --git a/mm/migrate.c b/mm/migrate.c
index 6f0c244..86db87e 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -864,10 +864,7 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
{
int rc = 0;
int *result = NULL;
- struct page *newpage = get_new_page(page, private, &result);
-
- if (!newpage)
- return -ENOMEM;
+ struct page *newpage = NULL;
if (page_count(page) == 1) {
/* page was freed from under us. So we are done. */
@@ -878,6 +875,10 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
if (unlikely(split_huge_page(page)))
goto out;
+ newpage = get_new_page(page, private, &result);
+ if (!newpage)
+ return -ENOMEM;
+
rc = __unmap_and_move(page, newpage, force, mode);
if (unlikely(rc == MIGRATEPAGE_BALLOON_SUCCESS)) {
@@ -908,7 +909,8 @@ out:
* Move the new page to the LRU. If migration was not successful
* then this will free the page.
*/
- putback_lru_page(newpage);
+ if (newpage)
+ putback_lru_page(newpage);
if (result) {
if (rc)
*result = rc;
--
1.7.9.5
--
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:[~2013-08-02 2:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-02 2:07 [PATCH 1/4] mm, page_alloc: add likely macro to help compiler optimization Joonsoo Kim
2013-08-02 2:07 ` Joonsoo Kim [this message]
2013-08-02 19:41 ` [PATCH 2/4] mm, migrate: allocation new page lazyily in unmap_and_move() Johannes Weiner
2013-08-05 7:41 ` Joonsoo Kim
2013-08-02 2:07 ` [PATCH 3/4] mm: move pgtable related functions to right place Joonsoo Kim
2013-08-02 2:07 ` [PATCH 4/4] swap: clean-up #ifdef in page_mapping() Joonsoo Kim
2013-08-02 19:43 ` Johannes Weiner
2013-08-02 16:27 ` [PATCH 1/4] mm, page_alloc: add likely macro to help compiler optimization Michal Hocko
2013-08-02 20:47 ` Johannes Weiner
2013-08-02 21:36 ` Michal Hocko
2013-08-05 8:10 ` Joonsoo Kim
2013-08-05 8:50 ` Joonsoo Kim
2013-08-05 8:59 ` Michal Hocko
2013-08-05 20:52 ` Johannes Weiner
2013-08-02 19:26 ` Johannes Weiner
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=1375409279-16919-2-git-send-email-iamjoonsoo.kim@lge.com \
--to=iamjoonsoo.kim@lge.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=js1304@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--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