Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5784637ioo; Wed, 1 Jun 2022 12:32:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0Hnb/RFFSB0q11DSsNvFkoq/iFfbY2iHzMHUMyev0oR/fzNii8ogugb6iJPpqMsyK8NBk X-Received: by 2002:a17:90a:ba15:b0:1c6:7873:b192 with SMTP id s21-20020a17090aba1500b001c67873b192mr1004132pjr.76.1654111925403; Wed, 01 Jun 2022 12:32:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654111925; cv=none; d=google.com; s=arc-20160816; b=NJQ53hjEHoUSIWV/CJ8KQXrzZIuacZeo49Xxp3XAaD+BKao66pYvwoUq4HDlasH2m0 EjPRlU90mgjT2IHEOXcLufY+AMqLvSeA5tb8OuTwpnHQeikIKDP9Uk27ls3hHaZhU1en 15IxHBmaKM95nd/PSDJcLP2POMUTliwnFkIfMEa6Ld5XVY3v2UwUFSbC6HafKSq+aFRh OjWACYpa02b49K3UlbkyjJCSk2SyZgOA8W3CfY9I6R7aLuohJCvqIDyvXk6lwR7+YqYC LeLf20mfy+faDfH2oFiuOFrKXK7XemlB1mcrLknzpJVsJ/oCIDk5eAt/wgyAl6zh3pgX El/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=xLBULzBh5oHqd8PDcEQQTLRKpqJ5mFh2Oa5dm6Do8/E=; b=XdZpHwIPTv+OMp8/bZPmpAYfGhAUR64tm2vax3IL5Sewlsya/d4KCCRftr5GGr0y1s GlKbBuRCuLYCn5PeXplJvQmBouiSulR6VNf+j5WM0/QBVC2LNbW5Qp6GhvB/BYUWmJVy GYAaynV6sNT0SOP+yr/Dx7UJek2EPmXPYIhW0Rb+UTVWz1w5IQJ6RpURygN8NJszKDYY Va5wdEU1N9lxpewuXWJrZGw8eq9CZv6boYkAnu7O8541JNAW1DN+5JHp82VAAG1lYn+4 WV/vg6IzZmieHHgvjUXaNn3HU9jwL4a5IulLn5uDAFQCVqcqF/q2xrDPE5X/3eDehufC 3T6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (expired) header.i=@sent.com header.s=fm1 header.b=FG2WFsU9; dkim=neutral (expired) header.i=@messagingengine.com header.s=fm1 header.b=w+0bnPYt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sent.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s11-20020a63214b000000b003c6dde2ad19si3291475pgm.26.2022.06.01.12.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:32:05 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=neutral (expired) header.i=@sent.com header.s=fm1 header.b=FG2WFsU9; dkim=neutral (expired) header.i=@messagingengine.com header.s=fm1 header.b=w+0bnPYt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E6FF3880C2; Wed, 1 Jun 2022 12:02:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243630AbiEaCpC (ORCPT + 99 others); Mon, 30 May 2022 22:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232746AbiEaCpB (ORCPT ); Mon, 30 May 2022 22:45:01 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FD1394185 for ; Mon, 30 May 2022 19:45:00 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,SPOOFED_FREEMAIL_NO_RDNS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 granula= rity") Reported-by: Anshuman Khandual Link: https://lore.kernel.org/linux-mm/20220530115027.123341-1-anshuman.kha= ndual@arm.com/ Signed-off-by: Zi Yan --- 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 bound= ary_pfn, int flags, * above do the rest. If migration is not possible, just fail. */ if (PageCompound(page)) { - unsigned long nr_pages =3D compound_nr(page); struct page *head =3D compound_head(page); unsigned long head_pfn =3D page_to_pfn(head); + unsigned long nr_pages =3D compound_nr(head); =20 if (head_pfn + nr_pages <=3D boundary_pfn) { pfn =3D head_pfn + nr_pages; --=20 2.35.1