From patchwork Wed Sep 13 20:12:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13383745 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 9D6BAEE0211 for ; Wed, 13 Sep 2023 20:13:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E26DF6B0288; Wed, 13 Sep 2023 16:13:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD6BD6B0289; Wed, 13 Sep 2023 16:13:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C50B76B028B; Wed, 13 Sep 2023 16:13:19 -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 B82216B0288 for ; Wed, 13 Sep 2023 16:13:19 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9504D120E53 for ; Wed, 13 Sep 2023 20:13:19 +0000 (UTC) X-FDA: 81232673718.13.7ECE5BD Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf12.hostedemail.com (Postfix) with ESMTP id 5E3BD40020 for ; Wed, 13 Sep 2023 20:13:16 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=sQpceFCL; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=f1J1usMY; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf12.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=1694635996; 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=W7emFMpfIMC3wLaZ+9JtBDyJqJ6ODUK3zLRX50gZBXo=; b=AL/NIu8Wh+al0iodJJk+AKZH6aBxRYfERhGICkDsegrK5yQ8gzWK7uggVPZBcxhAlW4gGM JEyucQoNG9uIIXSPBo1JPSQr/eUbMFnxQO3bjoj5iWXk/HZUpalYoaKhvHG2IcjmZQzAeF +AoMy9I+FfwsuI5erTZ9l0Tyv5Pccmw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=sQpceFCL; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=f1J1usMY; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf12.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=1694635996; a=rsa-sha256; cv=none; b=NqL0/zxW9ZKSVYED0t9aV0UENfKdQFFOLULzYm/N7Con1GtXhdJ8Hf9LpIhOty/3CsjA8o BDg5ueqYYO7XatPSff+Yoe/NoR2RwlkxArstmds08GEB1Q4vPjiYUXVBnuVL4V/fIe6eDu T0CeejAVb4vOpNFa4TxJjUU+pS4dQqY= Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id EC566320097B; Wed, 13 Sep 2023 16:13:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 13 Sep 2023 16:13:15 -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= 1694635993; x=1694722393; bh=W7emFMpfIMC3wLaZ+9JtBDyJqJ6ODUK3zLR X50gZBXo=; b=sQpceFCLA909BuTBZz+XL7Q94NZUOHGGjEudXMqrizGzLm9Mb35 QM+B7t8k3bGRHWOpM/I482LZgSftZIcr83fv6RxhAbx9PYx7xrpH9GBYEcHV8pAY 092W5LzEHe5FlGT9COx/ZIMaak1lx5dG4Hy3cSU00rZ21EUlzJ1TS8V7t8oNwEd9 TGzQ2QwH816D/VZjV51qnHMOAo22MmKiPSyltaa9W7YrRoID0uyOz27pGvX6ScmW PhCfwmjfx7T5kl9ANLy520k73m101Dbjvf2e4pUcgL1RUK6Magi2AMGuKnhZ93WD +KMSNhzFvGhVh/inlQ0KSLF9hLelEjS5gdw== 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= 1694635993; x=1694722393; bh=W7emFMpfIMC3wLaZ+9JtBDyJqJ6ODUK3zLR X50gZBXo=; b=f1J1usMYiSOuxL63bAr+b2r34zPIFYmvIMyOXr6CZeN2rm009Kf FFNbRaH5Zx7NXkXq4ElkCtNaRarPsMZHXaDe1qU6YTMkKuYG1qu49BqwYdiRdC86 8bPr3ikD2rS7M4sEajJfpBPmUwRVZOYV5EsZWY0cLSPUMm1W/LSqWbcHFl5y6fsY v+7MbXPcmDhVQQtKIrAX8ivkvC6fWEKOBTRvP3GAtI3jarH2FVTlPsvgGKeXQXvz DPEl4UDmWoBKthefGJm40hI1C76wHMX8xPVldQHBqILyAP6g/IpHBeMOvWSkAC6K 12Rp/ZsWNw8NW3aG5+v22TqG0QbmheKzZ4g== 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:12 -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 1/5] mm/cma: use nth_page() in place of direct struct page manipulation. Date: Wed, 13 Sep 2023 16:12:44 -0400 Message-Id: <20230913201248.452081-2-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: 5E3BD40020 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: d9zqfmsyqbcx5qgyzujubkyhebb579j3 X-HE-Tag: 1694635996-53375 X-HE-Meta: U2FsdGVkX19fYaw2a7rWgcJh5s4fe4JeNcBBO11Z/p6rRIoUv+ah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r9LyLfv2gZQQyZ3LH1oRhqKGgaDf3AgrYsYEdqUVo6wQHniEMFuvZ2qkdLFE6sesnGaNmjKKQy5OBmGCleZotYGJDXiGpmJqi6Q68TAIpwKt7jBHs5NyprHUVgAB9bwC/TGRhRTIxRRrQ0vSA9ipbhm5twK4dgetos1VsPbr0MVNmYuma68a24Y8glvMCBMuCkCsIIiXQOsYCuT803PSM5rQ4nqulsKj81D5cWc/J03D9MZ50vvkZg9rWGPqIbcA9v/GqTFiM6p/IjQ7iCWbxArt4nUmKl/6XBR65b1hLkcW3rRLIYQ17V9R1moEc7gxcHwlLLRpWAUdqq1dl70w5S/3+EIKgBpmJZcOr6Ycij1mh394uLZ27Y6I6v6e3eByTeeMT6U3T2laAUaRWYAVxH2lqpU7mjt8A2qu5DugMbtfyKgNA3ob1O0jdRVIZrNkFtgwzznC8d+ICsQaUm694fyS4O 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: 2813b9c02962 ("kasan, mm, arm64: tag non slab memory allocated via pagealloc") Cc: Signed-off-by: Zi Yan Reviewed-by: Muchun Song --- mm/cma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { From patchwork Wed Sep 13 20:12:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13383746 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 C5107EE020E for ; Wed, 13 Sep 2023 20:13:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5764F6B0289; Wed, 13 Sep 2023 16:13:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FE4C6B028B; Wed, 13 Sep 2023 16:13:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 328EF6B028C; Wed, 13 Sep 2023 16:13:21 -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 25A8C6B0289 for ; Wed, 13 Sep 2023 16:13:21 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F3FDAB3A83 for ; Wed, 13 Sep 2023 20:13:20 +0000 (UTC) X-FDA: 81232673760.03.418FC7C Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf21.hostedemail.com (Postfix) with ESMTP id D4FAE1C0012 for ; Wed, 13 Sep 2023 20:13:18 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=Q33sr6nx; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=nln4VLWK; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf21.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=1694635999; a=rsa-sha256; cv=none; b=HplV2XFKmqOhWqsb80CxmU/gja2bdvV4H9SajSK63cF5iegy5bprGPy47sVx2nyWJu9BPz YfPyTqfbVRZaPOkULI6Iuwa5lsmyDeLHoWOdm3EHyV6ArV2fCpergQCGoye2nmtkw3y0j/ 3CikQZQfj5RhMMnuof+JqZHS4d4EWGc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=Q33sr6nx; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=nln4VLWK; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf21.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=1694635999; 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=mxKjLm7C5akdzlDNgIeEXW3U7M/tKbi4yzpZmBIFkQc=; b=Sf8Z6dkNsClyXqoJch7/bPgzGx9qZpvuzOAnXohkhGJ6UEwLHDwyC1mBqtEumR4IEPIhvk CkvIh/b+8UvE88IEjs47RIXGihypd7puW48zWrtzwgh/tRYuE5ME/2F4WSD0E9/f30+NLa cvPmaeBJa0shjKXOlphiHbkeTb8rwUY= Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 77567320039A; Wed, 13 Sep 2023 16:13:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 13 Sep 2023 16:13:17 -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= 1694635995; x=1694722395; bh=mxKjLm7C5akdzlDNgIeEXW3U7M/tKbi4yzp ZmBIFkQc=; b=Q33sr6nx2erdmdA0tv9szaorSFCWd9oTgbOkZK628yvpAxE/Fa9 FyX0a3c04OIInmTb6z3uxuQbtG6IS5dHzgzxbK69YCFKOgIG2qfkwUS7eLsPJasE aiO6lQdwhpHuHUaGHIou4krQLlWzg607QRWrdOep0NAdCES5s5HooJgRYkKKiNMi nUVEhU5/8iBKyKUuLi3+MeM64aY7Kk01wqGkAhV/fVbHx6xa/C1Iu/EHwm2gS6SL 1uI2WOogXSeA4cPx0/QIDBiPyzmUB9bpsxV1hYuavNsRuICEKaGnveUuhzgPQgOi 0Fq+voBYJ/AD2PtGTEXlcvHMYso5Bb4zxMw== 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= 1694635995; x=1694722395; bh=mxKjLm7C5akdzlDNgIeEXW3U7M/tKbi4yzp ZmBIFkQc=; b=nln4VLWKEOaRlKOXjSxM+LK+Tyjpnm7IUNmvfLA/g8VkGuNjPPN G0K5zRF1KTJLBd+CypPRybFrIVS8Ic6oYobIUDsIB8L1YeVz/75fetXVcgbjvLha AfMk5zpriqRiL0vH3y1eurV+1Ra5k0M+tePqkQKO8A/JATeKsYFvEQULIt2ijkMI uhhDhmMdzsQol6jeUdbtZVReuyJzfcnIl6TUgWXcSkJ8+zZwctipxjnw+gCJiM6c GFTS6pP7osGaiVfn5m6PMEe229B5qYRn71H/KfFp9Pt65ginaXsiXV7XnSduwP2s 8vRpLBKfaVx5XfR9Zd52R6LvLogYT92iXiQ== 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: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)" , stable@vger.kernel.org, Muchun Song Subject: [PATCH v3 2/5] mm/hugetlb: use nth_page() in place of direct struct page manipulation. Date: Wed, 13 Sep 2023 16:12:45 -0400 Message-Id: <20230913201248.452081-3-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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D4FAE1C0012 X-Stat-Signature: 3kc6zajcmzzb9uejc5xapuoex9tk4nwd X-HE-Tag: 1694635998-16989 X-HE-Meta: U2FsdGVkX18yGaVeoYHKOG5JvIjEMAb1S+FyRQ2HsKxLmkybz7Y+PIwnJRK7TrMNXEhMuoFQOhtUCF0zcjF/MetsaCia3vdhnSsC2b2B7bmKrdN4LSCxruMhvfTnC2KYPV6ZN/NspkgPEClUle20un5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HLzIWz6QPqVn6EmcvROAwgg+WGyFWdIdm7PrYp6jcKSuBVnUByRYW9LUJrmF3AQZtvvvNIEeWZy3ZEeCk75EM+DU0zpA+s6hcZWmoQKQwBPIgqYhxHQFSeFFEp2v2lpYcFZfiYYFo5GN8GBP2Q8jdpZ4h67HWTZ1iEK10mEAnwM304iYcSnfxxo5pL0K+kts2zXfQnnipBcmaYfDfruccRf/4YBaBlmFIpIIKB6PSqi9ZaNoRDgjBCyLNBiMIEEXhW0UxbSmpXUcW1EnD3Y2jPFKPFLkcQLeElXtoxaWHOHDSEC17b1+lAtqFe1NT7BlR55hOs0/GhfAPNR16GEKrBv816CjEhNGXJ6kA6iOWjLurl 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: 57a196a58421 ("hugetlb: simplify hugetlb handling in follow_page_mask") Cc: Signed-off-by: Zi Yan Reviewed-by: Muchun Song --- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index af74e83d92aa..8e68e6c53e66 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6469,7 +6469,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 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+sYHZHbmHyHmtVG6psQucvKnJib/xnDsUOXNfbY6QemhPdYZLDVjNs8NzeIfBen6mFh/IamRn6f2ICSLgF8gM9UAHIMbKR2F66LMiqoRXY099OQ/u7gdxjU6ZO9yTu8SwdPPEPBn/okuxkNkqkabaNDOeIpfkAss4UZ2VOmoWNM/Yhg0N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Nc3Mx0WpHG7NOLp/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; From patchwork Wed Sep 13 20:12:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13383748 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 66808EE020D for ; Wed, 13 Sep 2023 20:13:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BF1E6B028E; Wed, 13 Sep 2023 16:13:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 749686B028F; Wed, 13 Sep 2023 16:13:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E80C6B0290; Wed, 13 Sep 2023 16:13:26 -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 4FC336B028E for ; Wed, 13 Sep 2023 16:13:26 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2B4A6160482 for ; Wed, 13 Sep 2023 20:13:26 +0000 (UTC) X-FDA: 81232674012.09.2C02912 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf11.hostedemail.com (Postfix) with ESMTP id 09C3A40006 for ; Wed, 13 Sep 2023 20:13:23 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=H+ayEHKc; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=YgxV1M8o; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf11.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=1694636004; 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=l4bevEHulLiJ5YHyw6Y9teMcyGqHbAaeFHUaV/6ZIds=; b=nEH17jOA1HQhbxKssg0pnuwl0B8kE00AdChHeuxOqSl9xYiJbPlPtcBaVxfXjIzmf1oYHx a3ppHcHBHS1RQMUhHA/WvlM80KG/1p5rKRMNrSC40IBAgxqOMNMoFOTucH5zMvqxaepCZJ IKJTMq71aXcjSIAkqOkPY7T8LcPFhi8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=H+ayEHKc; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=YgxV1M8o; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf11.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=1694636004; a=rsa-sha256; cv=none; b=ZAdZt2+Gqm+9DtfyHVyfsAeJq27Rg7FeikfFA8gEKcXdmKLMaseMZdS3P6apw8gnpZgju4 mA+bX26IhDPKyB5mQ4D+1EPmyFT9GP2i5f1Dqt4zPcdlmZBeXuL2V2xMp68998POoZwrJ3 MqfbX7ORp0SpTM9EJq2epxe0bDVrNtc= Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id A1BC43200495; Wed, 13 Sep 2023 16:13:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 13 Sep 2023 16:13:22 -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= 1694636001; x=1694722401; bh=l4bevEHulLiJ5YHyw6Y9teMcyGqHbAaeFHU aV/6ZIds=; b=H+ayEHKc5Yx5k+Dpc1wOOB1Y3ycugVwzEwwHd91K9eeo6tz2GMZ o33ft/YdfjMmTvM8YBdqDgvvVlPdq3S4OIgTsrSpnDohjyqct1/YmeU4yDSoy02A tPkjTNDVL6a3mQ19/TUut7cl2giLJq98zopfOqmR9d5eBAsXnIRLasFx428VGFiu RQ4oK4Cyz/3A0XTw/dvzJhkEmWaycHldo+LMf0LcfpAkV/vIuvL8lxrND9KvTeS6 WYC70OuysEGIDRBToO65ln/Cyo7B5Agdp1LtNShS4+BJS+TtX2pkZvvLBq0eAXLl WJdnEZZWQDha8YWY4EJ+ifRxu/i1o6HoQ/Q== 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= 1694636001; x=1694722401; bh=l4bevEHulLiJ5YHyw6Y9teMcyGqHbAaeFHU aV/6ZIds=; b=YgxV1M8oM33Puqg8fj6ipfY4rlBIRJuVZuMSIN9kxRevCGOpP+W aoW2pFq0J91Gro+JxjekWxs09v8kElVXgHstaNMEONK6uRSBBPu212JouOcLr3N4 7BuiAMO58woKwmVen+hAOQPd7KNStogYTQUHa5rXDK87CGePkfSRCmGi4XBOPOGh Pl3oMdD2LGDUWDzIkx6b+ke06EPe5+IIWzBnIkvY/jUhaCJHSpNF9RDq9nJBrl8D gmyNu+EwD1DbYD3/m92dw3hbK52VLvp09SkNBa1GJD7x/ESvHPZzgFGjEqUIdNTu fY3/9QQCffj6h8vIDhr2sSZOyjVGtF5ddgQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgudegiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enogfuohhrthgvugftvggtihhpvdculdegtddmnecujfgurhephffvvefufffkofgjfhhr ggfgsedtqhertdertddtnecuhfhrohhmpegkihcujggrnhcuoeiiihdrhigrnhesshgvnh htrdgtohhmqeenucggtffrrghtthgvrhhnpeeggeehudfgudduvdelheehteegledtteei veeuhfffveekhfevueefieeijeegvdenucevlhhushhtvghrufhiiigvpedunecurfgrrh grmhepmhgrihhlfhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 16:13:20 -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 4/5] fs: use nth_page() in place of direct struct page manipulation. Date: Wed, 13 Sep 2023 16:12:47 -0400 Message-Id: <20230913201248.452081-5-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-Rspam-User: X-Stat-Signature: ygqgn9mss3xs5n4o5egw7dotwxtxynfm X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 09C3A40006 X-HE-Tag: 1694636003-829831 X-HE-Meta: U2FsdGVkX1+3JUxZrw56x/2nTKJOXugYta4c2ts0tfiw0OFP9mawcj8TsXqKwriDGbOuUaoqKbgHqcMy5gexDWmDvZKrXH8XpvmB26Hr6SOftF6d/Zm0rtR2g1rZ6ypmfqsNiJT7lPmcc1URkoZ45m1A7OeaPaI0RV95Bm4T6LOH2ksgr7D6BO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ffZpe6wa+cwugXjlzNLKBapoy9qDnxsz18Hlsk2xsv+xA6OFuPpoQGD2bSNVGGPFUAL8X8L6pFCfT1GLuSNhf2RWAIVBROIPtocVEkiXb5RjoU93kkOvAlVRdWVk3Jyi26LFXiRvq+AoXbs5V22h05pqucdg79YlS5184CYz7Am7210TKCyDFrJqME6+MJMitR6L50QZmY0pa03Gf5xzoBzrqvNFizwaWi4oVF+hRF8mqYALnrb6ZNssXSBBQ0WGWaDoeqrFUXD8ccuoxNhy0iDDU6W4uol+JNffLye6OnOq5mw6k5CW1 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. Fixes: 38c1ddbde6c6 ("hugetlbfs: improve read HWPOISON hugepage") Cc: 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 7083fa0caaab..14d3d28e41b0 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 Sep 13 20:12:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13383749 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 04C43EE020C for ; Wed, 13 Sep 2023 20:13:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA18F6B028F; Wed, 13 Sep 2023 16:13:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C52516B0290; Wed, 13 Sep 2023 16:13:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF1686B0291; Wed, 13 Sep 2023 16:13:28 -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 9FCD36B028F for ; Wed, 13 Sep 2023 16:13:28 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8069812056A for ; Wed, 13 Sep 2023 20:13:28 +0000 (UTC) X-FDA: 81232674096.15.1C955FC Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf08.hostedemail.com (Postfix) with ESMTP id 4C4E2160018 for ; Wed, 13 Sep 2023 20:13:26 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=CBOmFlmf; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=R04EHa4q; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf08.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=1694636006; 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=X7/kZB7lpmBCw2k1unMB2GujXf55nXH6oT8ByqeAnAs=; b=NbXNEebFL6ZGNoRzVuj1IGPSxNbtTlq6iAcgMZhEj8vF15KZTdee2h3IP1GptNi5ntuMJQ E4YSILDExSIxp1ndrUJelF7XSa2w2akvtYOWv0p7GhlfZ66pDWhu4roacHxoDRqJWV5JEA UmFoY407X+JRpxIZ117iuOKVInpqIz8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=CBOmFlmf; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=R04EHa4q; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf08.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=1694636006; a=rsa-sha256; cv=none; b=4j41Wb/b4ixI+n5CY/Wuig2MBU66LOLm/ixn4U3sK1VjL2LhbPIJQi0eTlsluPn4FAs8Yx fzMq7rFw8VsECWT4RkwIxZGs8ZbIMLPlCC3+M3E+yKbHr3SpAiHiPS3od5EdOezQJDRgrq pmvXG93oG1Jf4QoeUUXEcZzl0MbA480= Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 080353200931; Wed, 13 Sep 2023 16:13:23 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 13 Sep 2023 16:13:25 -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= 1694636003; x=1694722403; bh=X7/kZB7lpmBCw2k1unMB2GujXf55nXH6oT8 ByqeAnAs=; b=CBOmFlmfdeIyUT89JnMFFy916vpAbJ9+Y0cZlpwErL9EqitXWZr uWr88udnznLV80ohjAvV5685ZWBBQEMoyF/qfcAqemAtrrEK8k2olxVb30YmPdUb Tlw0uK7KZPsGp+9j2OEfkrZzL3C4xkJNsEsDOva5YkPZKoeyPIr/gi7yBB1kbrNG XQ/I7z1bQqc9rOKkyTjShHd/+ahqxjRc4+Wxu3LFOY1SfwXY0murBB0Fl66mQpZj mc1dNZHIxQBFcfRzGoMNRSO+h6/Ikh4yrOGcLfNTjoXUcwObnu+yngcJ2fo4OrR/ TZHsqYmSk/VKyjpVhXMYY2cWckPbFTAE38w== 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= 1694636003; x=1694722403; bh=X7/kZB7lpmBCw2k1unMB2GujXf55nXH6oT8 ByqeAnAs=; b=R04EHa4qTG7s8rcZ3kVmP7mF3cLiCpbqwhsy5PJ+JwddtemnzQg CItzHuqb0aYBhWIBiGLIMyiQTfFeiTWpL+kSNDmPk6GkETnDAxmr6Nn2SVT+1vxp +i3Rdh3+cwEz1i4Z1IvmMlZ1edrQzgOpthPVnO5/0hfHMG/FsfUhmbGug0Cl0vqN MEcTlaWjY0Dnag15ONS44d/LdHbsl+wyeW+Lb5qXIwakLsnak8D7/ZiIJrn6psKI QtAKo0eOOGQrnQEiUSXWkkzeBXz61ifLsTqrqpNSflEXdMxnzJQltUpa4mWx5PoC 1PIex+iS2CJvgsszhUZhSBOnSzyc6//awNQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgudegiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enogfuohhrthgvugftvggtihhpvdculdegtddmnecujfgurhephffvvefufffkofgjfhhr ggfgsedtqhertdertddtnecuhfhrohhmpegkihcujggrnhcuoeiiihdrhigrnhesshgvnh htrdgtohhmqeenucggtffrrghtthgvrhhnpeeggeehudfgudduvdelheehteegledtteei veeuhfffveekhfevueefieeijeegvdenucevlhhushhtvghrufhiiigvpedunecurfgrrh grmhepmhgrihhlfhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 16:13:23 -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 Subject: [PATCH v3 5/5] mips: use nth_page() in place of direct struct page manipulation. Date: Wed, 13 Sep 2023 16:12:48 -0400 Message-Id: <20230913201248.452081-6-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: 4C4E2160018 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 8pcjnnzfx8hnnayrujhcxdcsiz96fhrs X-HE-Tag: 1694636006-48809 X-HE-Meta: U2FsdGVkX1/J65ibf3bDZxdTgehyK2Qte7iwqkdUpLqJHtzAiPMguhFHhGD1WDB3RKSzsac/tjEc4kRLyfPcjUapVnGhpJRZvIIfaIeDgwecXlTmOtewiQacHAf4ySeYz5zcOxmYesDMX4LDEwFIr6zsCIgjHvGVTD66YJBvxePGOoR/K6loOfp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d5EL3S0abcFvnzF118mJsKM0cgLxJwGv25+4wp+REnjd4PM39RCHu37GXCCYonLjWBlkXU52q+KLF1rVQhqJdofXpYXXaKL0T0Us9zJOvfITLZHVxVVgX13kRdBpkk3JYHfAMm81cufQCwqraxpgfEJeMUKWY5whulCWvjvn8WQwWVSePOIX7FudabNlzUXMmwPC/8P3YlP201RapxhTjEmL0ilaIOPvRwkFnkE8hlLxLqcgiNl 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. Fixes: 15fa3e8e3269 ("mips: implement the new page table range API") Cc: 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); }