From patchwork Wed Sep 6 15:03:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13375716 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 ED57BEE14A4 for ; Wed, 6 Sep 2023 15:03:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86A5544016B; Wed, 6 Sep 2023 11:03:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F3D0440151; Wed, 6 Sep 2023 11:03:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 534A244016B; Wed, 6 Sep 2023 11:03:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 40371440151 for ; Wed, 6 Sep 2023 11:03:36 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A2719120DB2 for ; Wed, 6 Sep 2023 15:03:35 +0000 (UTC) X-FDA: 81206491590.25.008BD23 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf01.hostedemail.com (Postfix) with ESMTP id C9F3E40049 for ; Wed, 6 Sep 2023 15:03:32 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=nB5E8Nf0; dkim=pass header.d=messagingengine.com header.s=fm1 header.b="aXvL/qIc"; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf01.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=1694012613; 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=xs9KL3ri9aVI+oSz6c/wzHeHoEyYgueyVeplOsiSZNc=; b=xwdY4ePFja4kAVbLGy/sx/Y1ABS3WZRC7/ckGOWB7a7KJEKQv+wsinIjiz3rwP3JyyJmsT 6L4WFHQCoa0vVczS7Hf7U+VvSPGPVIOgHa1OL3MHVFS0STGAgkIwygRNJYrIcJIqub+osx 5qliUeTgb6JKMO1oVKXrV1PnkuU0k/A= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=nB5E8Nf0; dkim=pass header.d=messagingengine.com header.s=fm1 header.b="aXvL/qIc"; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf01.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=1694012613; a=rsa-sha256; cv=none; b=TT6x+t1+/B9e1bm5Ga4u/6kHaJrhB4bwdkGd2phPkUdHLQ1PQ107+OsgCrGKWIZIKP5wTa XB+ZAfgUlsk7jmzyK6PoX7YDjGSex3UPNOawvD0nFlJo7HAuLvR+2VTL4i8lhXCDUJ24N8 01xlu0SEVhmyTCg0O5Bor1TR28eyYDY= Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 349A332009B4; Wed, 6 Sep 2023 11:03:30 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 06 Sep 2023 11:03:31 -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=fm1; t= 1694012609; x=1694099009; bh=xs9KL3ri9aVI+oSz6c/wzHeHoEyYgueyVep lOsiSZNc=; b=nB5E8Nf0GD6htUo2aB4p6yasTdnEGokEuYUgdnPHevyRvD+KCkp N0NbHMsERPS0fbnw8fRvJTxRO/oZy+uwVXCoffh9/V7DiL/YooG3rI0Iknk3UMlJ Jn1ve3i+kfepifLG2+YMczZwP6hYfkuGGYTsrR0dpH4D5g8szHurVlMglHfAE2Nw vz1IzDq3LMsH1l55+342ENlb4iViNA/l0F+QL6Rbl89rGSqZ300iQNin1uwY7gt/ ShQLkG2HN5NinkY4VpN9pAV5FeovYMZpgxGbs3toTEwWrAR5y9QaPsvgy1U8LWFb qO/7bGq0wnYGjE0CCMb7jopJc7eF4iDZFcg== 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=fm1; t= 1694012609; x=1694099009; bh=xs9KL3ri9aVI+oSz6c/wzHeHoEyYgueyVep lOsiSZNc=; b=aXvL/qIcbNerg/966+RIQLQ9nA/n3Ukd8U5WJbdEZm6vwrid1Nl FToc5Hnw1VWFaeKCb28wiRh22eYTgChPUcq5gTy0V3uFckWRe0XFyWiEaKb3hY04 FmxX+uynciVOqI0kMOawAYg6aIixIR+f8SG+pm2y4bVKCGg2LH7EWEcCwjb70KrL sSKzqUBRL3lHL9o1axhL//JzYLylnNFw01HA0j6z4X99CVue7pEU0eb3sZljwrLL ppvdSfotAlWLaaIfOoV5XrwkTZjHG9h9sjbFVc2o2fmSMmfWDSStdRHuPTsauNkF 1KBmC7grgN1XHuIw3GKVQxVxPoWthxoO9dQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhorhhtvggutfgvtghiphdvucdlgedtmdenucfjughrpefhvfevufffkffojghfrhgg gfestdhqredtredttdenucfhrhhomhepkghiucgjrghnuceoiihirdihrghnsehsvghnth drtghomheqnecuggftrfgrthhtvghrnhepgeeghedugfduuddvleehheetgeeltdetieev uefhffevkefhveeufeeiieejgedvnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrg hmpehmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 11:03:28 -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 v2 3/5] mm/memory_hotplug: use nth_page() in place of direct struct page manipulation. Date: Wed, 6 Sep 2023 11:03:07 -0400 Message-Id: <20230906150309.114360-4-zi.yan@sent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230906150309.114360-1-zi.yan@sent.com> References: <20230906150309.114360-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Queue-Id: C9F3E40049 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: k5ktkxzio6a7t518xkeguzkhon5ci8xw X-HE-Tag: 1694012612-403538 X-HE-Meta: U2FsdGVkX19yvCYmFt0y3/4fK0QvZYiQwWteEFB6hbQ61GT96LDK6qYh2W/xsLtK3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ui4Fc1alpU1iFxX7qQJNSISyuLL6S+ttd/lFO+KgdKs/BdKZuOmoFoacC/poeTREJQz6GimrLOwJK6pQYkARk5YdJzw6azSK1i8zn+VJz0ScmuyX/QO77Z3b8Udx3FD1BGYC6IowNcL/uZkitQ6NEjT+eBBx3wG0Bd0BUVR66yk5JLZHGjwdpFfuiTYmGzoCURy78jUkeZTx9qY1h7b+8fVQJdK/NonvhWWm9mHdWOwVcPS6qD5SJ6qdtQrRyWniX6ENNqp5CM9T/Et6Vuydfs2e3c74BWE0GUMe3k3jPRVXbB8TQeWxP7TmJVRJeBgUqOo86U2qS7diqIIfVGIcfrdegkR2NedCze8A/ihy/FuH1HillZeZKmVMLhemamFj9KsUEmhIQElBs59PrszemXA60218cOOlMkAHM1OCQulYw 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 nth_page() 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 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;