From: Xishi Qiu <qiuxishi@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@kernel.org>,
"Luck, Tony" <tony.luck@intel.com>,
Hanjun Guo <guohanjun@huawei.com>, Xiexiuqi <xiexiuqi@huawei.com>,
leon@leon.nu, Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Dave Hansen <dave.hansen@intel.com>,
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
Vlastimil Babka <vbabka@suse.cz>, Mel Gorman <mgorman@suse.de>
Cc: Xishi Qiu <qiuxishi@huawei.com>, Linux MM <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [RFC v2 PATCH 7/8] mm: add the buddy system interface
Date: Sat, 27 Jun 2015 10:27:52 +0800 [thread overview]
Message-ID: <558E0A28.6060607@huawei.com> (raw)
In-Reply-To: <558E084A.60900@huawei.com>
Add the buddy system interface for address range mirroring feature.
Use mirrored memory for all kernel allocations. If there is no mirrored pages
left, try to use other types pages.
Signed-off-by: Xishi Qiu <qiuxishi@huawei.com>
---
include/linux/memblock.h | 1 +
mm/memblock.c | 6 +++---
mm/page_alloc.c | 19 +++++++++++++++++++
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 53be030..8c33ac0 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -81,6 +81,7 @@ int memblock_mark_hotplug(phys_addr_t base, phys_addr_t size);
int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size);
int memblock_mark_mirror(phys_addr_t base, phys_addr_t size);
ulong choose_memblock_flags(void);
+extern struct static_key system_has_mirror;
#ifdef CONFIG_MEMORY_MIRROR
void memblock_mark_migratemirror(void);
#endif
diff --git a/mm/memblock.c b/mm/memblock.c
index 0d0b210..430ad87 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -55,14 +55,14 @@ int memblock_debug __initdata_memblock;
#ifdef CONFIG_MOVABLE_NODE
bool movable_node_enabled __initdata_memblock = false;
#endif
-static bool system_has_some_mirror __initdata_memblock = false;
+struct static_key system_has_mirror = STATIC_KEY_INIT;
static int memblock_can_resize __initdata_memblock;
static int memblock_memory_in_slab __initdata_memblock = 0;
static int memblock_reserved_in_slab __initdata_memblock = 0;
ulong __init_memblock choose_memblock_flags(void)
{
- return system_has_some_mirror ? MEMBLOCK_MIRROR : MEMBLOCK_NONE;
+ return static_key_false(&system_has_mirror) ? MEMBLOCK_MIRROR : MEMBLOCK_NONE;
}
/* inline so we don't get a warning when pr_debug is compiled out */
@@ -814,7 +814,7 @@ int __init_memblock memblock_clear_hotplug(phys_addr_t base, phys_addr_t size)
*/
int __init_memblock memblock_mark_mirror(phys_addr_t base, phys_addr_t size)
{
- system_has_some_mirror = true;
+ static_key_slow_inc(&system_has_mirror);
return memblock_setclr_flag(base, size, 1, MEMBLOCK_MIRROR);
}
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 4c5bc50..8a6125e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1033,6 +1033,9 @@ static int fallbacks[MIGRATE_TYPES][4] = {
[MIGRATE_UNMOVABLE] = { MIGRATE_RECLAIMABLE, MIGRATE_MOVABLE, MIGRATE_RESERVE },
[MIGRATE_RECLAIMABLE] = { MIGRATE_UNMOVABLE, MIGRATE_MOVABLE, MIGRATE_RESERVE },
[MIGRATE_MOVABLE] = { MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE, MIGRATE_RESERVE },
+#ifdef CONFIG_MEMORY_MIRROR
+ [MIGRATE_MIRROR] = { MIGRATE_RESERVE }, /* Never used */
+#endif
#ifdef CONFIG_CMA
[MIGRATE_CMA] = { MIGRATE_RESERVE }, /* Never used */
#endif
@@ -1295,6 +1298,15 @@ retry_reserve:
page = __rmqueue_smallest(zone, order, migratetype);
if (unlikely(!page) && migratetype != MIGRATE_RESERVE) {
+ /*
+ * If there is no mirrored memory left, alloc other types
+ * memory. But we should not change the pageblock's
+ * migratetype between mirror and others, so just use
+ * MIGRATE_RECLAIMABLE to retry
+ */
+ if (is_migrate_mirror(migratetype))
+ return __rmqueue(zone, order, MIGRATE_RECLAIMABLE);
+
if (migratetype == MIGRATE_MOVABLE)
page = __rmqueue_cma_fallback(zone, order);
@@ -2872,6 +2884,13 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
if (IS_ENABLED(CONFIG_CMA) && ac.migratetype == MIGRATE_MOVABLE)
alloc_flags |= ALLOC_CMA;
+#ifdef CONFIG_MEMORY_MIRROR
+ /* Alloc mirrored memory for kernel */
+ if (static_key_false(&system_has_mirror)
+ && !(gfp_mask & __GFP_MOVABLE))
+ ac.migratetype = MIGRATE_MIRROR;
+#endif
+
retry_cpuset:
cpuset_mems_cookie = read_mems_allowed_begin();
--
2.0.0
--
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:[~2015-06-27 2:39 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-27 2:19 [RFC v2 PATCH 0/8] mm: mirrored memory support for page buddy allocations Xishi Qiu
2015-06-27 2:23 ` [RFC v2 PATCH 1/8] mm: add a new config to manage the code Xishi Qiu
2015-06-29 6:50 ` Kamezawa Hiroyuki
2015-06-30 2:52 ` Xishi Qiu
2015-06-27 2:24 ` [RFC v2 PATCH 2/8] mm: introduce MIGRATE_MIRROR to manage the mirrored pages Xishi Qiu
2015-06-29 7:32 ` Kamezawa Hiroyuki
2015-06-30 2:45 ` Xishi Qiu
2015-06-30 7:53 ` Kamezawa Hiroyuki
2015-06-30 9:22 ` Xishi Qiu
2015-06-27 2:24 ` [RFC v2 PATCH 3/8] mm: find mirrored memory in memblock Xishi Qiu
2015-06-27 2:25 ` [RFC v2 PATCH 4/8] mm: add mirrored memory to buddy system Xishi Qiu
2015-06-29 7:39 ` Kamezawa Hiroyuki
2015-06-27 2:26 ` [RFC v2 PATCH 5/8] mm: introduce a new zone_stat_item NR_FREE_MIRROR_PAGES Xishi Qiu
2015-06-27 2:27 ` [RFC v2 PATCH 6/8] mm: add free mirrored pages info Xishi Qiu
2015-06-27 2:27 ` Xishi Qiu [this message]
2015-06-29 23:11 ` [RFC v2 PATCH 7/8] mm: add the buddy system interface Luck, Tony
2015-06-30 1:01 ` Kamezawa Hiroyuki
2015-06-30 1:31 ` Xishi Qiu
2015-06-30 2:01 ` Kamezawa Hiroyuki
2015-06-27 2:28 ` [RFC v2 PATCH 8/8] mm: add the PCP interface Xishi Qiu
2015-06-29 15:19 ` [RFC v2 PATCH 0/8] mm: mirrored memory support for page buddy allocations Dave Hansen
2015-06-30 1:26 ` Xishi Qiu
2015-06-30 1:52 ` Dave Hansen
2015-06-30 2:48 ` Xishi Qiu
2015-06-30 9:41 ` Mel Gorman
2015-06-30 10:46 ` Ingo Molnar
2015-06-30 11:53 ` Mel Gorman
2015-06-30 18:12 ` Luck, Tony
2015-07-13 4:56 ` Xishi Qiu
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=558E0A28.6060607@huawei.com \
--to=qiuxishi@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@intel.com \
--cc=guohanjun@huawei.com \
--cc=hpa@zytor.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=leon@leon.nu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=tony.luck@intel.com \
--cc=vbabka@suse.cz \
--cc=xiexiuqi@huawei.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