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 E69F3C433EF for ; Tue, 31 May 2022 09:05:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C7976B0078; Tue, 31 May 2022 05:05:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64C656B007B; Tue, 31 May 2022 05:05:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53AB96B007D; Tue, 31 May 2022 05:05:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4491D6B0078 for ; Tue, 31 May 2022 05:05:45 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1A7B360440 for ; Tue, 31 May 2022 09:05:45 +0000 (UTC) X-FDA: 79525455450.23.D3239BA Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf11.hostedemail.com (Postfix) with ESMTP id 50D3E40023 for ; Tue, 31 May 2022 09:05:36 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LC5v46cZ8zjXD9; Tue, 31 May 2022 17:04:32 +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, 31 May 2022 17:05:40 +0800 Subject: Re: [PATCH] mm: page_isolation: use compound_nr() correctly in isolate_single_pageblock() To: Zi Yan CC: , Qian Cai , Vlastimil Babka , Mel Gorman , Eric Ren , Mike Rapoport , Oscar Salvador , Christophe Leroy , Anshuman Khandual , Andrew Morton , David Hildenbrand , References: <20220531024450.2498431-1-zi.yan@sent.com> From: Miaohe Lin Message-ID: <8cfbab19-8feb-796d-9951-a07fb4855433@huawei.com> Date: Tue, 31 May 2022 17:05:40 +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: <20220531024450.2498431-1-zi.yan@sent.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 50D3E40023 X-Stat-Signature: ned7snyyfepftkj9kd7mg835r766ihfd Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-HE-Tag: 1653987936-380691 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/5/31 10:44, Zi Yan wrote: > From: Zi Yan > > When compound_nr(page) was used, page was not guaranteed to be the head > of the compound page and it could cause an infinite loop. Fix it by calling > it on the head page. > > Fixes: b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity") > Reported-by: Anshuman Khandual > Link: https://lore.kernel.org/linux-mm/20220530115027.123341-1-anshuman.khandual@arm.com/ > Signed-off-by: Zi Yan LGTM. Thanks! Reviewed-by: Miaohe Lin > --- > mm/page_isolation.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/page_isolation.c b/mm/page_isolation.c > index 6021f8444b5a..d200d41ad0d3 100644 > --- a/mm/page_isolation.c > +++ b/mm/page_isolation.c > @@ -385,9 +385,9 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags, > * above do the rest. If migration is not possible, just fail. > */ > if (PageCompound(page)) { > - unsigned long nr_pages = compound_nr(page); > struct page *head = compound_head(page); > unsigned long head_pfn = page_to_pfn(head); > + unsigned long nr_pages = compound_nr(head); > > if (head_pfn + nr_pages <= boundary_pfn) { > pfn = head_pfn + nr_pages; >