Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3700237rdb; Wed, 13 Sep 2023 22:59:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFEEH2UPEH7GQsyRQhxr7pvb5FFpDc0qlNzHtuM5WFDp2HK91QOCLuAC/Wx514ly8OcXuvI X-Received: by 2002:a05:6a00:23c7:b0:68e:25ff:613e with SMTP id g7-20020a056a0023c700b0068e25ff613emr4936783pfc.3.1694671190439; Wed, 13 Sep 2023 22:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694671190; cv=none; d=google.com; s=arc-20160816; b=agpz/NURwsIHLTxC1o3owPiORW67eFzMtTkzC/blVLYbhGen/t5/bOPjmvEsjAkxEc TfCyOKp6dg7Yr5t6i8F5LK/rmXZVCcZ/CI6OoFvRuHWRohpuBRS+klPifOzDPToFhgPZ mW4TyQixo2iPjnempDX5EcB6PKz/wQqOW46uvOqIQYC+cpCT5pjsM0lIA68pQDeRtTor 6OeZc+AwXahvipVLD/XWHBFSD+ybccHD+jItPsMDi3xyjXd2SQThZ3fI7GBkR/ankSL1 /g3fJcqbi2jETTuE0nVWGer02Miim7awlQIkC8WkKgxezmu4wDEVaUhiwvFEfSPXnyXv FZQg== 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 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id u190-20020a6385c7000000b0053fb354c194si856511pgd.659.2023.09.13.22.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 22:59:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; 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 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 8FD39822C619; Wed, 13 Sep 2023 13:13:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232171AbjIMUNY (ORCPT + 99 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 Content-Transfer-Encoding: quoted-printable 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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 13:13:35 -0700 (PDT) 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_mas= k") 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, } } =20 - page +=3D ((address & ~huge_page_mask(h)) >> PAGE_SHIFT); + page =3D nth_page(page, ((address & ~huge_page_mask(h)) >> PAGE_SHIFT)); =20 /* * Note that page may be a sub-page, and with vmemmap --=20 2.40.1