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: 13383748 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 66808EE020D for ; Wed, 13 Sep 2023 20:13:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BF1E6B028E; Wed, 13 Sep 2023 16:13:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 749686B028F; Wed, 13 Sep 2023 16:13:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E80C6B0290; Wed, 13 Sep 2023 16:13:26 -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 4FC336B028E for ; Wed, 13 Sep 2023 16:13:26 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2B4A6160482 for ; Wed, 13 Sep 2023 20:13:26 +0000 (UTC) X-FDA: 81232674012.09.2C02912 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf11.hostedemail.com (Postfix) with ESMTP id 09C3A40006 for ; Wed, 13 Sep 2023 20:13:23 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=H+ayEHKc; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=YgxV1M8o; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf11.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=1694636004; 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=l4bevEHulLiJ5YHyw6Y9teMcyGqHbAaeFHUaV/6ZIds=; b=nEH17jOA1HQhbxKssg0pnuwl0B8kE00AdChHeuxOqSl9xYiJbPlPtcBaVxfXjIzmf1oYHx a3ppHcHBHS1RQMUhHA/WvlM80KG/1p5rKRMNrSC40IBAgxqOMNMoFOTucH5zMvqxaepCZJ IKJTMq71aXcjSIAkqOkPY7T8LcPFhi8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=H+ayEHKc; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=YgxV1M8o; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf11.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=1694636004; a=rsa-sha256; cv=none; b=ZAdZt2+Gqm+9DtfyHVyfsAeJq27Rg7FeikfFA8gEKcXdmKLMaseMZdS3P6apw8gnpZgju4 mA+bX26IhDPKyB5mQ4D+1EPmyFT9GP2i5f1Dqt4zPcdlmZBeXuL2V2xMp68998POoZwrJ3 MqfbX7ORp0SpTM9EJq2epxe0bDVrNtc= 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 X-Rspam-User: X-Stat-Signature: ygqgn9mss3xs5n4o5egw7dotwxtxynfm X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 09C3A40006 X-HE-Tag: 1694636003-829831 X-HE-Meta: U2FsdGVkX1+3JUxZrw56x/2nTKJOXugYta4c2ts0tfiw0OFP9mawcj8TsXqK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t5nwEtKPLPVUSXRY672xvy/w2M8AYvZlHrhKq326Ds64X1M+Vi6zJnGpddRcmRYvjtsznm/rOsr30DN4Tf0DipWAy4kVL3bldCVgm/RHRWtrcOYUmFZoi6P3yaSuVLKffZpe6wa+cwugXjlzNLKBapoy9qDnxsz18Hlsk2xsv+xA6OFuPpoQGD2bSNVGGPFUAL8X8L6pFCfT1GLuSNhf2RWAIVBROIPtocVEkiXb5RjoU93kkOvAlVRdWVk3Jyi26LFXiRvq+AoXbs5V22h05pqucdg79YlS5184CYz7Am7210TKCyDFrJqME6+MJMitR6L50QZmY0pa03Gf5xzoBzrqvNFizwaWi4oVF+hRF8mqYALnrb6ZNssXSBBQ0WGWaDoeqrFUXD8ccuoxNhy0iDDU6W4uol+JNffLye6OnOq5mw6k5CW1 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 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; } }