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.2 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,URIBL_BLOCKED, 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 F1333C433F5 for ; Mon, 13 Sep 2021 12:43:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8862460FBF for ; Mon, 13 Sep 2021 12:43:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8862460FBF 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 E391B900002; Mon, 13 Sep 2021 08:43:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCE5E6B0072; Mon, 13 Sep 2021 08:43:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8930900002; Mon, 13 Sep 2021 08:43:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0154.hostedemail.com [216.40.44.154]) by kanga.kvack.org (Postfix) with ESMTP id B52DD6B0071 for ; Mon, 13 Sep 2021 08:43:40 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2F5962702E for ; Mon, 13 Sep 2021 12:43:40 +0000 (UTC) X-FDA: 78582516600.11.3F6B817 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf10.hostedemail.com (Postfix) with ESMTP id 562086001987 for ; Mon, 13 Sep 2021 12:43:39 +0000 (UTC) Received: from dggeme703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4H7Qz75J3xzQq7M; Mon, 13 Sep 2021 20:39:31 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) 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, 13 Sep 2021 20:43:36 +0800 Subject: Re: [PATCH v2] mm/page_isolation: fix potential missing call to unset_migratetype_isolate() To: David Hildenbrand , Michal Hocko CC: , , , References: <20210913115125.33617-1-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: <6cb372ff-0b68-2143-913e-04ab3e6b4160@huawei.com> Date: Mon, 13 Sep 2021 20:43:35 +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.177.76] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggeme703-chm.china.huawei.com (10.1.199.99) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 562086001987 X-Stat-Signature: uks8igk9u9d7bwyjerp93a686ee6oxqq Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=none) header.from=huawei.com X-HE-Tag: 1631537019-672834 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/13 20:20, David Hildenbrand wrote: > On 13.09.21 14:12, Michal Hocko wrote: >> On Mon 13-09-21 19:51:25, Miaohe Lin wrote: >>> In start_isolate_page_range() undo path, pfn_to_online_page() just ch= ecks >>> 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 cal= l to >>> unset_migratetype_isolate() in undo path and pages will remain isolat= ed >>> unexpectedly. Fix this by calling undo_isolate_page_range() and this = will >>> also help to simplify the code further. >> >> I like the clean up part but is this a real problem that requires CC >> stable? Have you ever seen this to be a real problem? It looks like >> something based on reading the code. I'm sorry but I haven't seen this to be a real problem. It's a theoretica= l bug. >=20 > We discussed that it isn't an issue anymore (we never call it on memory= holes), but might have been an issue on older kernels, back when we didn= 't have the "memory holes" check in the memory offlining path in place. So is the Cc:stable needed in this case? Many thanks for both of you. >=20 > Agreed, these details belong into this description. >=20 >> >>> Fixes: 2ce13640b3f4 ("mm: __first_valid_page skip over offline pages"= ) >>> Signed-off-by: Miaohe Lin >>> Cc: >>> --- >>> v1->v2: >>> =C2=A0=C2=A0 Simplify the code further per David Hildenbrand. >>> --- >>> =C2=A0 mm/page_isolation.c | 20 +++----------------- >>> =C2=A0 1 file changed, 3 insertions(+), 17 deletions(-) >>> >>> diff --git a/mm/page_isolation.c b/mm/page_isolation.c >>> index a95c2c6562d0..f93cc63d8fa1 100644 >>> --- a/mm/page_isolation.c >>> +++ b/mm/page_isolation.c >>> @@ -183,7 +183,6 @@ 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=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned migratetype, int flags) >>> =C2=A0 { >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long pfn; >>> -=C2=A0=C2=A0=C2=A0 unsigned long undo_pfn; >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct page *page; >>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 BUG_ON(!IS_ALIGNED(start_pfn, p= ageblock_nr_pages)); >>> @@ -193,25 +192,12 @@ int start_isolate_page_range(unsigned long star= t_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 pfn < en= d_pfn; >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pfn +=3D= pageblock_nr_pages) { >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 page =3D __fir= st_valid_page(pfn, pageblock_nr_pages); >>> -=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 i= f (set_migratetype_isolate(page, migratetype, flags)) { >>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 undo_pfn =3D pfn; >>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 goto undo; >>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (page && set_migratety= pe_isolate(page, migratetype, flags)) { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u= ndo_isolate_page_range(start_pfn, pfn, migratetype); >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 r= eturn -EBUSY; >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0; >>> -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_= nr_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 c= ontinue; >>> -=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 return -EBUSY; >>> =C2=A0 } >>> =C2=A0 =C2=A0 /* >>> --=C2=A0 >>> 2.23.0 >> >=20 >=20