From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751333AbdAWOuV (ORCPT ); Mon, 23 Jan 2017 09:50:21 -0500 Received: from smtpbg202.qq.com ([184.105.206.29]:56801 "EHLO smtpbg202.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750784AbdAWOuV (ORCPT ); Mon, 23 Jan 2017 09:50:21 -0500 X-QQ-mid: esmtp32t1485183013t2205ex7s X-QQ-SSF: 01000000000000503F100000000000V X-QQ-FEAT: 7dyrQdWWwZIbfngM2HfLLZ9DIWLu76IQ/HmPbzr06WCjeU6EFfnSbOweEIDJq +jh7aoTGVlMZDiah1q2bS1AQmETR/d0tCHA16XVRF3xZbuyPuQoPaspH4lUnXwISnNivQbM 7S/1mtW7vrcYmnz5xlXP6wRgNU/pS3YouYi0PtjWFRfyCfNQ8ZRmpU2RTqOEincouBUDQHb F3Fyb7pXFGXJ1uGUBGsuOlg6bjlm+8RXf+ZR3H6q4SOcLU9VpJbe1F7yQ/VpDngg= X-QQ-GoodBg: 0 From: ysxie@foxmail.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: n-horiguchi@ah.jp.nec.com, mhocko@suse.com, akpm@linux-foundation.org, minchan@kernel.org, vbabka@suse.cz, guohanjun@huawei.com, qiuxishi@huawei.com Subject: [PATCH v3] HWPOISON: soft offlining for non-lru movable page Date: Mon, 23 Jan 2017 22:50:10 +0800 Message-Id: <1485183010-9276-1-git-send-email-ysxie@foxmail.com> X-Mailer: git-send-email 1.9.1 X-QQ-SENDSIZE: 520 Feedback-ID: esmtp:foxmail.com:bgforeign:bgforeign1 X-QQ-Bgrelay: 1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yisheng Xie This patch is to extends soft offlining framework to support non-lru page, which already support migration after commit bda807d44454 ("mm: migrate: support non-lru movable page migration") When memory corrected errors occur on a non-lru movable page, we can choose to stop using it by migrating data onto another page and disable the original (maybe half-broken) one. Signed-off-by: Yisheng Xie Suggested-by: Michal Hocko Suggested-by: Minchan Kim Acked-by: Naoya Horiguchi --- v2: delete function soft_offline_movable_page() and hanle non-lru movable page in __soft_offline_page() as Michal Hocko suggested. v3: delete some unneed limitation and use !__PageMovable instead of PageLRU after isolate page to avoid isolated count mismatch, as Minchan Kim's suggestion. mm/memory-failure.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index f283c7e..3f3cfd4 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1527,7 +1527,8 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) { int ret = __get_any_page(page, pfn, flags); - if (ret == 1 && !PageHuge(page) && !PageLRU(page)) { + if (ret == 1 && !PageHuge(page) && + !PageLRU(page) && !__PageMovable(page)) { /* * Try to free it. */ @@ -1649,7 +1650,10 @@ static int __soft_offline_page(struct page *page, int flags) * Try to migrate to a new page instead. migrate.c * handles a large number of cases for us. */ - ret = isolate_lru_page(page); + if (PageLRU(page)) + ret = isolate_lru_page(page); + else + ret = !isolate_movable_page(page, ISOLATE_UNEVICTABLE); /* * Drop page reference which is came from get_any_page() * successful isolate_lru_page() already took another one. @@ -1657,18 +1661,20 @@ static int __soft_offline_page(struct page *page, int flags) put_hwpoison_page(page); if (!ret) { LIST_HEAD(pagelist); - inc_node_page_state(page, NR_ISOLATED_ANON + - page_is_file_cache(page)); + /* + * After isolated lru page, the PageLRU will be cleared, + * so use !__PageMovable instead for LRU page's mapping + * cannot have PAGE_MAPPING_MOVABLE. + */ + if (!__PageMovable(page)) + inc_node_page_state(page, NR_ISOLATED_ANON + + page_is_file_cache(page)); list_add(&page->lru, &pagelist); ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, MIGRATE_SYNC, MR_MEMORY_FAILURE); if (ret) { - if (!list_empty(&pagelist)) { - list_del(&page->lru); - dec_node_page_state(page, NR_ISOLATED_ANON + - page_is_file_cache(page)); - putback_lru_page(page); - } + if (!list_empty(&pagelist)) + putback_movable_pages(&pagelist); pr_info("soft offline: %#lx: migration failed %d, type %lx\n", pfn, ret, page->flags); -- 1.9.1