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 E5E87C433EF for ; Mon, 7 Mar 2022 03:44:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E60E8D0002; Sun, 6 Mar 2022 22:44:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 397038D0001; Sun, 6 Mar 2022 22:44:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25CA48D0002; Sun, 6 Mar 2022 22:44:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0212.hostedemail.com [216.40.44.212]) by kanga.kvack.org (Postfix) with ESMTP id 1476E8D0001 for ; Sun, 6 Mar 2022 22:44:27 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BCD9E1817C78B for ; Mon, 7 Mar 2022 03:44:26 +0000 (UTC) X-FDA: 79216197732.20.381C478 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf08.hostedemail.com (Postfix) with ESMTP id A81EE160002 for ; Mon, 7 Mar 2022 03:44:25 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KBknJ70F0zdZwS; Mon, 7 Mar 2022 11:43:00 +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.2308.21; Mon, 7 Mar 2022 11:44:21 +0800 Subject: Re: [PATCH 1/4] mm/memory-failure.c: fix race with changing page compound again To: Mike Kravetz , =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= CC: "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" References: <20220228140245.24552-1-linmiaohe@huawei.com> <20220228140245.24552-2-linmiaohe@huawei.com> <20220304082624.GA3778609@hori.linux.bs1.fc.nec.co.jp> <79f79813-bb9a-bfff-0837-a24d14da0b19@oracle.com> From: Miaohe Lin Message-ID: <999a0f88-9465-0c93-e922-8aa80fa64f81@huawei.com> Date: Mon, 7 Mar 2022 11:44:20 +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: <79f79813-bb9a-bfff-0837-a24d14da0b19@oracle.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: A81EE160002 X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: s386w3mw4f9o153nm1p919pg8zra3pa6 X-HE-Tag: 1646624665-140035 Content-Transfer-Encoding: quoted-printable 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/3/5 3:32, Mike Kravetz wrote: > On 3/4/22 00:26, HORIGUCHI NAOYA(=E5=A0=80=E5=8F=A3 =E7=9B=B4=E4=B9=9F)= wrote: >> On Mon, Feb 28, 2022 at 10:02:42PM +0800, Miaohe Lin wrote: >>> There is a race window where we got the compound_head, the hugetlb pa= ge >>> could be freed to buddy, or even changed to another compound page jus= t >>> before we try to get hwpoison page. If this happens, just bail out. >> >> I think that when some hugetlb page is about to change into other type= /size >> of compound page, it has to go through buddy allocator because hugetlb= pages >> are maintained in separate memory allocator and they never change into= other >> normal state directly. memory_failure_hugetlb() takes refcount before >> lock_page(), so the hugetlb page seems not change between get_hwpoison= _page() >> and lock_page(). So it this new check really necessary? >=20 > A hugetlb page could change size without going through buddy via the ne= w > demote functionality [1]. Only hugetlb pages on the hugetlb free list = can > be demoted. =20 >=20 > We should not demote a page if poison is set. However, there is no che= ck in > the demote code. IIUC, poison is set early in the memory error handlin= g > process, even before taking ref on page. Demote code needs to be fixed= so > that poisoned pages are not demoted. I can do that. >=20 > With this change in place, then I think Naoya's statement that hugetlb = pages > can not change state is correct and this patch is not necessary. >=20 Sorry for my confusing commit words. What I mean to tell is indeed the be= low race: CPU 1 CPU 2 memory_failure_hugetlb struct page *head =3D compound_head(p); hugetlb page is freed to buddy, or even changed to another compound page as we haven't held the page refcnt now get_hwpoison_page -- page is not what we want now... Does this make sense for both of you? Many thanks for comment and reply! = :) > Does that sound reasonable? >=20 > [1] https://lore.kernel.org/linux-mm/20211007181918.136982-1-mike.krave= tz@oracle.com/ This is really a nice feature. Thanks. >=20