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) { From patchwork Wed Sep 6 15:03:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13375714 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 4AF85EE14A3 for ; Wed, 6 Sep 2023 15:03:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F84D28001D; Wed, 6 Sep 2023 11:03:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 580B2280017; Wed, 6 Sep 2023 11:03:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FA4C28001D; Wed, 6 Sep 2023 11:03:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2DAB1280017 for ; Wed, 6 Sep 2023 11:03:32 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EE8B7A0C18 for ; Wed, 6 Sep 2023 15:03:31 +0000 (UTC) X-FDA: 81206491422.21.8A1113E Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf08.hostedemail.com (Postfix) with ESMTP id 322DA160065 for ; Wed, 6 Sep 2023 15:03:28 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=ylb72mJg; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=RyFkVW0v; 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=1694012609; 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=FRhlzq8UvIObngBkM6dyssvnlfJTeG6TGLo3e9CVZKk=; b=tErnjG/yIIb/DbX8j+JFaIo41W8UBHUbIDfuQzwhpBwii25JorR5KOjiQBxCnrw0y6yRER WkgngmQeJL1Mehm3T16NwZEddgglFP/snwz8txxXnlG2vApUsRn+mbdbiUogXOJqow3Og/ KNfoKS/rwjd261zXIZib6RV051lGe7M= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=ylb72mJg; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=RyFkVW0v; 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=1694012609; a=rsa-sha256; cv=none; b=JFeWJWcdiPp7gSdVPkywdnH3y/VSwRxPjRxrGe4G+8bHNXzyfCtnkP6Y2wzqWwyvyjhGO9 5epSiLqgcWPrqOD0215p7fuQBF+TgtZkA1BZfd7SuIoz1Rup8cMZDvxZ6OqcoN0UdFyWZP nFiOaSFiy3nZNUKrwfXSlCLtDjaVZAU= Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id BE0B5320093F; Wed, 6 Sep 2023 11:03:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 06 Sep 2023 11:03:27 -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= 1694012606; x=1694099006; bh=FRhlzq8UvIObngBkM6dyssvnlfJTeG6TGLo 3e9CVZKk=; b=ylb72mJgqmxN2pfmztXzBSYqUI0fCUryU9RZLnqhKRV6cdzQHPw WewNuJTadJnzAvfVVRxf5nAh2kQ+qRzYNJU3xPo/eWU0FHQRlpmtm8ojnyFRLaNG WAAE7vy0TSD4FClXqKHbrNYxYMUzHOS3nt39qBZiB3Qid8X8WaCpfF5YffMtZ4E0 lo5G79gkH6vB2HP52Yknle1/Zxz+TzayRAtcmBZ0BKaom8BxvQKURAx1sBOg4uiV JKOqVGNrlOm0oqAIjUJAaE/yULsfmxGRO6MzcRQz3qdCryUT6kvioH0ytebE8pU9 fpgKt1Czpg95KCYtQOcPxdYK1O325Bx10Nw== 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= 1694012606; x=1694099006; bh=FRhlzq8UvIObngBkM6dyssvnlfJTeG6TGLo 3e9CVZKk=; b=RyFkVW0vu58VoPxEjNCtMjVVEPg2uyGQhsVQI8c4UW2TuZZo30I EwigMAAynz1rFI8G1RAqCKG7OC9YZ1wSQpcVQArDwmmDwwpXuq3STKkmTk+63ahu MvDcewe93JMI10bkI7o4l93bEDVgSCzcpClVOo6B6Su9Z5DpPcaDRbedPbDjahDB gyA+QzhEGSNCPgAuf9j1bQhFetOMKdqadlqHqiEahWQ6NvMOzboJa4SGCixqvuRV 4p0uedH/D/LWU2laHLcu423rHmnFEcg15LhSbgv5lb3VGacOGcARjQ35xVchFTYL RsDzarygujS44z4Wynen1EJMc/3e5ZYKbmA== 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:24 -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 2/5] mm/hugetlb: use nth_page() in place of direct struct page manipulation. Date: Wed, 6 Sep 2023 11:03:06 -0400 Message-Id: <20230906150309.114360-3-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-Server: rspam09 X-Rspamd-Queue-Id: 322DA160065 X-Stat-Signature: emjpw3szri9n9rseuyedncmcmidepyk9 X-Rspam-User: X-HE-Tag: 1694012608-768488 X-HE-Meta: U2FsdGVkX1+HrZDzJCN4yrZS2/z94hmG37xYvN1nrzF/jnmnxSWVpF97N8VL7VCXQeOnXKa8tiaofZDShkdMpkyBN8oL4pzD08QJo5agCx0lPSzbXWYG+ldM0apzGYCPloTBBebj0ilgWl6MLgsmpRZi6jIjnaVqoGMLA0vwIh47Fsd+Uz5yOagcEOWP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5oXdZL1wQIsFJLSskvdhmKJkY8AVjK7A7DLGyEO4V097SNH9HEbLLJUBisYGpJtaTYWiYZACKEJolN6lVs/5WK1pygyG4RRYMawd7UC8Bp2J0fmQomAcrZ9x0P/MO18CnQmUJ5JrddLrwN8yl9te5Y9tR2iBfF5Y0wZsGNcNJBhkw5q3J7XG5KC1c7YyowOwDSlaVgykJxtUdyFmW5bJNUgwzWsYInTTECTdj6C9iRs7ZStQl4brxw/Rdki1FV+nS6yDnf12WERhqcSJxq4uf00LPEStEkMaPrNPr7HlE 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 2e7188876672..2521cc694fd4 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6489,7 +6489,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 6 15:03:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13375716 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 ED57BEE14A4 for ; Wed, 6 Sep 2023 15:03:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86A5544016B; Wed, 6 Sep 2023 11:03:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F3D0440151; Wed, 6 Sep 2023 11:03:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 534A244016B; Wed, 6 Sep 2023 11:03:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 40371440151 for ; Wed, 6 Sep 2023 11:03:36 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A2719120DB2 for ; Wed, 6 Sep 2023 15:03:35 +0000 (UTC) X-FDA: 81206491590.25.008BD23 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf01.hostedemail.com (Postfix) with ESMTP id C9F3E40049 for ; Wed, 6 Sep 2023 15:03:32 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=nB5E8Nf0; dkim=pass header.d=messagingengine.com header.s=fm1 header.b="aXvL/qIc"; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf01.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=1694012613; 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=xs9KL3ri9aVI+oSz6c/wzHeHoEyYgueyVeplOsiSZNc=; b=xwdY4ePFja4kAVbLGy/sx/Y1ABS3WZRC7/ckGOWB7a7KJEKQv+wsinIjiz3rwP3JyyJmsT 6L4WFHQCoa0vVczS7Hf7U+VvSPGPVIOgHa1OL3MHVFS0STGAgkIwygRNJYrIcJIqub+osx 5qliUeTgb6JKMO1oVKXrV1PnkuU0k/A= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=nB5E8Nf0; dkim=pass header.d=messagingengine.com header.s=fm1 header.b="aXvL/qIc"; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf01.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=1694012613; a=rsa-sha256; cv=none; b=TT6x+t1+/B9e1bm5Ga4u/6kHaJrhB4bwdkGd2phPkUdHLQ1PQ107+OsgCrGKWIZIKP5wTa XB+ZAfgUlsk7jmzyK6PoX7YDjGSex3UPNOawvD0nFlJo7HAuLvR+2VTL4i8lhXCDUJ24N8 01xlu0SEVhmyTCg0O5Bor1TR28eyYDY= Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 349A332009B4; Wed, 6 Sep 2023 11:03:30 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 06 Sep 2023 11:03:31 -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= 1694012609; x=1694099009; bh=xs9KL3ri9aVI+oSz6c/wzHeHoEyYgueyVep lOsiSZNc=; b=nB5E8Nf0GD6htUo2aB4p6yasTdnEGokEuYUgdnPHevyRvD+KCkp N0NbHMsERPS0fbnw8fRvJTxRO/oZy+uwVXCoffh9/V7DiL/YooG3rI0Iknk3UMlJ Jn1ve3i+kfepifLG2+YMczZwP6hYfkuGGYTsrR0dpH4D5g8szHurVlMglHfAE2Nw vz1IzDq3LMsH1l55+342ENlb4iViNA/l0F+QL6Rbl89rGSqZ300iQNin1uwY7gt/ ShQLkG2HN5NinkY4VpN9pAV5FeovYMZpgxGbs3toTEwWrAR5y9QaPsvgy1U8LWFb qO/7bGq0wnYGjE0CCMb7jopJc7eF4iDZFcg== 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= 1694012609; x=1694099009; bh=xs9KL3ri9aVI+oSz6c/wzHeHoEyYgueyVep lOsiSZNc=; b=aXvL/qIcbNerg/966+RIQLQ9nA/n3Ukd8U5WJbdEZm6vwrid1Nl FToc5Hnw1VWFaeKCb28wiRh22eYTgChPUcq5gTy0V3uFckWRe0XFyWiEaKb3hY04 FmxX+uynciVOqI0kMOawAYg6aIixIR+f8SG+pm2y4bVKCGg2LH7EWEcCwjb70KrL sSKzqUBRL3lHL9o1axhL//JzYLylnNFw01HA0j6z4X99CVue7pEU0eb3sZljwrLL ppvdSfotAlWLaaIfOoV5XrwkTZjHG9h9sjbFVc2o2fmSMmfWDSStdRHuPTsauNkF 1KBmC7grgN1XHuIw3GKVQxVxPoWthxoO9dQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhorhhtvggutfgvtghiphdvucdlgedtmdenucfjughrpefhvfevufffkffojghfrhgg gfestdhqredtredttdenucfhrhhomhepkghiucgjrghnuceoiihirdihrghnsehsvghnth drtghomheqnecuggftrfgrthhtvghrnhepgeeghedugfduuddvleehheetgeeltdetieev uefhffevkefhveeufeeiieejgedvnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrg hmpehmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 11:03:28 -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 3/5] mm/memory_hotplug: use nth_page() in place of direct struct page manipulation. Date: Wed, 6 Sep 2023 11:03:07 -0400 Message-Id: <20230906150309.114360-4-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: C9F3E40049 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: k5ktkxzio6a7t518xkeguzkhon5ci8xw X-HE-Tag: 1694012612-403538 X-HE-Meta: U2FsdGVkX19yvCYmFt0y3/4fK0QvZYiQwWteEFB6hbQ61GT96LDK6qYh2W/xsLtK3rTV6FcOsJB2CUFKC8EJGmi7JkU4ClL7E8tNsK7p68tOO18j7ctS0SGr3WA0sMhZnt+gM9tDOIjsgq7Jhb3KlL7oAlhsSnvQoRY9E1b1z9joRkt4wKb6bsnl+OjawxdoUyP3mVnD0YgD7CbEmrcMQH03DWadIG7bnvsqx8e3r/M/QtasAStHAivQ6o/guJhh1gYGpK+YRfSiP2+2xqEWSzfeBDBjrk3Rw6jIExx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wVcPS6qD5SJ6qdtQrRyWniX6ENNqp5CM9T/Et6Vuydfs2e3c74BWE0GUMe3k3jPRVXbB8TQeWxP7TmJVRJeBgUqOo86U2qS7diqIIfVGIcfrdegkR2NedCze8A/ihy/FuH1HillZeZKmVMLhemamFj9KsUEmhIQElBs59PrszemXA60218cOOlMkAHM1OCQulYw 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: 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 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 6 15:03:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13375717 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 61689EE14A5 for ; Wed, 6 Sep 2023 15:03:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86A2F44016C; Wed, 6 Sep 2023 11:03:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F2C0440151; Wed, 6 Sep 2023 11:03:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61E1E44016C; Wed, 6 Sep 2023 11:03:38 -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 49BAA440151 for ; Wed, 6 Sep 2023 11:03:38 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 11E32A0C8F for ; Wed, 6 Sep 2023 15:03:38 +0000 (UTC) X-FDA: 81206491716.02.F31FC17 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf02.hostedemail.com (Postfix) with ESMTP id A775E80044 for ; Wed, 6 Sep 2023 15:03:35 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=pCUlhr0P; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=qhSDgtan; spf=pass (imf02.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=1694012615; 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=cqtMZEUvBe54JghNmYIOYKwpXMmZI+q66Bi2kSF9BAQ=; b=iJmzP8u/mTCVN9dDBXwkzF6VsEJYO00z+rcZwhYEE5xDX2v6bwI1mdSJ4oxrStHrOGcnYB 2cjMYludHmA8lwiqJv62LoQvRNSO/CS6wj35bs0GaRB5DtcU0mMnqEiCk2DzItsosjeiwH k1zBLPrY9ndyFYN5XUDVkaWacopjkKs= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=pCUlhr0P; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=qhSDgtan; spf=pass (imf02.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694012615; a=rsa-sha256; cv=none; b=4BV9cgpBzLhQW8px8SnbKxguSBhh922vzxZ+xaeRMVunLY+xuhnwkLmHrv11JzENzI0WqS kkojLRdtN2v9Zm6hq7B9QGt8B0iTuhQ+0WKenb6ke4Vks1hAcRr1ZVM4Z9mDD7ZO65LM91 rMXAjluJ7rOIbFHtqfRA8QLggJjDO1g= Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 45E1632009C5; Wed, 6 Sep 2023 11:03:33 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 06 Sep 2023 11:03:34 -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= 1694012612; x=1694099012; bh=cqtMZEUvBe54JghNmYIOYKwpXMmZI+q66Bi 2kSF9BAQ=; b=pCUlhr0PqKkKxrLg6/MAEej8PHN+UaXMGYaUKHfsyEqZii72vIv gF0fdzEG7vtIqYpsYif27qqiciuJZzSDA7T2n7kmrF6jYoO4IbIeU7tWfi44QyhO oA/2yQBIU24n81ylhfY2Uwg+ko+lEw4sQWOCQjHJ9bQUtylPhYkxswK9Bom7G2Mr steSMIHZpymEEv6tObZHSSMoWMvHdbCz41mA0Jup92qZz7oNa9OwMRQb1pGmrd+e Pq+xtKcSl10jploMADZBMHSKRZUhEfTTqWDrOX0BmF1lf8LFc96vYrrnLrmYX5t8 E4WBACH3Il/bRFeSCRzmP6v2BwcvEP3khfA== 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= 1694012612; x=1694099012; bh=cqtMZEUvBe54JghNmYIOYKwpXMmZI+q66Bi 2kSF9BAQ=; b=qhSDgtanx+0+pDt3JTxcMZmdRwzhQPSAjuqOLwGGTNZLjO57/tf WGxNmarVSk8cnsbHZlErQ7AvWs2JK+xMUdbld8zXeqCu65S8QwCeJJqVqP/IhCUq 0WNVFsMVBLnF6psCkT7qZofRZcAkaE5qJv26bJEze+db608cOoTam68AgTDzY6Ja MG8x2WjkNaBlVIlLdGckGofLL7kZE6aycGsmA4peiiHgBE+rRCWAz8iVyHrGCTsP gq77YUMS8WGl7Lk6Cc1YrtApBiTV5XK51y9CbUQil26cyUNceJyZbXLByzlLabGa RgOL68x+vSiMAhQHz/oTn6PUSsVILwOLfIQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhorhhtvggutfgvtghiphdvucdlgedtmdenucfjughrpefhvfevufffkffojghfrhgg gfestdhqredtredttdenucfhrhhomhepkghiucgjrghnuceoiihirdihrghnsehsvghnth drtghomheqnecuggftrfgrthhtvghrnhepgeeghedugfduuddvleehheetgeeltdetieev uefhffevkefhveeufeeiieejgedvnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrg hmpehmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 11:03:31 -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 4/5] fs: use nth_page() in place of direct struct page manipulation. Date: Wed, 6 Sep 2023 11:03:08 -0400 Message-Id: <20230906150309.114360-5-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: A775E80044 X-Rspam-User: X-Stat-Signature: f6jk5s44ok66xjtc56ddid8fzadiy8ub X-Rspamd-Server: rspam01 X-HE-Tag: 1694012615-318668 X-HE-Meta: U2FsdGVkX1+8bILcvtLCX8Ao0YhmdBpVKhWZQHJb/6rSvXOpSzZzl1o5bAoWMEXI3xKXxsVJLTIPp3G74NZIy3IvWt6+VlfCC7E/6xk3Nvl1PBiXRSSatr4t9N5qLaSKxdb7JOFbjN4SjI8b+EQqdQkfXKVE5cVkhCqdYyXYQCvEvqsIyPYLyySw7H7uTnTIONy+oP4JMdFAb6iqB7wMwouLDial5wgYOIRB1f3X91MssrR/1ucH0cQr5wRCgkJmgb3cp7ACpbVs/wLBqNrbsF9fPRD9QDOyuA1woptfsyk7NkWqwOuYq3DT4MF3jSlekx7z0Cw6SGi1R4dGJROB1iY3Qz4DXEd2H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o4IwuTLiyAakXC/n3O+Wg5KDDrbJYUAUMk/KhqIfGF92m7+ucdMaCYCCDcQD41zgB/rPSVgf7HO7/1gTft5XjtElQU6lLvsLveMhZoLU07YVlBVjLTcpKQ8wjT/y//7TySMu8RiEDt7xFL+hkYh88Mh4RjOc 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 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 Sep 6 15:03:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13375718 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 B25C8EE14A7 for ; Wed, 6 Sep 2023 15:03:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A1DA44016D; Wed, 6 Sep 2023 11:03:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 003B2440151; Wed, 6 Sep 2023 11:03:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D70BC44016D; Wed, 6 Sep 2023 11:03:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BFCAA440151 for ; Wed, 6 Sep 2023 11:03:41 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8F2A9160D81 for ; Wed, 6 Sep 2023 15:03:41 +0000 (UTC) X-FDA: 81206491842.14.E2754CD Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf04.hostedemail.com (Postfix) with ESMTP id DC77140062 for ; Wed, 6 Sep 2023 15:03:38 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="s56TOG/g"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=dsbymiPb; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf04.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=1694012619; 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=tA5h65ebd0wKNIYuGhFvWEg78woV13O44fUyZWMBWSUe7HoxS8scTJFN7rqqsRXzix27yk mEWLlyjA7t39mYJSmDjv003gdwIzYioU/A3GqCDK9Iz2E9Ory0aCNVErx8G9jhl888/me8 WN0+Nv+5ddJIeH+y6c/z9LhjtitKxAk= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="s56TOG/g"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=dsbymiPb; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf04.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=1694012619; a=rsa-sha256; cv=none; b=Gd95r0sX6dcvKufrJ9xnKGAjyMJHMHkLiTsqssO2zVnqSAdPLMnN4ciMghSYul1u0UhVWM TOuMRKGm+9pMTmICgUo6R1zYLbml8+oUCZ7F+PowQnxYgSMzzI/9ArtD/pjbzvGJOhoZAY o+weEtDkU1ENVncboGiNNPOQEaOG6UQ= Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 40E453200904; Wed, 6 Sep 2023 11:03:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 06 Sep 2023 11:03:37 -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= 1694012615; x=1694099015; bh=X7/kZB7lpmBCw2k1unMB2GujXf55nXH6oT8 ByqeAnAs=; b=s56TOG/g3wW3xdiIqMGnd+ngS6IcPFOJrgFciXKXnjSSlKj8Inc gmOg53MxNHCTU+4MczmgLmSph3GPf+dxfRb5d6RJmtabLNp16TcmtIQeYj53m14O T9BvHZZ5HcHgHl2ccLvCgVbR73GsLu1VXPNu3K4/bCMRea5wTpWW5oZ1x1+N4HlC 3IYNRuCZ5ehUJ3fAsJRaVmkV/AAy2x85yhX4BDK94tR7AWi73acL19o92+oj+JaQ bxr3F/dwKY/UI39cMU59sNCk+jk8xeMn9LMBSBDkK3iJu8rw5/KD7x8+nf1+Jlo6 C9z4I3J/habuZfvWzbufCWdsbiCRpIWnEpQ== 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= 1694012615; x=1694099015; bh=X7/kZB7lpmBCw2k1unMB2GujXf55nXH6oT8 ByqeAnAs=; b=dsbymiPbH/noxVmpwQtJWj92IfMyXpQwtT4715YnPxEu8wfhQ42 K/L4u3Gk9fzKNgeCzhS3sqGqqIn2mvqETe1CUukPuAINgN+pmvIlIKnWQOAU6C7i V6BNXA4eyYrWCUB+JCg9pY1yEPjtOqcwNGDY6C5T+uXMqDP2hQ6F+PAOyiLMN1TI lPtzNPQ1+eAkE2XV7vOH5lSQdPC7Qm3rHP9+4DITK2enroBBmsRHzh/gaNAvNeaE a4nIdAya9YboYqVIE3dYeHcqGgD3oxb1oiG7d3MC8X3KYlchpUuk+QwYKS8RSkJi aSdUgeOU/Bs85BZdWwyEJXsRdfOqvu990nw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhorhhtvggutfgvtghiphdvucdlgedtmdenucfjughrpefhvfevufffkffojghfrhgg gfestdhqredtredttdenucfhrhhomhepkghiucgjrghnuceoiihirdihrghnsehsvghnth drtghomheqnecuggftrfgrthhtvghrnhepgeeghedugfduuddvleehheetgeeltdetieev uefhffevkefhveeufeeiieejgedvnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrg hmpehmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 11:03:34 -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 v2 5/5] mips: use nth_page() in place of direct struct page manipulation. Date: Wed, 6 Sep 2023 11:03:09 -0400 Message-Id: <20230906150309.114360-6-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: DC77140062 X-Stat-Signature: 83hkpz5g87nefddn5cdi8aqpyw7bkjf3 X-HE-Tag: 1694012618-662023 X-HE-Meta: U2FsdGVkX1/v6Y6rD5gv72a0/VvWKg5eTtUrNre5zK5EiCyfJ2uj3KUauZ/NcH0h78SCks36AdfVpuzy8k+dpSvYh20PcZd9PCR4W0VJ4IaGVQ+Cm/RJVaKPSDLIfDjd999ZXSOeMU21IVpta1LBh5biF3C6ibUjLfpv/N9FuEKRsl/7Q0mufdZwFr+NqbQgkdwQ0JcZ5nCtWIoAliaSCSQbY2A5IhYugK/+la2AQRZNmoemtAVQQY2atspg1cafy6/TOUmswlG+8UPuwwMCczf4vqCOmz5cHgMJoHRzmDjcxJkriKYtWQH5ldq+iM/6ZftlUXaPHTFu5BmkV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y5+t0AjDTmQunLngO25wF79yvRO6nDiwAGLm4QdzPFSj8lVNqEKEaIzLBT29CUTUQxMW9UCNkcu50JYm4 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); }