From mboxrd@z Thu Jan 1 00:00:00 1970 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 01E9CC433EF for ; Tue, 12 Apr 2022 06:10:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F3336B0071; Tue, 12 Apr 2022 02:10:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A33D6B0073; Tue, 12 Apr 2022 02:10:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66AE56B0074; Tue, 12 Apr 2022 02:10:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 53D6A6B0071 for ; Tue, 12 Apr 2022 02:10:54 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 29A8B81E1A for ; Tue, 12 Apr 2022 06:10:54 +0000 (UTC) X-FDA: 79347203628.05.A452CF6 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf29.hostedemail.com (Postfix) with ESMTP id B8BD3120004 for ; Tue, 12 Apr 2022 06:10:51 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4KcwLY6TH2z1HBhg; Tue, 12 Apr 2022 14:10:13 +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; Tue, 12 Apr 2022 14:10:47 +0800 Subject: Re: [PATCH 3/3] mm/memory-failure.c: dissolve truncated hugetlb page To: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= CC: "akpm@linux-foundation.org" , "shy828301@gmail.com" , "mike.kravetz@oracle.com" , "david@redhat.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" References: <20220407130352.15618-1-linmiaohe@huawei.com> <20220407130352.15618-4-linmiaohe@huawei.com> <20220411131344.GA3188122@hori.linux.bs1.fc.nec.co.jp> <20220412055922.GA3227993@hori.linux.bs1.fc.nec.co.jp> From: Miaohe Lin Message-ID: <20403524-98f8-ce51-65c6-0430a38b14b8@huawei.com> Date: Tue, 12 Apr 2022 14:10:47 +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: <20220412055922.GA3227993@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-Stat-Signature: 5995abw5uuy7phdq4jwzqttnzjwts56x Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: B8BD3120004 X-HE-Tag: 1649743851-167192 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/4/12 13:59, HORIGUCHI NAOYA(堀口 直也) wrote: > On Tue, Apr 12, 2022 at 10:47:53AM +0800, Miaohe Lin wrote: >> On 2022/4/11 21:13, HORIGUCHI NAOYA(堀口 直也) wrote: >>> Hi Miaohe, >>> >>> On Thu, Apr 07, 2022 at 09:03:52PM +0800, Miaohe Lin wrote: >>>> If me_huge_page meets a truncated huge page, hpage won't be dissolved >>> >>> I might not understand correctly what "truncated huge page" means. If it >>> means the page passed to me_huge_page() and truncate_error_page() is called >>> on it, the else branch you're trying to update is not chosen, so maybe it >>> sounds irrelevant to me? Could you elaborate it or share the procedure to >>> reproduce the case you care about? >> >> Sorry for making confusing. What 'truncated hugetlb page' means is that a hugepage is >> truncated but still on the way to free. So HPageMigratable is still set and we might >> come across it here. Does this make sense for you? > > Yes, it does. Thank you. > >> >>> >>>> even if we hold the last refcnt. It's because the truncated huge page >>>> has NULL page_mapping while it's not anonymous page too. Thus we lose >>>> the last chance to dissolve it into buddy to save healthy subpages. >>>> Remove PageAnon check to handle these huge pages too. >>>> >>>> Signed-off-by: Miaohe Lin >>>> --- >>>> mm/memory-failure.c | 3 +-- >>>> 1 file changed, 1 insertion(+), 2 deletions(-) >>>> >>>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c >>>> index bd563f47630c..3f054dbb169d 100644 >>>> --- a/mm/memory-failure.c >>>> +++ b/mm/memory-failure.c >>>> @@ -1046,8 +1046,7 @@ static int me_huge_page(struct page_state *ps, struct page *p) >>>> * hugepage, so we can free and dissolve it into buddy to >>>> * save healthy subpages. >>>> */ >>>> - if (PageAnon(hpage)) >>>> - put_page(hpage); >>> >>> I think that the reason of this "if (PageAnon(hpage))" is to not remove >>> hugepages for hugetlbfs files. Unlike anonymous hugepage, it can be >>> accessed from file after error handling, so we can't simply dissolve it >>> because otherwise another process reading the hugepage sees zeroed one >>> without knowing the memory error. >> >> In this branch, we have precondition that page_mapping is NULL. So it can't be hugepages >> for hugetlbfs files. It should be anonymous hugepages in most cases. If it's not anonymous >> hugepages too, i.e. (!page_mapping(hpage) && !PageAnon(hpage)), it could be free hugepages >> or 'truncated hugetlb page'. But we have already handled the free hugepages case, it should >> be 'truncated hugetlb page' here. Since it's on the way to free, we should put the refcnt >> to increase the chance that we can free and dissolve it into buddy to save healthy subpages. >> Or am I miss something? > > No, it sounds correct. So I agree with removing the "if". Could you also > update the inline comment just above it in the next version? We no longer > need to limitedly mention "anonymous hugepage". Sure. Will do it in next version. Many thanks! > > Thanks, > Naoya Horiguchi >