From patchwork Wed Aug 30 18:27:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13370367 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 220F5C83F01 for ; Wed, 30 Aug 2023 18:28:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89AA744016F; Wed, 30 Aug 2023 14:28:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84A92440161; Wed, 30 Aug 2023 14:28:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6ECB844016F; Wed, 30 Aug 2023 14:28:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5DA1D440161 for ; Wed, 30 Aug 2023 14:28:20 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 3A5C4A036A for ; Wed, 30 Aug 2023 18:28:20 +0000 (UTC) X-FDA: 81181605960.18.EACD1A7 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by imf20.hostedemail.com (Postfix) with ESMTP id E9FD41C0009 for ; Wed, 30 Aug 2023 18:28:17 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=bp98RaEm; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=In+KJmv1; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf20.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.21 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=1693420098; 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=B/34aYGd//k30w6FAZcn4rQLSn8omlUfm+JuIQdqDGI=; b=RswMgT5iwafL0eK1mC2xXVE8UNao9OOZQw5E3Y0SAkRcm6Yj+viP+Q5nROAGNGanKkCP5I 19DQZJ15qwQH9vFcD6HtIRfKuyGMNN+aWDo815SyACewzMDVKAnV8LpNuXEUgaW9Eys9mx dsWbamyUg+lNc35yZoOrJ2H2i8V3kgU= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=bp98RaEm; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=In+KJmv1; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf20.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.21 as permitted sender) smtp.mailfrom=zi.yan@sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693420098; a=rsa-sha256; cv=none; b=Ppzg4UQryG64K5RIumavFxjBluv1Ej6C57Qxei1JapCJu3dpUiHrq11DFozCqsh+QC4jYX ugVW7sGWf+fbHqaQLb07xJ3NhWJV7DwBEKlEqPetw5jiNj+sGj244/znF4XcQ9ZBhNxCuz 8gT0uoW32aeoN3hOBDLNkkTKsYwHHtQ= Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 46F693200946; Wed, 30 Aug 2023 14:28:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 30 Aug 2023 14:28:16 -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= 1693420094; x=1693506494; bh=B/34aYGd//k30w6FAZcn4rQLSn8omlUfm+J uIQdqDGI=; b=bp98RaEmsAkKBW8ghMIXww+CS6+V/zkoC6Rhda0iWyOG6/7XJYc /8v4rROgB+oFQlulTvKrM8AkcGcy3GW2TRL/6qU9FKRX/EHKaTFwq11SJY0VY2FO 5C+nnb47gm2+n9BbEkTT6VOF10qVjWVjD1RJZbqlhRWZFQscEyHK+z98E7nYMqNw 4R9ImSJxA2sY37IVm79RLXwwDy+8QQL4A/6RMa8O7MFZAu0hkWxBWlw8uCbXDp0e Tgqoh5wGfjq8IYiyVJQUNBCRAAteZl0WMhZqbS7rr30h9u95LNMxv9Gt8kHdMlmB vZc5S0cVVAQz2YGQHboVUerB+m0jD6BQEKw== 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= 1693420094; x=1693506494; bh=B/34aYGd//k30w6FAZcn4rQLSn8omlUfm+J uIQdqDGI=; b=In+KJmv1kp6XqtiudbjR4d1p1MACS6EJdB/jlntYE7YOmHkENiw 94pZU35qb54jSOyhROCBdyZJjJwlXjuBsEYgAtR9VpDXbShAJof3KzJnAwigidei vuTsLTIWEHGcfYIqfChEIDn0mmmfKLOgusenxkUM6vwZblGEhUOyTyyli+swpfft DWkWBccN23ADyp/Oz2IvClEYeaN3U2kt6iTv5+t+wzw+0m7EmSPNTM2n1j82uB1b iezbSj1VeP68EIYfvBBcKmAT4+7tArikfr5ZGR0sKTGa2lPsdvdwrgSSFW/7QF3S VJmUzhwXKRkovWljPV7DK59WC3l/pdAtLEA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudefkedguddvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enogfuohhrthgvugftvggtihhpvdculdegtddmnecujfgurhephffvvefufffkofgjfhhr ggfgsedtqhertdertddtnecuhfhrohhmpegkihcujggrnhcuoeiiihdrhigrnhesshgvnh htrdgtohhmqeenucggtffrrghtthgvrhhnpeeggeehudfgudduvdelheehteegledtteei veeuhfffveekhfevueefieeijeegvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Aug 2023 14:28:14 -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 1/3] mm: use nth_page() in place of direct struct page manipulation. Date: Wed, 30 Aug 2023 14:27:51 -0400 Message-Id: <20230830182753.55367-2-zi.yan@sent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230830182753.55367-1-zi.yan@sent.com> References: <20230830182753.55367-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E9FD41C0009 X-Stat-Signature: 611fggbwh5hgsht1n7joemw6kwoakr34 X-Rspam-User: X-HE-Tag: 1693420097-683406 X-HE-Meta: U2FsdGVkX18OS4WOzn1ASj5szP2A4Qw1AXRFv/rEw/MRbZ29le8jkzNmsA82Sx4PAkOdBoQbyP06xSdfs9pGRuuEfLpiSSEFKTn3AydSpdzK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yz42h9q3VcO9PxVcePXoLoT/D4qs9KxuikJwHS7DCTCyuOwVDSjI3RclSIYvLdGbr6ARWxAZOXW7OaQ60GIhzY3huj17Ahpfh1dUhrt1NHPNrPJ8glENfjS9ChfHB6QK10xOpLTRp33JS373rxNmDADSiFulY0keNhnTYUZg5C+OvQe1+v+0vEHDwQ0lWbONVosLB/WnSTY8wZPjA3hr9gh809U6/ty/5hmNutHM4TLAUiZd32frxulOtSBZ/D/0U2G9YDpop5sJ2OO4JlNZhbatIicO068mY47q9ZFze6VwJp3Oc/5mKdF7xtenQ= 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. Signed-off-by: Zi Yan Reviewed-by: Muchun Song --- mm/cma.c | 2 +- mm/hugetlb.c | 2 +- mm/memory_hotplug.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/cma.c b/mm/cma.c index da2967c6a223..2b2494fd6b59 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -505,7 +505,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count, */ if (page) { for (i = 0; i < count; i++) - page_kasan_tag_reset(page + i); + page_kasan_tag_reset(nth_page(page, i)); } if (ret && !no_warn) { diff --git a/mm/hugetlb.c b/mm/hugetlb.c index ba6d39b71cb1..77e8d2cf4eed 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6474,7 +6474,7 @@ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, } } - page += ((address & ~huge_page_mask(h)) >> PAGE_SHIFT); + page = nth_page(page, ((address & ~huge_page_mask(h)) >> PAGE_SHIFT)); /* * Note that page may be a sub-page, and with vmemmap 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; From patchwork Wed Aug 30 18:27:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13370368 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 E8C94C83F17 for ; Wed, 30 Aug 2023 18:28:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DCFD440170; Wed, 30 Aug 2023 14:28:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58BF0440161; Wed, 30 Aug 2023 14:28:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B8CD440170; Wed, 30 Aug 2023 14:28:23 -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 26646440161 for ; Wed, 30 Aug 2023 14:28:23 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id ED51AA0364 for ; Wed, 30 Aug 2023 18:28:22 +0000 (UTC) X-FDA: 81181606044.21.1D5BFCB Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by imf10.hostedemail.com (Postfix) with ESMTP id 9AFD0C0008 for ; Wed, 30 Aug 2023 18:28:20 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=wVMie9Qf; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=ziKY7X6d; spf=pass (imf10.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.21 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=1693420100; 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=TK10HtZMWkaeyr29jSGk50ed2+QFV4733ljLHyyzZmA=; b=zbYZskQ1kPiENvN9w9kvm5Oew2vNUJI1ecsstcOp38E6DajNDjwWWKqqvciHkyj8y9SeVL s83HhWzU9r5TwUg3G9EALQFr0Jr7JGbCc8bqWczvp0jEcba+6EOARhEVNOJZ3g4x87DMh6 AhqEpBARRov/Y/XgAaun7ZvLs6HJIqM= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=wVMie9Qf; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=ziKY7X6d; spf=pass (imf10.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.21 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=1693420100; a=rsa-sha256; cv=none; b=zV1w8Dv4qr5CNVN2Jerj/NntTAoXzg7kgA0TJSonCpK8UhK8XvLtt5WFghYMqDDVZ9Oplg 1FOU9WAe0PAkj2u7gnKDGLclMCO4R2l9gymsyWD4qX8JnkTxfSqKQIocz3xauHwUdSHJQQ k5WUZIrCEl5xWQqVeU7v2lE5cKdhWsk= Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id F3E6B3200941; Wed, 30 Aug 2023 14:28:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 30 Aug 2023 14:28: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:in-reply-to:message-id:mime-version:references :reply-to:reply-to:sender:subject:subject:to:to; s=fm1; t= 1693420097; x=1693506497; bh=TK10HtZMWkaeyr29jSGk50ed2+QFV4733lj LHyyzZmA=; b=wVMie9QfMJAfZCtvv/CLDGpDzW3bh1Gk2NBoHI0hoWVREkq3dgY +48nO3GAyn8XC8bHDHwCMgtHeYijkz4DyOvLKjhu5deoObYlNMb0goJJjbZPsuSH Cv7QNhvzmMVF2GY3Ww2fGD756MsZeGZyt4qWPrS3k4peKFRXBklabFvKqkEzEkfo 65LebOhjDZ0OjDqI+IEjtYVPRVxlNBWX3PvW79tpEsPO7LmlzMplzFuvc4lEXItR JybkxgkU+tSm8bLdjGkGvLQwvl4WA39HGvA25kn8MF5WXW3C6gnj5OwbFHEXvrYa +OghkryonUAqHfmrb85aB3C6QdtiBxWzK/g== 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= 1693420097; x=1693506497; bh=TK10HtZMWkaeyr29jSGk50ed2+QFV4733lj LHyyzZmA=; b=ziKY7X6dy6aRNNRouY0tNqlLuvndGRS+knN/IbPMk7xsieoO0V9 t6GT+lSpAx7hVmg7VucGt/Mf8iWiYr7Zdmf2FyWYpnsdARUqCpaBz9kkgIODylZb wqGxcXVnoqmfusEjtA52SiWcxEbwNmo+oDq/xRfEW8fabKcf/ZkcbddJZmvfI3w+ G92FFGG49+NslDWY2fNtHQUWvbdA1euJRCL1IEBizJ9G10crBI0P0l3yPJiXa+xs BIJuSuh/hZoDcqS4cPssInZIixidGnVxs3HLgfvtXqpTRFDyMwAbORQCMs63yYDb tztU+jJdL6QM8YZSiM2ZSY1hiJ5RAPf2NWw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudefkedguddvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enogfuohhrthgvugftvggtihhpvdculdegtddmnecujfgurhephffvvefufffkofgjfhhr ggfgsedtqhertdertddtnecuhfhrohhmpegkihcujggrnhcuoeiiihdrhigrnhesshgvnh htrdgtohhmqeenucggtffrrghtthgvrhhnpeeggeehudfgudduvdelheehteegledtteei veeuhfffveekhfevueefieeijeegvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Aug 2023 14:28:16 -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 2/3] fs: use nth_page() in place of direct struct page manipulation. Date: Wed, 30 Aug 2023 14:27:52 -0400 Message-Id: <20230830182753.55367-3-zi.yan@sent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230830182753.55367-1-zi.yan@sent.com> References: <20230830182753.55367-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Queue-Id: 9AFD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pRj2cHc mdKjbeXqX4eQltyuRNb/c1ZjDu4OE/4p+Di/MHn0hM1hjq2wmOo6bA07HJlBBz89Xc+spe5bU9LDia9RHTTSvC+yKZRSUEh0qEnKlqxL8yA7WTlscaw9Fzku7XvgIT/kfG0cXRiPhPbPst39z17K/1rUEPlL6QAHgH6CWs3e3mZeveb98gfKMTJ9m9JaEe0Vu6zEezQd1IbzGnjlNU9qZCz7lk0o0Z8sQjCkOJUn/f1ZK94N4JLCkBuJDLmnXsReoEEqiPm3f2A/WNXPZ3cm4QiroCfky+9vLWAi2uvmpei83zps1FtVIg36pHCeY4yC/uaiCmO0EzCUahFiiyPTyZDOJ89WrT53YRzmJFA4F4lDWzsbk+PkupA7LtSUCdEQFo+KZnHAlrqCvxTJUJNKNyP337CMifMpd4jbO+RXIP6FdgqmwjdJW2Sf8J+stkrlarc0Gqb/8WwVWuwhWGLkFDC3OEzqcZw+AdUm0kTzA/I1Q8Rg= 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, struct page is not guaranteed to be contiguous on SPARSEMEM without VMEMMAP. Use nth_page() to handle it properly. Signed-off-by: Zi Yan Reviewed-by: Muchun Song --- fs/hugetlbfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 316c4cebd3f3..60fce26ff937 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -295,7 +295,7 @@ static size_t adjust_range_hwpoison(struct page *page, size_t offset, size_t byt size_t res = 0; /* First subpage to start the loop. */ - page += offset / PAGE_SIZE; + page = nth_page(page, offset / PAGE_SIZE); offset %= PAGE_SIZE; while (1) { if (is_raw_hwpoison_page_in_hugepage(page)) @@ -309,7 +309,7 @@ static size_t adjust_range_hwpoison(struct page *page, size_t offset, size_t byt break; offset += n; if (offset == PAGE_SIZE) { - page++; + page = nth_page(page, 1); offset = 0; } } From patchwork Wed Aug 30 18:27:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13370369 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 6B06CC6FA8F for ; Wed, 30 Aug 2023 18:28:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF5D3440171; Wed, 30 Aug 2023 14:28:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B7E62440161; Wed, 30 Aug 2023 14:28:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D11C440171; Wed, 30 Aug 2023 14:28:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8B575440161 for ; Wed, 30 Aug 2023 14:28:25 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5DF2040334 for ; Wed, 30 Aug 2023 18:28:25 +0000 (UTC) X-FDA: 81181606170.26.E8C8576 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by imf26.hostedemail.com (Postfix) with ESMTP id 1FA52140022 for ; Wed, 30 Aug 2023 18:28:22 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=EYBx63Ev; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=cIqp7Ocq; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf26.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.21 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=1693420103; 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=UaWYMjZoz/qbv6HU3P8JXTg44k1buzeqH5W8mgla10I=; b=XRrtXQO6MjDwiNrznNluL4Ib1ypI4aXgVcDQtwl4bR9pWmAzRyWyXNKwGL2hu010l88U0A Cl+N6AfoUti5MfpB45JDe1g+VTW1ZhiW/JH4T2TPwY3/VBGJD5RfNxRN32meQRUmUIiI5C k5R280N4cpF+F7kdOF8Pj32yOToAiXo= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=EYBx63Ev; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=cIqp7Ocq; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf26.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.21 as permitted sender) smtp.mailfrom=zi.yan@sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693420103; a=rsa-sha256; cv=none; b=Lqcg9+CJUyRtCFr1fU8MaWYZZt9EEP79brQNgN/9qmJ3kl+8c2ncn0NzLb8nrTrNm4e0S/ 2xa0nGnTFVXiKIA738UkwmI9sdufTcUtzUXzlU3vPQJg28BUcP1pxZtStl7kfzl8VGLuuS 32Fd1KtNqwUbW8qcRWQP/zRVi6D2jGM= Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 70DC23200942; Wed, 30 Aug 2023 14:28:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 30 Aug 2023 14:28:21 -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= 1693420099; x=1693506499; bh=UaWYMjZoz/qbv6HU3P8JXTg44k1buzeqH5W 8mgla10I=; b=EYBx63EvFZjpL4B27TvMy7dGqT0pwxAoSEQMIg8pIUrC14oW5Qe NQQkav+XRQAccBSjDYtL6wGLdshSlcg1rzwDN10arpEUSJWVjaH6IgApWfE4wz2k NJrHO5LIciwfDdoPDOe6ZjYQxyAx+9Qp/yhg90D1Mu/zDRHBh+usGjHa8kak61BH +wRtghRwUfwcK5/g4dAMCzoN5W7fRgb6/Fc0s9E42Y4N6bQRYuO/UkeirPUMSiZp yZ2IN3lwvHgVsMMyVUZL8ujlFJZVEXlmSYvbJK3v4JmwYHq8eQAgRitNdVAr72K/ 83+G2VVVKYJBkgGYIUdzl6PFgre20wJhuxw== 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= 1693420099; x=1693506499; bh=UaWYMjZoz/qbv6HU3P8JXTg44k1buzeqH5W 8mgla10I=; b=cIqp7OcqR9mAO5om8208dHU0wNnEriPSq/ag/Nx4a6D5SqamN6H u5pPrVI3kn3E2aS0lJco43LEkbh81xEEzrwAjk1UPuFe/Q1Gu0D3lR1Jd20Zu1Mb gdjd18scjP00w/1McZqpwobB31v+bdGi+n1BVFMzoHn//F67+rVg9YaYsXDC1vi1 b49vnbHA72x2FuM7RHMCZpxiG9NycXuTOEiki0emG1ppfM0lGJf6JXWoJSRt9xrv eX/aAvXfHx1aQbS9TyPhFAOhk0jRQP0Bm66uUGmD/P3FdC5dkgxYpXaV/oKOBN+Y D5N/biYochIaLDXNgUc6e45rtgmFJlOkXGw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudefkedguddvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enogfuohhrthgvugftvggtihhpvdculdegtddmnecujfgurhephffvvefufffkofgjfhhr ggfgsedtqhertdertddtnecuhfhrohhmpegkihcujggrnhcuoeiiihdrhigrnhesshgvnh htrdgtohhmqeenucggtffrrghtthgvrhhnpeeggeehudfgudduvdelheehteegledtteei veeuhfffveekhfevueefieeijeegvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Aug 2023 14:28:19 -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 3/3] mips: use nth_page() in place of direct struct page manipulation. Date: Wed, 30 Aug 2023 14:27:53 -0400 Message-Id: <20230830182753.55367-4-zi.yan@sent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230830182753.55367-1-zi.yan@sent.com> References: <20230830182753.55367-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1FA52140022 X-Stat-Signature: xuqt1urobi9nob96c63nkayteogtood8 X-HE-Tag: 1693420102-478604 X-HE-Meta: U2FsdGVkX19XXpRHb8VE9QYEPEhR7mbbwBHS2tM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jV7Ldb3vabm+kDOhXzZwaiHNfMvBOIQcQnbg7MF8Zdar8PehZ4sA5bR1qLn2rOLEKDIIr3UE7MZvaTrtDb+zLLZ9DJZZAEnC5Y9KPaKscRxmr3jayA7w64hv6ud+or565Mz7uW6167Fru7+4/M8SCPKm6jBEVxZUHR0UzKMVaieqe9klaTQOUFJwqFmkVBb6uo6A6mPT/vwdN2CNFrDiHQV3rCCdtwCKTHLL0QLAS46RObA3uLm67e1SGyKA1pLAMIqsYgiTHhG6nGkyNsIHF2FlpQIZi+fLjVQJ2fqToBVOOaHjY600zmf5hcShHSax0tdT/5iXAPwOEk1WziPofEGbJKLTbSv2iXsbk= 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 __flush_dcache_pages() is called during hugetlb migration via migrate_pages() -> migrate_hugetlbs() -> unmap_and_move_huge_page() -> move_to_new_folio() -> flush_dcache_folio(). And with hugetlb and without sparsemem vmemmap, struct page is not guaranteed to be contiguous beyond a section. Use nth_page() instead. Signed-off-by: Zi Yan --- arch/mips/mm/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c index 02042100e267..7f830634dbe7 100644 --- a/arch/mips/mm/cache.c +++ b/arch/mips/mm/cache.c @@ -117,7 +117,7 @@ void __flush_dcache_pages(struct page *page, unsigned int nr) * get faulted into the tlb (and thus flushed) anyways. */ for (i = 0; i < nr; i++) { - addr = (unsigned long)kmap_local_page(page + i); + addr = (unsigned long)kmap_local_page(nth_page(page, i)); flush_data_cache_page(addr); kunmap_local((void *)addr); }