From patchwork Wed Sep 6 15:03:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13375719 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 1CA82EE14A4 for ; Wed, 6 Sep 2023 15:03:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1FF544016F; Wed, 6 Sep 2023 11:03:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA980440151; Wed, 6 Sep 2023 11:03:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D230444016F; Wed, 6 Sep 2023 11:03:43 -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 BDBE9440151 for ; Wed, 6 Sep 2023 11:03:43 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 97CECB4167 for ; Wed, 6 Sep 2023 15:03:43 +0000 (UTC) X-FDA: 81206491926.01.0A12482 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf14.hostedemail.com (Postfix) with ESMTP id E28CA10009B for ; Wed, 6 Sep 2023 15:03:25 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=vcYBM45Z; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=dUCL8M+R; spf=pass (imf14.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=1694012606; 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=H8sen9omJwpQsFJTtO+3KtjD+QxgLjPd0ePLj46J8FwsSxOKDDQB9KN1MS3v1hKzF3QDpy yCTLpGHIdi2ahezO6N1p4LKSX63J1fuupozyqsXEQvHBjSKmAlTHr0Y2gCO+NFOMbNFuF6 WJtZ+IIq4Pp/w1QpdUWQhkxwCPFY9xg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694012606; a=rsa-sha256; cv=none; b=8k82o3zeFjIP3KZ2PpYZL73fX9e0CBC4ReP/YLz5BgWSOpxjNnwPcBkJj6tYgBT4Suf5Bt CTMaS/US9Dc6ni6mOnlHktBW+Lwdy0jarV8sQ2vnQrJpEGjhJGD9CkvOtBmcst4TiXr5AB 8n4ktAx7P8/UkZut5DXNkOU9/I7wb5k= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=vcYBM45Z; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=dUCL8M+R; spf=pass (imf14.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 compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 2FC0332009C2; Wed, 6 Sep 2023 11:03:23 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 06 Sep 2023 11:03:24 -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= 1694012601; x=1694099001; bh=W7emFMpfIMC3wLaZ+9JtBDyJqJ6ODUK3zLR X50gZBXo=; b=vcYBM45Z0NyfFhbQnfqMxgYUvYl6KExbiuS5d4pGXEm6TPZt6wa LevI4fk+W5gH/9RzeC5Jw+9b7P1KGiTJV9zp93SsgnTikIc1lor43Ryy2D+9NYAq Q+V1uoMNIQctbWdXHEHR2+pUPsfsIIcsEWwgDOOcj2p43cK0/UTA6WD/l0mNYHTg OnH5Km5sFPNuK3YfISX47UXgqyogINQZz8Id/rbjwKhCqH8qxu7VfAqZMQV2msIK 36hLQOogNALv9IzK+N7dY87aQbt+esmJP7cDRe7UfrbFHjmY+tMREaZIv7+KT/Sp 24ZB4lE/iDe6ju5TOzqDPjkU/ZJcSmhHaOQ== 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= 1694012601; x=1694099001; bh=W7emFMpfIMC3wLaZ+9JtBDyJqJ6ODUK3zLR X50gZBXo=; b=dUCL8M+RdnSQEis5+inefIkWRr+eO17dlVGmXvF+szI3ylwv5sj hW+6e3IRKftMQ8I/aSXitmrkd96cXnwmeWK1rS3JjL887VdFgoWBwQGaoAwkq08U Tmj1Dm/fz6lCmqKNEcP/4y7Og5ilEBc2NN+SS/IgcThjeDlVCs2e+VWdKNniJyov lHQ1tBLgfbRwKE+lfrq+O27C5X2iDuqu+onMRH+wUY/RuJ3byVmrax6h27xoguXC RfOT0v2wSP+Zi+AsENyrD6aJajz+iGiKQPzhjdTCnkMyJYAWngFNFhOCI30TODCl ERq5GxYS7RNVXCKOqRZ7smQuBMIjjh+LaqQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhorhhtvggutfgvtghiphdvucdlgedtmdenucfjughrpefhvfevufffkffojghfrhgg gfestdhqredtredttdenucfhrhhomhepkghiucgjrghnuceoiihirdihrghnsehsvghnth drtghomheqnecuggftrfgrthhtvghrnhepgeeghedugfduuddvleehheetgeeltdetieev uefhffevkefhveeufeeiieejgedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 11:03: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)" , stable@vger.kernel.org, Muchun Song Subject: [PATCH v2 1/5] mm/cma: use nth_page() in place of direct struct page manipulation. Date: Wed, 6 Sep 2023 11:03:05 -0400 Message-Id: <20230906150309.114360-2-zi.yan@sent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230906150309.114360-1-zi.yan@sent.com> References: <20230906150309.114360-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Queue-Id: E28CA10009B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: io8rp67kopsz7cwkjwu3mx5qs5qpzfnj X-HE-Tag: 1694012605-30033 X-HE-Meta: U2FsdGVkX1+TVjfecmPnQdXsJn9Sc7qIAAYNZb1bqXaP0G60Fpo0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F7FWiCCDaTzwdc+fYDbzD5dVQKOULsD+EHKXPuHsA+xXF1y4MqAbtVWtSOWQfW9jCUbgVob3XJ5JYECJ4y0rKNVN/cHj63Sn36HPHY8/GC4O4Mez8v63MJ5j3rDMP6/S4wKnHTfo05O/aimDAganeBHs88ZNT6SPhiyCqi/T6wNbycuhUA96DXsK8QEg98+D/u16MBZV/3x/iji5QZEc0jXnJSaj9VQCOY0Ryv0QAAfcNwXEgxucL0XX+KLlCwVrMCQjiIcBZJdjdkJl/ogRmdsvIAy9YkZotwf7XTyDb5/t8m8cuBm4Lp5H+nEFKyz6t1leYDCKH5YBPqcEUfbIlm/K/oHwgCrLTEZJmNZOo+h0qDTGbK0GdPNhmQthPUk2l6o06D3gMejP8ilcAKUI54LFBd95C5KxbG2Mos52TJS6LCJiRnGJr2N7g9cLk1b7El+GaWR5Mmx3nycglfWv 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) {