Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2759751rwb; Mon, 5 Sep 2022 00:33:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR66ejIvyE5y1Ky1gHQuLph/ld6+O+8t0WNRfMSeo99Fey758IIAMIWH2dF0qLaNhVcDYXjb X-Received: by 2002:a17:903:2310:b0:175:4f33:4ddf with SMTP id d16-20020a170903231000b001754f334ddfmr22388885plh.32.1662363208996; Mon, 05 Sep 2022 00:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662363208; cv=none; d=google.com; s=arc-20160816; b=c2MmA6F9gtr2vgnCjJ/yCFoNsZ4mtexFBgLpbX9rztuTIzwxqaryP1sOSP+fnGO0Fc 87X9hLHPhYzQ5hjrKuMTiRn15oH0fo8O4YaLRS025Yk7YkV3ckOLkfqJFTp0WTEXhDhH YhTjU3WtTKN8/9cOcw00h54RAicImFnCilx8SF1j9lSIvf5TYBdPJp/hlDA3AcFbJquO s+T+rAZMeeus2nolnCAsWOMymeYR1hZwsLPL9iHQTezVVZH1KT2TYJw7PLTYyWWXH2TN eMh2tIUGeMY415KpUpjTKqKLJiCjs21U0j7SiXB6/p3cfEftgjTUbR44Zv7TeyFLag6W gGuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=9h702q5BsKEnXQf5chaBBWtY2p15Ez3K2eEnRtCQe4A=; b=cV4OuMstjabhVrp47/kNyAptlgOBlRbn6mqb31oPhffx2LWh4UfvII1zA9K09E9pnJ JVTLZtzH8mailkd9d1QhFW8vFLslEwlAgZsNcEUEOgQuJz42wVo09+72zXH4w09TxEmo VGf/pVmQe70ABawgba3z+XAwlkFEOIGXPhIpdpgumGRniC0NNHcmIUw+QzqDKg7dVxKJ IBFX/sWXk8mHzuAonZWn6XyfLnrFXRtXFn1HAORQpFMwfOUOlwqAgBgAiujX1dYbOjU7 vtCSGUSyYpmc/E/f697p5quneTJOv1HJaWX5vdsrmommKNIEUyaUaZCGg2ZFEBGrKlVr lApQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3-20020a170902a60300b0016d17cde503si9084844plq.143.2022.09.05.00.33.18; Mon, 05 Sep 2022 00:33:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236393AbiIEHaM (ORCPT + 99 others); Mon, 5 Sep 2022 03:30:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234585AbiIEH3j (ORCPT ); Mon, 5 Sep 2022 03:29:39 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79C706456 for ; Mon, 5 Sep 2022 00:29:37 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MLg6g4zZGzmV65; Mon, 5 Sep 2022 15:26:03 +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 15:29:35 +0800 Subject: Re: [PATCH 2/6] mm, hwpoison: use __PageMovable() to detect non-lru movable pages To: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , "akpm@linux-foundation.org" CC: "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> <1f7ee86e-7d28-0d8c-e0de-b7a5a94519e8@huawei.com> <20220905071542.GA1364147@hori.linux.bs1.fc.nec.co.jp> From: Miaohe Lin Message-ID: Date: Mon, 5 Sep 2022 15:29:34 +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: <20220905071542.GA1364147@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: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/9/5 15:15, HORIGUCHI NAOYA(堀口 直也) wrote: > On Mon, Sep 05, 2022 at 02:53:41PM +0800, Miaohe Lin wrote: >> 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. > > OK, thank you for correct me. > >> >>> >>>> >>>> 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(). >> > > Yes, that's exactly what I thought of. Hi Andrew: The above code change could be applied to the mm-tree directly. Or should I resend the v2 series? Which one is more convenient for you? They're all fine to me. ;) Many thanks both. Thanks, Miaohe Lin