From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Rik van Riel <riel@redhat.com>, Jiang Liu <jiang.liu@huawei.com>,
Mel Gorman <mgorman@suse.de>,
Cody P Schafer <cody@linux.vnet.ibm.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.cz>, Minchan Kim <minchan@kernel.org>,
Michal Nazarewicz <mina86@mina86.com>,
Andi Kleen <ak@linux.intel.com>,
Wei Yongjun <yongjun_wei@trendmicro.com.cn>,
Tang Chen <tangchen@cn.fujitsu.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Joonsoo Kim <js1304@gmail.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: [PATCH 5/7] mm/page_alloc: separate interface to set/get migratetype of freepage
Date: Thu, 9 Jan 2014 16:04:45 +0900 [thread overview]
Message-ID: <1389251087-10224-6-git-send-email-iamjoonsoo.kim@lge.com> (raw)
In-Reply-To: <1389251087-10224-1-git-send-email-iamjoonsoo.kim@lge.com>
Currently, we use (set/get)_freepage_migratetype in two use cases.
One is to know the buddy list where this page will be linked and
the other is to know the buddy list where this page is linked now.
But, we should deal these two use cases differently, because information
isn't sufficient for the second use case and properly setting this
information needs some overhead. Whenever the page is merged or split
in buddy, this information isn't properly re-assigned and it may not
have enough information for the second use case.
This patch just separates interface, so there is no functional change.
Following patch will do further steps about this issue.
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3552717..2733e0b 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -257,14 +257,31 @@ struct inode;
#define page_private(page) ((page)->private)
#define set_page_private(page, v) ((page)->private = (v))
-/* It's valid only if the page is free path or free_list */
-static inline void set_freepage_migratetype(struct page *page, int migratetype)
+/*
+ * It's valid only if the page is on buddy. It represents
+ * which freelist the page is linked.
+ */
+static inline void set_buddy_migratetype(struct page *page, int migratetype)
+{
+ page->index = migratetype;
+}
+
+static inline int get_buddy_migratetype(struct page *page)
+{
+ return page->index;
+}
+
+/*
+ * It's valid only if the page is on pcp list. It represents
+ * which freelist the page should go on buddy.
+ */
+static inline void set_pcp_migratetype(struct page *page, int migratetype)
{
page->index = migratetype;
}
-/* It's valid only if the page is free path or free_list */
-static inline int get_freepage_migratetype(struct page *page)
+/* It's valid only if the page is on pcp list */
+static inline int get_pcp_migratetype(struct page *page)
{
return page->index;
}
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 4913829..c9e6622 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -681,7 +681,7 @@ static void free_pcppages_bulk(struct zone *zone, int count,
page = list_entry(list->prev, struct page, lru);
/* must delete as __free_one_page list manipulates */
list_del(&page->lru);
- mt = get_freepage_migratetype(page);
+ mt = get_pcp_migratetype(page);
/* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */
__free_one_page(page, zone, 0, mt);
trace_mm_page_pcpu_drain(page, 0, mt);
@@ -745,7 +745,7 @@ static void __free_pages_ok(struct page *page, unsigned int order)
local_irq_save(flags);
__count_vm_events(PGFREE, 1 << order);
migratetype = get_pageblock_migratetype(page);
- set_freepage_migratetype(page, migratetype);
+ set_buddy_migratetype(page, migratetype);
free_one_page(page_zone(page), page, order, migratetype);
local_irq_restore(flags);
}
@@ -903,7 +903,7 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order,
rmv_page_order(page);
area->nr_free--;
expand(zone, page, order, current_order, area, migratetype);
- set_freepage_migratetype(page, migratetype);
+ set_pcp_migratetype(page, migratetype);
return page;
}
@@ -971,7 +971,7 @@ int move_freepages(struct zone *zone,
order = page_order(page);
list_move(&page->lru,
&zone->free_area[order].free_list[migratetype]);
- set_freepage_migratetype(page, migratetype);
+ set_buddy_migratetype(page, migratetype);
page += 1 << order;
pages_moved += 1 << order;
}
@@ -1094,12 +1094,11 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype)
/* CMA pages cannot be stolen */
if (is_migrate_cma(migratetype)) {
- set_freepage_migratetype(page, migratetype);
+ set_pcp_migratetype(page, migratetype);
__mod_zone_page_state(zone,
NR_FREE_CMA_PAGES, -(1 << order));
} else {
- set_freepage_migratetype(page,
- start_migratetype);
+ set_pcp_migratetype(page, start_migratetype);
}
/* Remove the page from the freelists */
@@ -1346,7 +1345,7 @@ void free_hot_cold_page(struct page *page, int cold)
return;
migratetype = get_pageblock_migratetype(page);
- set_freepage_migratetype(page, migratetype);
+ set_pcp_migratetype(page, migratetype);
local_irq_save(flags);
__count_vm_event(PGFREE);
diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index 534fb3a..c341413 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -190,7 +190,7 @@ __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn,
* is MIGRATE_ISOLATE. Catch it and move the page into
* MIGRATE_ISOLATE list.
*/
- if (get_freepage_migratetype(page) != MIGRATE_ISOLATE) {
+ if (get_buddy_migratetype(page) != MIGRATE_ISOLATE) {
struct page *end_page;
end_page = page + (1 << page_order(page)) - 1;
--
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:[~2014-01-09 7:04 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-09 7:04 [PATCH 0/7] improve robustness on handling migratetype Joonsoo Kim
2014-01-09 7:04 ` [PATCH 1/7] mm/page_alloc: synchronize get/set pageblock Joonsoo Kim
2014-01-09 9:08 ` Michal Nazarewicz
2014-01-09 7:04 ` [PATCH 2/7] mm/cma: fix cma free page accounting Joonsoo Kim
2014-01-09 21:10 ` Laura Abbott
2014-01-10 8:50 ` Joonsoo Kim
2014-01-09 7:04 ` [PATCH 3/7] mm/page_alloc: move set_freepage_migratetype() to better place Joonsoo Kim
2014-01-09 7:04 ` [PATCH 4/7] mm/isolation: remove invalid check condition Joonsoo Kim
2014-01-09 7:04 ` Joonsoo Kim [this message]
2014-01-09 9:18 ` [PATCH 5/7] mm/page_alloc: separate interface to set/get migratetype of freepage Michal Nazarewicz
2014-01-09 7:04 ` [PATCH 6/7] mm/page_alloc: store freelist migratetype to the page on buddy properly Joonsoo Kim
2014-01-09 9:19 ` Michal Nazarewicz
2014-01-09 7:04 ` [PATCH 7/7] mm/page_alloc: don't merge MIGRATE_(CMA|ISOLATE) pages on buddy Joonsoo Kim
2014-01-09 9:22 ` Michal Nazarewicz
2014-01-09 9:06 ` [PATCH 0/7] improve robustness on handling migratetype Michal Nazarewicz
2014-01-09 14:05 ` Joonsoo Kim
2014-01-09 9:27 ` Mel Gorman
2014-01-10 8:48 ` Joonsoo Kim
2014-01-10 9:48 ` Mel Gorman
2014-01-13 1:57 ` Joonsoo Kim
2014-01-29 16:52 ` Vlastimil Babka
2014-01-31 15:39 ` Mel Gorman
2014-02-03 7:45 ` Joonsoo Kim
2014-02-03 9:16 ` Vlastimil Babka
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=1389251087-10224-6-git-send-email-iamjoonsoo.kim@lge.com \
--to=iamjoonsoo.kim@lge.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=cody@linux.vnet.ibm.com \
--cc=hannes@cmpxchg.org \
--cc=jiang.liu@huawei.com \
--cc=js1304@gmail.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=mina86@mina86.com \
--cc=minchan@kernel.org \
--cc=riel@redhat.com \
--cc=tangchen@cn.fujitsu.com \
--cc=yongjun_wei@trendmicro.com.cn \
/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