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 377E8C433F5 for ; Tue, 31 May 2022 02:22:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8105F6B0072; Mon, 30 May 2022 22:22:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 799116B0073; Mon, 30 May 2022 22:22:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65F2B6B0074; Mon, 30 May 2022 22:22:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 576666B0072 for ; Mon, 30 May 2022 22:22:21 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2ECFD31D11 for ; Tue, 31 May 2022 02:22:21 +0000 (UTC) X-FDA: 79524438882.04.BA29C6D Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf04.hostedemail.com (Postfix) with ESMTP id E9ED340044 for ; Tue, 31 May 2022 02:22:01 +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 7F95A23A; Mon, 30 May 2022 19:22:19 -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 0DEAE3F66F; Mon, 30 May 2022 19:22:17 -0700 (PDT) Message-ID: Date: Tue, 31 May 2022 07:52:14 +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: [RFC] mm/page_isolation: Fix an infinite loop in isolate_single_pageblock() Content-Language: en-US To: Zi Yan Cc: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org References: <20220530115027.123341-1-anshuman.khandual@arm.com> From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf04.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: rspam12 X-Rspamd-Queue-Id: E9ED340044 X-Stat-Signature: yp95wdu1gmyic3juai11zfto8ou85opy X-HE-Tag: 1653963721-500275 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/30/22 19:23, Zi Yan wrote: > On 30 May 2022, at 7:50, Anshuman Khandual wrote: > >> HugeTLB allocation (32MB pages on 4K base page) via sysfs on arm64 platform >> is getting stuck in isolate_single_pageblock(), because of an infinite loop >> Because head_pfn always evaluate the same, so does pfn, and the outer loop >> never exits. Dropping the relevant code block, which seems redundant, makes >> the problem go away. > > Thanks for the report. > >> >> Cc: Andrew Morton >> Cc: Zi Yan >> Cc: linux-mm@kvack.org >> Cc: linux-kernel@vger.kernel.org >> Fixes: b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity") >> Signed-off-by: Anshuman Khandual >> --- >> I am not sure about this fix, and also did not find much time today to >> debug any further. There are much code changes around this function in >> recent days. This problem is present on latest mainline kernel. >> >> - Anshuman >> >> mm/page_isolation.c | 4 ---- >> 1 file changed, 4 deletions(-) >> >> diff --git a/mm/page_isolation.c b/mm/page_isolation.c >> index 6021f8444b5a..b0922fee75c1 100644 >> --- a/mm/page_isolation.c >> +++ b/mm/page_isolation.c >> @@ -389,10 +389,6 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags, >> struct page *head = compound_head(page); >> unsigned long head_pfn = page_to_pfn(head); >> >> - if (head_pfn + nr_pages <= boundary_pfn) { >> - pfn = head_pfn + nr_pages; >> - continue; >> - } >> #if defined CONFIG_COMPACTION || defined CONFIG_CMA >> /* >> * hugetlb, lru compound (THP), and movable compound pages >> -- >> 2.20.1 > > Can you try the patch below to see if it fixes the issue? Thanks. > > 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; > > Yes, this does solve the problem. I guess nr_pages should have been derived from the compound head itself for it be meaningful (i.e > 1). I assume you will send a fix patch with appropriate write up that describes this problem. - Anshuman