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 X-Spam-Level: X-Spam-Status: No, score=-17.6 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA30BC433F5 for ; Mon, 6 Sep 2021 09:39:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3EA6160F13 for ; Mon, 6 Sep 2021 09:39:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3EA6160F13 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C83786B0071; Mon, 6 Sep 2021 05:39:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C33DB900002; Mon, 6 Sep 2021 05:39:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFB286B0073; Mon, 6 Sep 2021 05:39:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0182.hostedemail.com [216.40.44.182]) by kanga.kvack.org (Postfix) with ESMTP id 9F9496B0071 for ; Mon, 6 Sep 2021 05:39:04 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 44E5223116 for ; Mon, 6 Sep 2021 09:39:04 +0000 (UTC) X-FDA: 78556649808.23.E42EBB3 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf20.hostedemail.com (Postfix) with ESMTP id 64F1ED0000B1 for ; Mon, 6 Sep 2021 09:39:03 +0000 (UTC) Received: from dggeme703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4H33H65l13z1DGjC; Mon, 6 Sep 2021 17:38:10 +0800 (CST) Received: from [10.174.178.100] (10.174.178.100) by dggeme703-chm.china.huawei.com (10.1.199.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Mon, 6 Sep 2021 17:38:59 +0800 Subject: Re: [PATCH] mm/page_isolation: fix potential missing call to unset_migratetype_isolate() To: David Hildenbrand , CC: , , , References: <20210904092053.33037-1-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: Date: Mon, 6 Sep 2021 17:38:58 +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: Content-Type: text/plain; charset="utf-8" Content-Language: en-US X-Originating-IP: [10.174.178.100] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme703-chm.china.huawei.com (10.1.199.99) X-CFilter-Loop: Reflected Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=none) header.from=huawei.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 64F1ED0000B1 X-Stat-Signature: tuhzxfm57pp76twsb574k5ok1wncjqnh X-HE-Tag: 1630921143-797979 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 2021/9/6 17:27, David Hildenbrand wrote: > On 04.09.21 11:20, Miaohe Lin wrote: >> In start_isolate_page_range() undo path, pfn_to_online_page() just che= cks >> the first pfn in a pageblock while __first_valid_page() will traverse = the >> pageblock until the first online pfn is found. So we may miss the call= to >> unset_migratetype_isolate() in undo path and pages will remain isolate= d >> unexpectedly. Fix this by calling undo_isolate_page_range() and this w= ill >> also help to remove some duplicated codes. >> >> Fixes: 2ce13640b3f4 ("mm: __first_valid_page skip over offline pages") >=20 > While that is true, we shouldn't ever trigger, neither via cma, virtio-= mem nor memory offlining, because essentially all operate on MAX_ORDER -1= -aligned ranges without memory holes. I think this should never trigger too. It's a theoretical issue. So is th= e Fixes tag necessary ? >=20 >> Signed-off-by: Miaohe Lin >> --- >> =C2=A0 mm/page_isolation.c | 9 +-------- >> =C2=A0 1 file changed, 1 insertion(+), 8 deletions(-) >> >> diff --git a/mm/page_isolation.c b/mm/page_isolation.c >> index 471e3a13b541..9bb562d5d194 100644 >> --- a/mm/page_isolation.c >> +++ b/mm/page_isolation.c >> @@ -202,14 +202,7 @@ int start_isolate_page_range(unsigned long start_= pfn, unsigned long end_pfn, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0; >> =C2=A0 undo: >> -=C2=A0=C2=A0=C2=A0 for (pfn =3D start_pfn; >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pfn < undo_pfn; >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pfn +=3D pageblock_n= r_pages) { >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct page *page =3D pfn_= to_online_page(pfn); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!page) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 co= ntinue; >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unset_migratetype_isolate(= page, migratetype); >> -=C2=A0=C2=A0=C2=A0 } >> +=C2=A0=C2=A0=C2=A0 undo_isolate_page_range(start_pfn, undo_pfn, migra= tetype); >> =C2=A0=20 >=20 > It'd be even cleaner to drop the label completely and call it from the = single callsite. We can even avoid undo_pfn ... >=20 > if (page && set_migratetype_isolate(page, migratetype, flags)) { > =C2=A0=C2=A0=C2=A0=C2=A0undo_isolate_page_range(start_pfn, pfn, migrate= type); > =C2=A0=C2=A0=C2=A0=C2=A0return -EBUSY; > } >=20 Looks much better. Will do it later. Many thanks. :) > If pfn =3D=3D start_pfn, undo_isolate_page_range() will simply do nothi= ng. >=20 >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EBUSY; >> =C2=A0 } >> >=20