From patchwork Wed Sep 13 20:12:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13383744 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 441C4EE020D for ; Wed, 13 Sep 2023 20:13:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6105F6B0285; Wed, 13 Sep 2023 16:13:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C0006B0288; Wed, 13 Sep 2023 16:13:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 487DD6B0289; Wed, 13 Sep 2023 16:13:16 -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 39EB46B0285 for ; Wed, 13 Sep 2023 16:13:16 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 02616A06EE for ; Wed, 13 Sep 2023 20:13:15 +0000 (UTC) X-FDA: 81232673592.16.7728058 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf19.hostedemail.com (Postfix) with ESMTP id C473A1A001F for ; Wed, 13 Sep 2023 20:13:13 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=xvbgZdE3; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=q9t1HOCl; spf=pass (imf19.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694635994; a=rsa-sha256; cv=none; b=hzjoD7y6czqmQT55bNgjH6gkl6b4aJs2kfDYRfAhem3VuuTg2WC0C62jmK3LkRS4kwShT7 6TKahox/gImiz7stEobI+Zwl8HNPslSgXbiMgymxV4zKIx904Ald0t6uXs23aIcj40DmF5 /EySuvNP+Y2rfr7uHLT4SiMZXatUhaw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=xvbgZdE3; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=q9t1HOCl; spf=pass (imf19.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694635994; 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:references:dkim-signature; bh=nWGq1gLR7F41muaJaoLOMct76xa7LgE2SjtA7mYmrLE=; b=TyuEtPkbGa/SSZalfcASzBWYc3gD7dGXxvlEpbtb8ut/zOKDSQxgMdJPkuCCpSGvY2BjZ5 1mXI4xVW4w+ojBiPZF4RVB4Vh9nTMiynyHzL74eUFPvA0cZIbXbHTsHb+b2lo/2Qfv+vEw HAJiW444pIrcBSLUdz8U+tXoFvDzUrQ= Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 3AD4C3200931; Wed, 13 Sep 2023 16:13:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 13 Sep 2023 16:13:12 -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:message-id:mime-version:reply-to:reply-to:sender :subject:subject:to:to; s=fm2; t=1694635990; x=1694722390; bh=nW Gq1gLR7F41muaJaoLOMct76xa7LgE2SjtA7mYmrLE=; b=xvbgZdE3/nGTuYUUvH u5cCgINz/3pwJhWTguTgefNOzbUhpNqf3mZHxc4jf8Gi1EVIya1H3GR2ZBgF/dXp 7hNXBAXnSlbfx4HBobFsvvCCxiPdcnXymIZOsu41aom5nBhu4l7FXoH8I5VF0SnJ U68NDJ6hCCK5D67ktwRZBjTvJTpdc2KhnOPUvPQyG8kZIysketKrIAR6AZfd5HmF 85F0KpKO2XbB71FviIWMfeskmsu7YynqqsOHNaBB/JJbZYM38i6zff7PpOD4Kscf TWLBWUYJik0rQBafXPQJ/RTOd+g2sPesJscNbLDHt04KAWgTzv0XMC8C83F7Sret mJ1A== 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: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=fm2; t=1694635990; x=1694722390; bh=n WGq1gLR7F41muaJaoLOMct76xa7LgE2SjtA7mYmrLE=; b=q9t1HOCltCbs9NGp2 35SQHUh7Yz5SCWu97v/ldfktBV9gKyWzHfSBHsZcxXGXkk/Dbz3Yr/6sPJY+YWj+ Bc5gJ/GC57NUV4TOAR9Y+nqkp0XcRZK5QSyxjGVmPWLNldWyLWOd/DnqdtqTxxmt gMtqtLzXzKIOGCOWdTIg/epr7yg8lYox9+bsRr2ibP+Q2wFCLzUOe2NTW9x3fVgc TzqjN5HUq7VwAeGfjUdXL1EI4tVzsEDBgSAQBz4HZtMb7l7+gOHHugHK+fG9rneN XIcAVxVDCw3nkHNGILSx5VEblUtX8o/6wecDsvsW794pGIMpChkMXrjpIsKjRohQ MECQA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgudegiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enogfuohhrthgvugftvggtihhpvdculdegtddmnecujfgurhephffvvefufffkofhrggfg sedtqhertdertddtnecuhfhrohhmpegkihcujggrnhcuoeiiihdrhigrnhesshgvnhhtrd gtohhmqeenucggtffrrghtthgvrhhnpeduffekueejvdetgeelgfdvudfggfejtedvheev hedvhedvjedvgeejvdffleeuveenucffohhmrghinhepmhgrnhhiphhulhgrthhiohhnrd hmmhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpeii ihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 16:13:09 -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)" Subject: [PATCH v3 0/5] Use nth_page() in place of direct struct page manipulation Date: Wed, 13 Sep 2023 16:12:43 -0400 Message-Id: <20230913201248.452081-1-zi.yan@sent.com> X-Mailer: git-send-email 2.40.1 Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C473A1A001F X-Stat-Signature: qx1k3reaf51ndeeizeqibbnmjq538zwp X-Rspam-User: X-HE-Tag: 1694635993-953142 X-HE-Meta: U2FsdGVkX18/NbOACSI6TYn5KP8FRA7W80ZTytZd/4bingVlKTsfaGAkFG5NGRFDWykvNozTOq5XCBmOpBDLw9iRkRdop+eB148gkGlsqMPLpniBCrNCtw9MmjHto8kiJNFUWaH4MEGldtSAsnMuG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fynyvNJHaYL63MLnclQTN+9uXUHMyAfhI5+1Mpcx1o1WyEhDkZNvB9GQx/3ED3hoaAdv9Fi1+Gsg4nF2BE8ln1HTx4DTYC+cVvYSoQOlmP9Jfc3xAWMoWVKAH0Nl5gJ1U6CIKX1s0FFATElxyPc9lbtoa9SKW6dSOQRVyycAv6tkrvPVbTRH9QnKGFgcy5oQFS30Ne0iH1ISYAqId7Xy6fvT/eHCftAmAVNUI0zPcaSsCntFeE0zZ0= 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 On SPARSEMEM without VMEMMAP, struct page is not guaranteed to be contiguous, since each memory section's memmap might be allocated independently. hugetlb pages can go beyond a memory section size, thus direct struct page manipulation on hugetlb pages/subpages might give wrong struct page. Kernel provides nth_page() to do the manipulation properly. Use that whenever code can see hugetlb pages. The patches are on top of next-20230913 Changes: From v2: 1. Fixed the subject and the commit log of Patch 3 (David Hildenbrand) From v1: 1. Separated first patch into three and add Fixes for better backport. Zi Yan (5): mm/cma: use nth_page() in place of direct struct page manipulation. mm/hugetlb: use nth_page() in place of direct struct page manipulation. mm/memory_hotplug: use pfn math in place of direct struct page manipulation. fs: use nth_page() in place of direct struct page manipulation. mips: use nth_page() in place of direct struct page manipulation. arch/mips/mm/cache.c | 2 +- fs/hugetlbfs/inode.c | 4 ++-- mm/cma.c | 2 +- mm/hugetlb.c | 2 +- mm/memory_hotplug.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-)