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 BF68DC433F5 for ; Tue, 31 May 2022 03:12:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1640C6B0072; Mon, 30 May 2022 23:12:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 137076B0073; Mon, 30 May 2022 23:12:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 026D16B0074; Mon, 30 May 2022 23:12:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E64396B0072 for ; Mon, 30 May 2022 23:12:22 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AEE9B60456 for ; Tue, 31 May 2022 03:12:22 +0000 (UTC) X-FDA: 79524564924.12.354B414 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 7D70918001D for ; Tue, 31 May 2022 03:12:07 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7FD9F23A; Mon, 30 May 2022 20:12:21 -0700 (PDT) Received: from [10.162.41.9] (unknown [10.162.41.9]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 07A1B3F66F; Mon, 30 May 2022 20:12:17 -0700 (PDT) Message-ID: <2455da92-6522-6842-6c9c-c153e97d6e27@arm.com> Date: Tue, 31 May 2022 08:42:15 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] mm: page_isolation: use compound_nr() correctly in isolate_single_pageblock() Content-Language: en-US To: Zi Yan , Andrew Morton , David Hildenbrand , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Qian Cai , Vlastimil Babka , Mel Gorman , Eric Ren , Mike Rapoport , Oscar Salvador , Christophe Leroy References: <20220531024450.2498431-1-zi.yan@sent.com> From: Anshuman Khandual In-Reply-To: <20220531024450.2498431-1-zi.yan@sent.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: cgw3ro959hhgp5nfbdnhdqewsr8fskch Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7D70918001D X-HE-Tag: 1653966727-793758 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 5/31/22 08:14, 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 Reviewed-by: Anshuman Khandual > --- > 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;