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: 13383747 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 9C544EE020C for ; Wed, 13 Sep 2023 20:13:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 219706B028D; Wed, 13 Sep 2023 16:13:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 17DE86B028E; Wed, 13 Sep 2023 16:13:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0F7F6B028F; Wed, 13 Sep 2023 16:13:23 -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 E285B6B028D for ; Wed, 13 Sep 2023 16:13:23 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B649140384 for ; Wed, 13 Sep 2023 20:13:23 +0000 (UTC) X-FDA: 81232673886.01.4CE97A6 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf30.hostedemail.com (Postfix) with ESMTP id 7F1F58001B for ; Wed, 13 Sep 2023 20:13:21 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=naPdsB3d; dkim=pass header.d=messagingengine.com header.s=fm2 header.b="gUo/FnX8"; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf30.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.19 as permitted sender) smtp.mailfrom=zi.yan@sent.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694636001; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0WyzrkiVwl0HyDd6Aci2MQZZb/Gy7N43VoXzZpGq6Jc=; b=AlL19VVgArHel0UsJ6uuQQAzhcl4OsW5S45QDDsfw9xxa9dyAHvvtym8qrTNZI2kIUl3rR G4pA5eL2kaoG/x0FyLJZm73Jk4D7DzV+Ycu7j/154hMEEyur2Z0MfmQuVoYVFNeNFaRKSA RWRce24siJmE/1+oP4A6Gg2qRf3tbHw= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=naPdsB3d; dkim=pass header.d=messagingengine.com header.s=fm2 header.b="gUo/FnX8"; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf30.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.19 as permitted sender) smtp.mailfrom=zi.yan@sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694636001; a=rsa-sha256; cv=none; b=gf+ejZyT4ov8cZBuT9aI4R4y1DIL+EC+yem6S5NzY/Z+tQmpJUWU7wiyGtprAWhqiYGPn+ ZuOBmQJ/MJYRxs1F0h74nqrLsezO7xJcvx0CrKB/vS8ZUUR2m5oglMW5bQJSQ9hCiwOeKW N7khsHBxqLUSgnhL9Kc3nEDYXNwZTz0= 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 X-Rspamd-Queue-Id: 7F1F58001B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fopmamqdx5okc6efywitrhq1qfw9djqu X-HE-Tag: 1694636001-268019 X-HE-Meta: U2FsdGVkX19+sYHZHbmHyHmtVG6psQucvKnJ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iikzwe0/JZWzQkfrnWtCz9x4S2Mt6RMw1kzcrPOF4lzBtMXh1/Gx1p4Jd65BZ+7ZF5nNxPCDWtEcmGjTVSCafTuwpzNN2ndgdKJEAsZ0J9kVGC/Zo9+ws9YFyr5rsYm9X2+w0RUtKUMl3CNc3Mx0WpHG7NOLp/4d0t4ceNbHSMh0ylkSmm5apqw1IyFtnD0nDdnjffe1L0XZZYWSAWMPCFcIXjy8EG48cdeWUG9Y6n+zijDYfRw5nnliIV6WlK6TsEHYgeLd8MLlfctDkF6DwwoJJHB4sQxRfqHto5HXgiy/96/mN56bCU2cCn/RrNEloV9EVbxrbuRCATi8J5b+canipCFzAzrLZXIxES38k6tnFRBxLMtWpnYeTS+pHVAjeYs5YCoxlySPWSSTny2nJj11hG3T44JP8bP55xNze+nx3W1hV1mrOmRE5VpfaQW2LHlkcmV7k6PgzE8OeDix31ckxJBwcpS8X/6adCGOAe3A+VdIEhnkH5TbNt9QAx1Km372VqeW+7WtQeKaqp 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 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;