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