From patchwork Wed Sep 6 15:03:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13375717 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 61689EE14A5 for ; Wed, 6 Sep 2023 15:03:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86A2F44016C; Wed, 6 Sep 2023 11:03:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F2C0440151; Wed, 6 Sep 2023 11:03:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61E1E44016C; Wed, 6 Sep 2023 11:03:38 -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 49BAA440151 for ; Wed, 6 Sep 2023 11:03:38 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 11E32A0C8F for ; Wed, 6 Sep 2023 15:03:38 +0000 (UTC) X-FDA: 81206491716.02.F31FC17 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf02.hostedemail.com (Postfix) with ESMTP id A775E80044 for ; Wed, 6 Sep 2023 15:03:35 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=pCUlhr0P; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=qhSDgtan; spf=pass (imf02.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.19 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694012615; 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=cqtMZEUvBe54JghNmYIOYKwpXMmZI+q66Bi2kSF9BAQ=; b=iJmzP8u/mTCVN9dDBXwkzF6VsEJYO00z+rcZwhYEE5xDX2v6bwI1mdSJ4oxrStHrOGcnYB 2cjMYludHmA8lwiqJv62LoQvRNSO/CS6wj35bs0GaRB5DtcU0mMnqEiCk2DzItsosjeiwH k1zBLPrY9ndyFYN5XUDVkaWacopjkKs= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=pCUlhr0P; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=qhSDgtan; spf=pass (imf02.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.19 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694012615; a=rsa-sha256; cv=none; b=4BV9cgpBzLhQW8px8SnbKxguSBhh922vzxZ+xaeRMVunLY+xuhnwkLmHrv11JzENzI0WqS kkojLRdtN2v9Zm6hq7B9QGt8B0iTuhQ+0WKenb6ke4Vks1hAcRr1ZVM4Z9mDD7ZO65LM91 rMXAjluJ7rOIbFHtqfRA8QLggJjDO1g= Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 45E1632009C5; Wed, 6 Sep 2023 11:03:33 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 06 Sep 2023 11:03:34 -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= 1694012612; x=1694099012; bh=cqtMZEUvBe54JghNmYIOYKwpXMmZI+q66Bi 2kSF9BAQ=; b=pCUlhr0PqKkKxrLg6/MAEej8PHN+UaXMGYaUKHfsyEqZii72vIv gF0fdzEG7vtIqYpsYif27qqiciuJZzSDA7T2n7kmrF6jYoO4IbIeU7tWfi44QyhO oA/2yQBIU24n81ylhfY2Uwg+ko+lEw4sQWOCQjHJ9bQUtylPhYkxswK9Bom7G2Mr steSMIHZpymEEv6tObZHSSMoWMvHdbCz41mA0Jup92qZz7oNa9OwMRQb1pGmrd+e Pq+xtKcSl10jploMADZBMHSKRZUhEfTTqWDrOX0BmF1lf8LFc96vYrrnLrmYX5t8 E4WBACH3Il/bRFeSCRzmP6v2BwcvEP3khfA== 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= 1694012612; x=1694099012; bh=cqtMZEUvBe54JghNmYIOYKwpXMmZI+q66Bi 2kSF9BAQ=; b=qhSDgtanx+0+pDt3JTxcMZmdRwzhQPSAjuqOLwGGTNZLjO57/tf WGxNmarVSk8cnsbHZlErQ7AvWs2JK+xMUdbld8zXeqCu65S8QwCeJJqVqP/IhCUq 0WNVFsMVBLnF6psCkT7qZofRZcAkaE5qJv26bJEze+db608cOoTam68AgTDzY6Ja MG8x2WjkNaBlVIlLdGckGofLL7kZE6aycGsmA4peiiHgBE+rRCWAz8iVyHrGCTsP gq77YUMS8WGl7Lk6Cc1YrtApBiTV5XK51y9CbUQil26cyUNceJyZbXLByzlLabGa RgOL68x+vSiMAhQHz/oTn6PUSsVILwOLfIQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhorhhtvggutfgvtghiphdvucdlgedtmdenucfjughrpefhvfevufffkffojghfrhgg gfestdhqredtredttdenucfhrhhomhepkghiucgjrghnuceoiihirdihrghnsehsvghnth drtghomheqnecuggftrfgrthhtvghrnhepgeeghedugfduuddvleehheetgeeltdetieev uefhffevkefhveeufeeiieejgedvnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrg hmpehmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 11:03:31 -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 v2 4/5] fs: use nth_page() in place of direct struct page manipulation. Date: Wed, 6 Sep 2023 11:03:08 -0400 Message-Id: <20230906150309.114360-5-zi.yan@sent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230906150309.114360-1-zi.yan@sent.com> References: <20230906150309.114360-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Queue-Id: A775E80044 X-Rspam-User: X-Stat-Signature: f6jk5s44ok66xjtc56ddid8fzadiy8ub X-Rspamd-Server: rspam01 X-HE-Tag: 1694012615-318668 X-HE-Meta: U2FsdGVkX1+8bILcvtLCX8Ao0YhmdBpVKhWZQHJb/6rSvXOpSzZzl1o5bAoWMEXI3xKXxsVJLTIPp3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H7ZQZpYA1s/+zNjcYdbi39YisobR8TgYL2/xWsgMz9qzQuT90+b2xdIVktlZZuihX6ZlSjjf/LxicyeZwS6niR1qJ/4wrdSvD2HRL+mbY03L0+mM0KBeC9g1yQ7G1VaOBrwPiJ1UoWGNFKe6rehf1Q8zn02qaYtEwvxe2NVsngp9MJZd2EST7GWASamfG2hqxbnUeIohas8lyxALWUsvZM4B1HrR3bNoj1VVPnWhYnPyopQPnVd3/FWUIRd8DEgnIjytTW3VXaydOMj+f89ABWIoXo4IwuTLiyAakXC/n3O+Wg5KDDrbJYUAUMk/KhqIfGF92m7+ucdMaCYCCDcQD41zgB/rPSVgf7HO7/1gTft5XjtElQU6lLvsLveMhZoLU07YVlBVjLTcpKQ8wjT/y//7TySMu8RiEDt7xFL+hkYh88Mh4RjOc 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 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; } }