Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F27DAECAAA1 for ; Mon, 5 Sep 2022 06:53:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 674408D0057; Mon, 5 Sep 2022 02:53:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FC938D0050; Mon, 5 Sep 2022 02:53:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49D3A8D0057; Mon, 5 Sep 2022 02:53:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3436B8D0050 for ; Mon, 5 Sep 2022 02:53:47 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 056671C09B2 for ; Mon, 5 Sep 2022 06:53:47 +0000 (UTC) X-FDA: 79877116494.12.9B967E7 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf12.hostedemail.com (Postfix) with ESMTP id EF0D34007A for ; Mon, 5 Sep 2022 06:53:45 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MLfKG1c7yzlWs6; Mon, 5 Sep 2022 14:50:10 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 5 Sep 2022 14:53:41 +0800 Subject: Re: [PATCH 2/6] mm, hwpoison: use __PageMovable() to detect non-lru movable pages To: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= CC: "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" References: <20220830123604.25763-1-linmiaohe@huawei.com> <20220830123604.25763-3-linmiaohe@huawei.com> <20220905052243.GA1355682@hori.linux.bs1.fc.nec.co.jp> From: Miaohe Lin Message-ID: <1f7ee86e-7d28-0d8c-e0de-b7a5a94519e8@huawei.com> Date: Mon, 5 Sep 2022 14:53:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220905052243.GA1355682@hori.linux.bs1.fc.nec.co.jp> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662360826; a=rsa-sha256; cv=none; b=J6gG+L4c/6WnurMG8XvRQXBgZnFprFI2R0DKnZCPXr254NdagWrz+Nit7iropg3wqof45T BMomNyWLVqqfpW4DRA388UjvwJqSMTYGnIjI3bG83Zrhf0F1w+N9VrOW4cqC6U7ioxanwd bGFYx6iZEx7Tg2QmuhXOgvrFczDmkWI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662360826; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tYJuSQFCRJQdBPYn2lnhUAYJj4ex8M5CGUncYpJoAl4=; b=mSZC9VbVoGJEfEnyHw0RuH87s+FcLZFV4rrULRlAOXy9uZQwUXK6R0KCxVgSp/tLvpUBL9 BGYOaWQEW3u8IT5palxw2n/+q+EVv/2KPhQNfsOmW5YiUijnrBU//vawqKu0dJQYj1pznT r12qotsjmtco5WtQsbvP9NRq1Yopl8Q= X-Stat-Signature: wqzue1pas9h5rzkf5x1gcqqnsei6q7a5 X-Rspamd-Queue-Id: EF0D34007A X-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam01 X-HE-Tag: 1662360825-12948 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2022/9/5 13:22, HORIGUCHI NAOYA(堀口 直也) wrote: > Hi Miaohe, > > On Tue, Aug 30, 2022 at 08:36:00PM +0800, Miaohe Lin wrote: >> It's more recommended to use __PageMovable() to detect non-lru movable >> pages. We can avoid bumping page refcnt via isolate_movable_page() for >> the isolated lru pages. Also if pages become PageLRU just after they're >> checked but before trying to isolate them, isolate_lru_page() will be >> called to do the right work. > > Good point, non-lru movable page is currently handled by isolate_lru_page(), > which always fails. This means that we lost the chance of soft-offlining > for any non-lru movable page. So this patch improves the situation. Non-lru movable page will still be handled by isolate_movable_page() before the code change as they don't have PageLRU set. The current situation is that the isolated LRU pages are passed to isolate_movable_page() uncorrectly. This might not hurt. But the chance that pages become un-isolated and thus available just after checking could be seized with this patch. > >> >> Signed-off-by: Miaohe Lin >> --- >> mm/memory-failure.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/memory-failure.c b/mm/memory-failure.c >> index a923a6dde871..3966fa6abe03 100644 >> --- a/mm/memory-failure.c >> +++ b/mm/memory-failure.c >> @@ -2404,7 +2404,7 @@ EXPORT_SYMBOL(unpoison_memory); >> static bool isolate_page(struct page *page, struct list_head *pagelist) >> { >> bool isolated = false; >> - bool lru = PageLRU(page); >> + bool lru = !__PageMovable(page); > > It seems that PAGE_MAPPING_MOVABLE is not set for hugetlb pages, so > lru becomes true for them. Then, if isolate_hugetlb() succeeds, > inc_node_page_state() is called for hugetlb pages, maybe that's not expected. Yes, that's unexpected. Thanks for pointing this out. > >> >> if (PageHuge(page)) { >> isolated = !isolate_hugetlb(page, pagelist); > } else { > if (lru) > isolated = !isolate_lru_page(page); > else > isolated = !isolate_movable_page(page, ISOLATE_UNEVICTABLE); > > if (isolated) > list_add(&page->lru, pagelist); > } > > if (isolated && lru) > inc_node_page_state(page, NR_ISOLATED_ANON + > page_is_file_lru(page)); > > so, how about moving this if block into the above else block? > Then, the automatic variable lru can be moved into the else block. Do you mean something like below? diff --git a/mm/memory-failure.c b/mm/memory-failure.c index df3bf266eebf..48780f3a61d3 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2404,24 +2404,25 @@ EXPORT_SYMBOL(unpoison_memory); static bool isolate_page(struct page *page, struct list_head *pagelist) { bool isolated = false; - bool lru = !__PageMovable(page); if (PageHuge(page)) { isolated = !isolate_hugetlb(page, pagelist); } else { + bool lru = !__PageMovable(page); + if (lru) isolated = !isolate_lru_page(page); else isolated = !isolate_movable_page(page, ISOLATE_UNEVICTABLE); - if (isolated) + if (isolated) { list_add(&page->lru, pagelist); + if (lru) + inc_node_page_state(page, NR_ISOLATED_ANON + + page_is_file_lru(page)); + } } - if (isolated && lru) - inc_node_page_state(page, NR_ISOLATED_ANON + - page_is_file_lru(page)); - /* * If we succeed to isolate the page, we grabbed another refcount on * the page, so we can safely drop the one we got from get_any_pages(). > > Thanks, > Naoya Horiguchi Thanks a lot for your review and comment on this series, Naoya. Thanks, Miaohe Lin.