From patchwork Wed Aug 30 18:27:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13370664 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13B31C83F01 for ; Wed, 30 Aug 2023 18:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343898AbjH3S4D (ORCPT ); Wed, 30 Aug 2023 14:56:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344206AbjH3S2W (ORCPT ); Wed, 30 Aug 2023 14:28:22 -0400 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A600A3; Wed, 30 Aug 2023 11:28:19 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id F3E6B3200941; Wed, 30 Aug 2023 14:28:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 30 Aug 2023 14:28:19 -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= 1693420097; x=1693506497; bh=TK10HtZMWkaeyr29jSGk50ed2+QFV4733lj LHyyzZmA=; b=wVMie9QfMJAfZCtvv/CLDGpDzW3bh1Gk2NBoHI0hoWVREkq3dgY +48nO3GAyn8XC8bHDHwCMgtHeYijkz4DyOvLKjhu5deoObYlNMb0goJJjbZPsuSH Cv7QNhvzmMVF2GY3Ww2fGD756MsZeGZyt4qWPrS3k4peKFRXBklabFvKqkEzEkfo 65LebOhjDZ0OjDqI+IEjtYVPRVxlNBWX3PvW79tpEsPO7LmlzMplzFuvc4lEXItR JybkxgkU+tSm8bLdjGkGvLQwvl4WA39HGvA25kn8MF5WXW3C6gnj5OwbFHEXvrYa +OghkryonUAqHfmrb85aB3C6QdtiBxWzK/g== 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= 1693420097; x=1693506497; bh=TK10HtZMWkaeyr29jSGk50ed2+QFV4733lj LHyyzZmA=; b=ziKY7X6dy6aRNNRouY0tNqlLuvndGRS+knN/IbPMk7xsieoO0V9 t6GT+lSpAx7hVmg7VucGt/Mf8iWiYr7Zdmf2FyWYpnsdARUqCpaBz9kkgIODylZb wqGxcXVnoqmfusEjtA52SiWcxEbwNmo+oDq/xRfEW8fabKcf/ZkcbddJZmvfI3w+ G92FFGG49+NslDWY2fNtHQUWvbdA1euJRCL1IEBizJ9G10crBI0P0l3yPJiXa+xs BIJuSuh/hZoDcqS4cPssInZIixidGnVxs3HLgfvtXqpTRFDyMwAbORQCMs63yYDb tztU+jJdL6QM8YZSiM2ZSY1hiJ5RAPf2NWw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudefkedguddvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enogfuohhrthgvugftvggtihhpvdculdegtddmnecujfgurhephffvvefufffkofgjfhhr ggfgsedtqhertdertddtnecuhfhrohhmpegkihcujggrnhcuoeiiihdrhigrnhesshgvnh htrdgtohhmqeenucggtffrrghtthgvrhhnpeeggeehudfgudduvdelheehteegledtteei veeuhfffveekhfevueefieeijeegvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Aug 2023 14:28:16 -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)" Subject: [PATCH 2/3] fs: use nth_page() in place of direct struct page manipulation. Date: Wed, 30 Aug 2023 14:27:52 -0400 Message-Id: <20230830182753.55367-3-zi.yan@sent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230830182753.55367-1-zi.yan@sent.com> References: <20230830182753.55367-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org 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. 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; } }