From patchwork Tue May 31 02:44:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12865039 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 00B19C433F5 for ; Tue, 31 May 2022 02:45:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E1E26B0074; Mon, 30 May 2022 22:45:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 795B86B0078; Mon, 30 May 2022 22:45:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 633656B007D; Mon, 30 May 2022 22:45:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4E1866B0074 for ; Mon, 30 May 2022 22:45:00 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1BB16349CA for ; Tue, 31 May 2022 02:45:00 +0000 (UTC) X-FDA: 79524495960.18.DE30D62 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf22.hostedemail.com (Postfix) with ESMTP id 425A8C0052 for ; Tue, 31 May 2022 02:44:56 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id CDBEB3200954; Mon, 30 May 2022 22:44:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 30 May 2022 22:44:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:reply-to:sender:subject :subject:to:to; s=fm1; t=1653965096; x=1654051496; bh=xLBULzBh5o Hqd8PDcEQQTLRKpqJ5mFh2Oa5dm6Do8/E=; b=FG2WFsU9TrYfVAoOnfaPdPB1XY sDzGhRYv0B6tCLQzphZMWNs6qhdRHL6zPercheXJl8G++J3MNBpNzJCM6CkkigoL DGF/dsHb1do2S/dJQgieKEsZ7ULOSsmeDuewOzbKDEvXx6uYTxdp1Zd/CSgBmMPN YkpSBzkRli9lFkzTUoDKXSHVwUwYrxYkaCowryVMzX5vahYAYtV72CFH7YLc5l+z rQ5D576bkIFFxku3W9AyvBfXRCd/bid7cV0vVjIYmgAevx7vHIy3XTte4E9mw2Zd qAG37luJNc+/91y/+csrahP5HEASi+C6G7kgme7dkvaRwOjlfYQr1dYF3tYg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1653965096; x=1654051496; bh=xLBULzBh5oHqd8PDcEQQTLRKpqJ5 mFh2Oa5dm6Do8/E=; b=w+0bnPYtu5raQinXgwH+c1kagKzA5zbjw06Q8iSH4SKS DEwQ3kOCCff0tw+kan0iVUieAtqCUgniC4OVM/BSxuVS+47sruGK0FO73lS1gCZH 1ShT68bhoXHYFbdGjf0tGYIKaryF8II00ZK0VfgdtVYKtvQylJNF8fB2L1fkCKso uGd4cvQf7zgetBqzNy4l/+QOICp4RPlH1vjotwc5WiCmHFu8ioJzH5R9KRQLxMta 65sjaI3m+dm2BA/h1oApXuMqxnfy+eQatEbyVJjIn24M2eJJXDmC0xmRTXT2LP3p PLdBKm1A7KLiTyyd+GB8xBtF1Umgs2cMgMskuh6vIg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrkeejgdeifecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkfforhgggfestdhqredtredttdenucfhrhhomhepkghiucgjrghn uceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepvdeiuedthe dttdfhgeevkeeuveefvdeuheejledtvefgjeetkedugfdvleevkeffnecuffhomhgrihhn pehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 May 2022 22:44:55 -0400 (EDT) From: Zi Yan To: 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 , Zi Yan , Anshuman Khandual Subject: [PATCH] mm: page_isolation: use compound_nr() correctly in isolate_single_pageblock() Date: Mon, 30 May 2022 22:44:50 -0400 Message-Id: <20220531024450.2498431-1-zi.yan@sent.com> X-Mailer: git-send-email 2.35.1 Reply-To: Zi Yan MIME-Version: 1.0 X-Stat-Signature: 73kgziibh1bwd65szqsz4uikhn1yctwx X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=FG2WFsU9; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=w+0bnPYt; spf=pass (imf22.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.19 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 425A8C0052 X-HE-Tag: 1653965096-13210 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: 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 Acked-by: Muchun Song Reviewed-by: Oscar Salvador 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;