From patchwork Wed Sep 6 15:03:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13375715 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 E2CCFEE14A7 for ; Wed, 6 Sep 2023 15:03:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C4BC280017; Wed, 6 Sep 2023 11:03:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 225F1440151; Wed, 6 Sep 2023 11:03:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09F1928001E; Wed, 6 Sep 2023 11:03:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E5990280017 for ; Wed, 6 Sep 2023 11:03:32 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B630680E1C for ; Wed, 6 Sep 2023 15:03:32 +0000 (UTC) X-FDA: 81206491464.27.E4CCC9E Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf03.hostedemail.com (Postfix) with ESMTP id EC78820067 for ; Wed, 6 Sep 2023 15:03:20 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=Sn70enwh; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=abyRc8o8; spf=pass (imf03.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=1694012601; 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=nTuP10zriYyST8Q/kBCNG/qEQgmqc70KHU1yjiMDwLg=; b=TVS69GlwcPwEBO+HYcDtIHp2pqIC14mfB03MH9ApwRsEdkhIJ25sLL7U7j6Z6YD9HKsW1F VuSP2ysqSfskgZ14b6+65H6FXA7lAigY2EAOzPLBRVhv4GtMKKkh9suvkwiHxIKoY/RYGf Wm4n28raNV7HVM75rsqL28J4w/wKqzk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694012601; a=rsa-sha256; cv=none; b=ZdUszABZKupA9QgM5DqIEp1WVgACSQNpsmlcaFQZC2pWId3G+XZJXbHIYvR7S7TnU1Dqus gR7M7MqPlxg3fplgCUyWI18OXD/gUwwzDtdBjpnJzEzRqys8X68KOoOhNyY/GTodUKB2cU qgIC+eIx2txVRVX+1BGRdBqT5ub4cpo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=Sn70enwh; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=abyRc8o8; spf=pass (imf03.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 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 6D2FB320092A; Wed, 6 Sep 2023 11:03:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 06 Sep 2023 11:03:19 -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=fm1; t=1694012597; x=1694098997; bh=nT uP10zriYyST8Q/kBCNG/qEQgmqc70KHU1yjiMDwLg=; b=Sn70enwh1eH007UJNc cyTt2nHpLZx1vQXdrhk438xafdqp5ZuDSJAtPeceUmtBeGUE7LmH3LLhREeuxFXi o1j/JRtZIwdGsclczjEvFQF0Fs43c1qm69kCLNXwsb98wLaVRmlHQ5j0kRgA6R0x aAgssCKGyGj0/rReVQey4zOuwRpbTR9eJBKA2fzDbi81QYocnTwZbPod+pOroKHf MLTDIpatpHi+ffs8FXqViLfGWAkcMvekidGMx64rzVB7FU4strT98RIlnFPCrV0Z fKHza8ElRmeH2gUD4+25WTGLjFZa5uvZd/NkMXJvV9aBVmMU5LsJF6Ow+Rc0P83g 5RMQ== 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=fm1; t=1694012597; x=1694098997; bh=n TuP10zriYyST8Q/kBCNG/qEQgmqc70KHU1yjiMDwLg=; b=abyRc8o8LiDpvKbHi raN8Yulebq767LF3nLwmzWfDM1dVKzNk/M9refFnLGQv7/VmvjGIuSlVUPL/t89r HRoS7P15C73rFKnKSIgAVXMLGes+9tyefoMU5jE0VbhVwCNizYbHi4AnHfgdnzUC V5fsIjlbOheo8HlHsLc742H6jQUJo5AXlPMERpd1hBFq/aI8QjfZdkxLZSttq5t0 L0Zr/P46BbTsevdvf9OUt0vE6ZY64xgCfwXK9/u+WOt8uccU9iJkdKrUYx9hcEID qkw7p2PMqjRtx5raaPi75LnvpCkcItR6g8QMxssAQVzlmV7AhptttM1ypJczPYdf HlpiA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhorhhtvggutfgvtghiphdvucdlgedtmdenucfjughrpefhvfevufffkfforhgggfes tdhqredtredttdenucfhrhhomhepkghiucgjrghnuceoiihirdihrghnsehsvghnthdrtg homheqnecuggftrfgrthhtvghrnhepudffkeeujedvteeglefgvddugffgjeetvdehveeh vdehvdejvdegjedvffelueevnecuffhomhgrihhnpehmrghnihhpuhhlrghtihhonhdrmh hmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihi rdihrghnsehsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 11:03:15 -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 v2 0/5] Use nth_page() in place of direct struct page manipulation Date: Wed, 6 Sep 2023 11:03:04 -0400 Message-Id: <20230906150309.114360-1-zi.yan@sent.com> X-Mailer: git-send-email 2.40.1 Reply-To: Zi Yan MIME-Version: 1.0 X-Stat-Signature: 9pkwib8a3s1dhwcpj3qa6bjayqzqqdmu X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: EC78820067 X-Rspam-User: X-HE-Tag: 1694012600-256016 X-HE-Meta: U2FsdGVkX1+0u0DznGMun0bBcGBkhgEL7UBBV3g0CWJMbmW+ZzgwRef3tsnDYuFSYihgZ6Yu+DrRl9IxZpTPdptAOnHmg/DXLAPYiDF50hNrnvnhq+guwmYC7DvoZvUcrb5ImxqFjdMaya/4PWfAqPGCLCYlCf60Nl++otwR85YBQOVybhoMY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8nRuwMBqY+SGq93buxd0ceu0X8v/j2ogIxvyfUSBu7aS3hzjOy7G1QHKFPAiEhI+/g06oQdEA4ag3APVEyk21sap95Z1IGhhgBFc3CyzqS9LTijyt3Kkaq/r5oNY/yIbQwwKdAeEAXUbmwAmdN2Vnm9QD+ekD1ZMlDjbJPD/hzITreuCcgIRh3j79/aA9i2bWaqUgXj/MyD8lj8pLNMUIss= 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-20230906 Changes from v1: 1. Separated first patch into three and add Fixes for better backport. 2. Collected Reviewed-by. 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 nth_page() 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(-)