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: 139165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a5a:b0:13f:353d:d1ed with SMTP id 26csp83551rwb; Wed, 13 Sep 2023 16:47:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMWtt053nQy0KXhZut0K5Z2cy2wpK304au93fviH71mcjCpPPE/4fROdJjh2L2VYXHhp/u X-Received: by 2002:a17:903:264a:b0:1c0:93b6:2e4b with SMTP id je10-20020a170903264a00b001c093b62e4bmr3780251plb.33.1694648854642; Wed, 13 Sep 2023 16:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694648854; cv=none; d=google.com; s=arc-20160816; b=KA2M3uj8keSsORW/g3de4bXw6WREQjoPJR3vnRSl5BOKtTES/rEaElTROyYyhziKcW sIf3p1RQPdqA81Roa5Tx7CXfIMBFSoJW8sNKLLgeAE5HqVBKILZowbn10vf2FXO5QRlp ooCLUqdTYf4Wqx6qEV6hVBTMRV4VNcN5Ygn4J55btJWmWfkELIR/3L2P+7kEnVmZKqAK 8PwzGnsYQjhjpHF3iq586A3nWWL5xP4cxVVxGSmgAggGH2y8b/q2EXE884p76q33sqfA zmCYt+XYqQFSjyfW8c0TUWjBQwvToB9u0Pk8u0Tb/1n6f1PH916mLrjwEy8XhccbLYPB lhJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=W7emFMpfIMC3wLaZ+9JtBDyJqJ6ODUK3zLRX50gZBXo=; fh=uXOOnG6dSiAFwWm6vSsvJiwW7q8GOjY1G0eNovT28gQ=; b=YT0ckjVdGpfuiFCuEltb1igY4qRaihhOASWboZQL6+1QAvQhT6vslB3wskpiHEklDR iq+vhHWO5XmrQoxeS3hjCLlp6D9zU1w4ryjTQGy+cJJO9nG1PX5nF2JAvSgj9+eizmh6 0ix1jPJ9RnR9003Ubf7SeXYmT/xkxQMeYTciIF82fZrGpv0xee+jytIA3jrOveYEMVmc 0iTvJneayk5R+R0F7k+NuvGPhpHhMAme4AUH567eyhyALDK1avNuwMP0XBaCPKaRsj5f C0HMGfltmO4fALdcYkMYNkuIEUxjyj3e1xqfrjWbzmSDhx9QvkXhykk0+nf4b3PJII2L nw3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=sQpceFCL; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=f1J1usMY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id a15-20020a170902eccf00b001bf01fee6bcsi372765plh.610.2023.09.13.16.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 16:47:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=sQpceFCL; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=f1J1usMY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DB59181F8500; Wed, 13 Sep 2023 13:13:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232165AbjIMUNW (ORCPT + 34 others); Wed, 13 Sep 2023 16:13:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232128AbjIMUNT (ORCPT ); Wed, 13 Sep 2023 16:13:19 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E28B1BC3; Wed, 13 Sep 2023 13:13:15 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 13:13:41 -0700 (PDT) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776968117749431546 X-GMAIL-MSGID: 1776968117749431546 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: 139069 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp61978vqb; Wed, 13 Sep 2023 13:14:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHz4dlTFmfJH78dfQ6ibkUDT40yFflcFYxI9Gy/1iBQwNHhecbH/abya7MQgOJ0CJhPFgSG X-Received: by 2002:a05:6358:8823:b0:134:d45b:7dd1 with SMTP id hv35-20020a056358882300b00134d45b7dd1mr4236254rwb.21.1694636080642; Wed, 13 Sep 2023 13:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694636080; cv=none; d=google.com; s=arc-20160816; b=sbvnNgMAoHKB0rZ+XeAXR8QDM2BEjvnxVhgspfcIr4bR9SLCm+5gaq5937CMpuEuM1 jhKgjlOgrlh3SRSj1r0mq2Nt34mT7p1yHQWi3sb2UxxE0KEZUpo8hYX5sVuSCRSMs+RT w5VPHcFhXALwADmNukDjdO5/Ralt3f5MuQ/AxZKStRpj47snMzP4LGWyq/EDCIIEdbqt /7gyyzq3HQrVOun7lKyqkD3nJ3uS1Ek0eHYnr2r0KSmoDT455iImKFT9CdqRgI3nbUrg 9x+TovedvUhn0Rwuv4Iy/iDDOmKl4Ocsww9zUTCd1O9Nw18n6T2ie8IG8jy+DitvEdeh D6WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=mxKjLm7C5akdzlDNgIeEXW3U7M/tKbi4yzpZmBIFkQc=; fh=uXOOnG6dSiAFwWm6vSsvJiwW7q8GOjY1G0eNovT28gQ=; b=dyZo2Hm8uXaqlcIC0hqNGYU8FPI+zdG6Vhu5E1akQPevkd4KQy/9BjNfgS2yVarfki vhm5ORdRBEJkUHuogQzMnIcBEJ0SzZybPSHqZsDTBsQUUBXo2g58iXxlkPE6VlTC8nA4 2gNnL0a1DXlzh0rTbtZsG77gpVvkobL2vcnB7SPhXA1i6574VgxYYqEJ4TGEDgBajGG8 Ga3tOv8USnMI/A9vPseEhFjX1+cCY6gNhj7PA07hPzBSAJi/l5vuS5Y23+n4wXqtXwr/ wS4lnnFK8HVAY0h8eyiIpfxt3X1BAFkWaY2cW5C7M6sHqXu5VWt2knS/ZmoT/JL7CjUT 1uyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=Q33sr6nx; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=nln4VLWK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d15-20020a63360f000000b0056944c06855si7743555pga.88.2023.09.13.13.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 13:14:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=Q33sr6nx; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=nln4VLWK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id BE85B81F8525; Wed, 13 Sep 2023 13:13:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232217AbjIMUNY (ORCPT + 34 others); Wed, 13 Sep 2023 16:13:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232020AbjIMUNV (ORCPT ); Wed, 13 Sep 2023 16:13:21 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 150981BC6; Wed, 13 Sep 2023 13:13:18 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 13:13:34 -0700 (PDT) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776954722632363525 X-GMAIL-MSGID: 1776954722632363525 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: 139099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp94359vqb; Wed, 13 Sep 2023 14:23:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIywQyTCXSxNGi7Ynn1qAtWEbjz2yK+bGZ4sfQhycKXtaivCJcBQ4cdpWFk+zjCB68Ig39 X-Received: by 2002:a17:902:f688:b0:1c3:3b5c:1fbf with SMTP id l8-20020a170902f68800b001c33b5c1fbfmr5211770plg.10.1694640194867; Wed, 13 Sep 2023 14:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694640194; cv=none; d=google.com; s=arc-20160816; b=zHt98yFIm6cFhiw4Q7dlYFOiLymxMs1fRl+Y/OMGCjk0eAtckE/m1P7xkSWXXmkVCK iK7NWkLmXOtMlVZKzmafTvc/Zw8dvHVl6AY/ywAqsS15zj2yc/bP2r4DnAUkxCxsj2Te 44PFqYMoK1mzbQqN8ZmdrCvxKUpKKtrTluJdb0YzaZU6dHBEDRXcEgrIpfzhkDgWXWx4 QEB8ErCoww+86IH6pVKdeehiDAkC+CVwJejW6/K1yyUS4PcZjZSmBWH+H4Oc2Hm3ofRV vGWeCZB+RpJ0b5iRZYPKoGldqwQbBLaaX9+jmBfqrW2b1LtJs81VIBi0PGHbLX0RVl+T zcog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=0WyzrkiVwl0HyDd6Aci2MQZZb/Gy7N43VoXzZpGq6Jc=; fh=uXOOnG6dSiAFwWm6vSsvJiwW7q8GOjY1G0eNovT28gQ=; b=IX/nzLIxQKzt1rUosyG4Yd2g3DVs7mDMoOa1rlYViXkpNHKMcwpGL+o/5kjFFhSNm2 sEL+1F5O3p+lK/PnayFIvNzsR00DZSaHT/0XyB5Z2uV8r8R8KLLM2y5LtEFndxWQPJVY xPF7xoeAhMptfS4hAAZOU1eQnZDa3urE+YepzrGnx1HDSKC2QrTmkhAIutxEhz4DH82c KC9pFIYyz5JnIcuwPYqGgvsIERomiXMUSyFzrkinG3avPaUd4vS+WYKGDhsdWPm6uH0E BK081juZzBdDGkUhQSGj3bJ3QMfdrcahRg0cJKQADWtZk2S9IxJjV8TCDUWfdF201dit z8Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=naPdsB3d; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="gUo/FnX8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ay6-20020a1709028b8600b001b9d800b487si153772plb.87.2023.09.13.14.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 14:23:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=naPdsB3d; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="gUo/FnX8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A20D681DDD22; Wed, 13 Sep 2023 13:13:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232417AbjIMUNc (ORCPT + 34 others); Wed, 13 Sep 2023 16:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232241AbjIMUN3 (ORCPT ); Wed, 13 Sep 2023 16:13:29 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B10BF1BCF; Wed, 13 Sep 2023 13:13:20 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Sep 2023 13:13:44 -0700 (PDT) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776959036703659938 X-GMAIL-MSGID: 1776959036703659938 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: 139296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp89238vqi; Wed, 13 Sep 2023 20:44:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4z2v/pQYU5V3jIlnWLSnop9xx/abmflvhcg7fmcYwyLR1j5HcCS1IrVLLV/fzslng8sf5 X-Received: by 2002:a05:6358:8829:b0:13a:d269:bd23 with SMTP id hv41-20020a056358882900b0013ad269bd23mr5196045rwb.16.1694663061008; Wed, 13 Sep 2023 20:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694663060; cv=none; d=google.com; s=arc-20160816; b=p0ZAO7ChE7q2zcb28kB9x2I7+AOK3Obn2cLrgngxf4y8qVbaIOYbfg2XPPCeebKBsu khZEQr5SjVx+GPBiwxoSDHKXzWjQVqzwloD41SNOfHjEQCbfD5sCE3DSR8kxNGlNzVW6 whYqe+u0dT1Bdj28dkdrv+eUWxB/MM9eV5OF1DTVVqqqLCC6oxyccvhHIV5oezuvGJtr rTsHgt9zz/plYYzbSdIQHiMhT2TAxoxE5VywZdjYnO74WKx3QoccZk3hKLn6ZmJ13XTl 4/cgBZnCLOWzd0DVNesjoUUJFG9UqTUrQhmKjteLOeFEXMN+ibpTrTP6Fuly8dFmsY/e fE5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=l4bevEHulLiJ5YHyw6Y9teMcyGqHbAaeFHUaV/6ZIds=; fh=uXOOnG6dSiAFwWm6vSsvJiwW7q8GOjY1G0eNovT28gQ=; b=i6ELG/YzF9C+2Rz+nXtiWelJm5yiGkIhqu9l6plxBMRnU9R/HmEdQx0gw6VfuzZm81 JBV0gRgB+MBMqIIS6QTu0wN80LiDUm4bjTN63UwAcG65cytt3wWtK81x0HrBDYZy15hf TvKjRdMMIu08Jfifk9HCgUC6eJKo5F1Zsw2ltm4rcrNJBO5nLCpVvAK0+0aPozIEBWPP j3sVoFOpyhfhHmDKQZd9gGldmsNC6IehfuT4du6G2CX5rara6ON2RnGJpGR2M7Xs/pzp LHeIz1LewwjluT2DWmTDypEL0HmJm+1aJ65GkAvS3qOA3ul2g/HnNJ8nxApBO4KUBohM njRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=H+ayEHKc; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=YgxV1M8o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id l69-20020a638848000000b00565f37c5472si572754pgd.781.2023.09.13.20.44.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 20:44:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=H+ayEHKc; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=YgxV1M8o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4C46B821579F; Wed, 13 Sep 2023 13:13:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232679AbjIMUNe (ORCPT + 34 others); Wed, 13 Sep 2023 16:13:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232203AbjIMUNa (ORCPT ); Wed, 13 Sep 2023 16:13:30 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 364A71BEF; Wed, 13 Sep 2023 13:13:23 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Sep 2023 13:13:49 -0700 (PDT) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776983013418768971 X-GMAIL-MSGID: 1776983013418768971 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: 139098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp91894vqb; Wed, 13 Sep 2023 14:17:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEa/tQmkmu10vpXkx0QvwkZarTPw5aeavWnR3XdZ5sHAWeYf+BzHzpfrm4HKYWpSmDBbRhU X-Received: by 2002:a17:902:9a0a:b0:1c3:c99b:7e3f with SMTP id v10-20020a1709029a0a00b001c3c99b7e3fmr3683998plp.38.1694639870109; Wed, 13 Sep 2023 14:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694639870; cv=none; d=google.com; s=arc-20160816; b=SAOuly35TNJgaagtN7+DgajE/Rww08JuqJmPCsebm4lfSkQCy9eCYbkNvRsaX4HESY llDWgcPa2UkOG3kmPvrxboE4Z7BIn0U+vL/5/TJX7xWtCNBmH/+vObwvMdMCdWjACKPC 0HQHV9Gyy1CYjvzLiwgVBb/Uq7yaSflyaDtC4FnTnvjBIpQwwudEZHmpc5nNn7o77Skw J/Ew9lRpNlOS0ao+6PHIe1zDKWGyX8Z6U3eZJ2xEhF8F0gVTpFVVmZ0D/OW92QA8axSh 042GIDABWBAiBWVy2MRyPcFEeIuoALm/W5glv8EM1ln7Y4FWgdyUoG/W/xuErmyEv5El SXzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=X7/kZB7lpmBCw2k1unMB2GujXf55nXH6oT8ByqeAnAs=; fh=GxieLooCEvcBpEBw8LOqYAxw58VqH9EOnAcolEICVqM=; b=tigQ9av8xnklG6xGAJSR6FKZ/WfcO0WbhH1R+myL4LCMTwA40kzl74DmhNAmVh6QIT qobxfqw90y+eEupg7rRl2Q9TPqw1zCvkbOwaJMjcMqKh0YZaT+6nPdRzZpBhtatO6lPD P0maOAISsAW4VAbuUeYpD1x0OTygk5E9WEkLAb4QhYfCTlhTDMR83gt2UPaZusclzNJc vc/UBm0eMwhxH+7VNwZ4exTzU1WLzJFdd5XFqoa09ThxQatS3bhNW9QARHUAGMc+vkbF agSF7ewrWbi1kPssjKwwvzR5GOvVwzzPi/OHTqmCCudf6smR7gQoXfI4LLYRsnfY3f7K iGhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=CBOmFlmf; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=R04EHa4q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id u15-20020a170902714f00b001bba7713547si133929plm.151.2023.09.13.14.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 14:17:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm2 header.b=CBOmFlmf; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=R04EHa4q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 731B481F852F; Wed, 13 Sep 2023 13:13:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232514AbjIMUNl (ORCPT + 34 others); Wed, 13 Sep 2023 16:13:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232173AbjIMUNc (ORCPT ); Wed, 13 Sep 2023 16:13:32 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5A051BCA; Wed, 13 Sep 2023 13:13:25 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 13:13:54 -0700 (PDT) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776958696455578264 X-GMAIL-MSGID: 1776958696455578264 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); }