From patchwork Wed Sep 13 20:12:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 139099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp94359vqb; Wed, 13 Sep 2023 14:23:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIywQyTCXSxNGi7Ynn1qAtWEbjz2yK+bGZ4sfQhycKXtaivCJcBQ4cdpWFk+zjCB68Ig39 X-Received: by 2002:a17:902:f688:b0:1c3:3b5c:1fbf with SMTP id l8-20020a170902f68800b001c33b5c1fbfmr5211770plg.10.1694640194867; Wed, 13 Sep 2023 14:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694640194; cv=none; d=google.com; s=arc-20160816; b=zHt98yFIm6cFhiw4Q7dlYFOiLymxMs1fRl+Y/OMGCjk0eAtckE/m1P7xkSWXXmkVCK iK7NWkLmXOtMlVZKzmafTvc/Zw8dvHVl6AY/ywAqsS15zj2yc/bP2r4DnAUkxCxsj2Te 44PFqYMoK1mzbQqN8ZmdrCvxKUpKKtrTluJdb0YzaZU6dHBEDRXcEgrIpfzhkDgWXWx4 QEB8ErCoww+86IH6pVKdeehiDAkC+CVwJejW6/K1yyUS4PcZjZSmBWH+H4Oc2Hm3ofRV vGWeCZB+RpJ0b5iRZYPKoGldqwQbBLaaX9+jmBfqrW2b1LtJs81VIBi0PGHbLX0RVl+T zcog== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=0WyzrkiVwl0HyDd6Aci2MQZZb/Gy7N43VoXzZpGq6Jc=; fh=uXOOnG6dSiAFwWm6vSsvJiwW7q8GOjY1G0eNovT28gQ=; b=IX/nzLIxQKzt1rUosyG4Yd2g3DVs7mDMoOa1rlYViXkpNHKMcwpGL+o/5kjFFhSNm2 sEL+1F5O3p+lK/PnayFIvNzsR00DZSaHT/0XyB5Z2uV8r8R8KLLM2y5LtEFndxWQPJVY xPF7xoeAhMptfS4hAAZOU1eQnZDa3urE+YepzrGnx1HDSKC2QrTmkhAIutxEhz4DH82c KC9pFIYyz5JnIcuwPYqGgvsIERomiXMUSyFzrkinG3avPaUd4vS+WYKGDhsdWPm6uH0E BK081juZzBdDGkUhQSGj3bJ3QMfdrcahRg0cJKQADWtZk2S9IxJjV8TCDUWfdF201dit z8Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=naPdsB3d; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="gUo/FnX8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ay6-20020a1709028b8600b001b9d800b487si153772plb.87.2023.09.13.14.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 14:23:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=naPdsB3d; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="gUo/FnX8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A20D681DDD22; Wed, 13 Sep 2023 13:13:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232417AbjIMUNc (ORCPT + 34 others); Wed, 13 Sep 2023 16:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232241AbjIMUN3 (ORCPT ); Wed, 13 Sep 2023 16:13:29 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B10BF1BCF; Wed, 13 Sep 2023 13:13:20 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 25AC7320098D; Wed, 13 Sep 2023 16:13:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 13 Sep 2023 16:13:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694635998; x=1694722398; bh=0WyzrkiVwl0HyDd6Aci2MQZZb/Gy7N43VoX zZpGq6Jc=; b=naPdsB3dfR1YBhvIR8pdDs7slpAMXOvSUBxRMTlGo8NMy8jMZ/E vvG+mB2vn+0vCRBIQ5YzI14b/fcYj4pef1sM4+aIRJqZBIfN+fcDie6TsW9EJ2J1 iYZUct01uyaBS4lO8rjJWS7cQxtE6cbWBOvTKAIXfXFjlN6o5NoQjTt7ALDP/R9C 9DEIHh0t9nSkJPu06rigfkgSMV3jWGYmLfnfshlJ7HpRzXzC6jxLshs+2cXUDdHT F/6Re+X3Zd4Jhi9DPfLeg3ccZFx2Cx8gUoj03MrSB0oaDFntrPUqvXY+rBFe9VfI nFi8rN5IYyskwETE285/XelyAcZ6BaMMvOg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :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=fm2; t= 1694635998; x=1694722398; bh=0WyzrkiVwl0HyDd6Aci2MQZZb/Gy7N43VoX zZpGq6Jc=; b=gUo/FnX8pMldlTdPvkX01eISqaj/5SU9K0sixsYw5fh7hOuaxVg wnIQeTY3i4rUcpwpGV1sFA6LoWS5ojkvkzq/9GFLTbqE5oSycXU4LbcrfWfiZf7N gjJT/7AdYJk5QwTexrGkKZoSzpmMgmw6hMByVhg+5y1Jqep0E8Apl/M/xOafFppW Ph3hI002dwiCvgE+UsQWXrSNZ7y5N8N7e20KZNeP3xCLVqX6FjxxzrR5GMqPAfWh fU9u6+oJ2bR2ppwbvmVSEuw7lbT+XWQPA/K0N54soWxj2Osls+9AhVVXCpGed41k Wrfmg5nfB6k6EzSq4oO+nKkhwNNaCSs5s9A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgudegiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enogfuohhrthgvugftvggtihhpvdculdegtddmnecujfgurhephffvvefufffkofgjfhhr ggfgsedtqhertdertddtnecuhfhrohhmpegkihcujggrnhcuoeiiihdrhigrnhesshgvnh htrdgtohhmqeenucggtffrrghtthgvrhhnpeeggeehudfgudduvdelheehteegledtteei veeuhfffveekhfevueefieeijeegvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 16:13:17 -0400 (EDT) From: Zi Yan To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Zi Yan , Andrew Morton , Thomas Bogendoerfer , "Matthew Wilcox (Oracle)" , David Hildenbrand , Mike Kravetz , Muchun Song , "Mike Rapoport (IBM)" , stable@vger.kernel.org, Muchun Song Subject: [PATCH v3 3/5] mm/memory_hotplug: use pfn math in place of direct struct page manipulation. Date: Wed, 13 Sep 2023 16:12:46 -0400 Message-Id: <20230913201248.452081-4-zi.yan@sent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913201248.452081-1-zi.yan@sent.com> References: <20230913201248.452081-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Sep 2023 13:13:44 -0700 (PDT) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776959036703659938 X-GMAIL-MSGID: 1776959036703659938 From: Zi Yan When dealing with hugetlb pages, manipulating struct page pointers directly can get to wrong struct page, since struct page is not guaranteed to be contiguous on SPARSEMEM without VMEMMAP. Use pfn calculation to handle it properly. Fixes: eeb0efd071d8 ("mm,memory_hotplug: fix scan_movable_pages() for gigantic hugepages") Cc: Signed-off-by: Zi Yan Reviewed-by: Muchun Song Acked-by: David Hildenbrand --- mm/memory_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 1b03f4ec6fd2..3b301c4023ff 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1689,7 +1689,7 @@ static int scan_movable_pages(unsigned long start, unsigned long end, */ if (HPageMigratable(head)) goto found; - skip = compound_nr(head) - (page - head); + skip = compound_nr(head) - (pfn - page_to_pfn(head)); pfn += skip - 1; } return -ENOENT;