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) {