From mboxrd@z Thu Jan 1 00:00:00 1970 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 88490ECAAD5 for ; Fri, 2 Sep 2022 19:47:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A719580103; Fri, 2 Sep 2022 15:47:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E14758010A; Fri, 2 Sep 2022 15:47:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A64480100; Fri, 2 Sep 2022 15:47:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0AEAF800F5 for ; Fri, 2 Sep 2022 15:47:03 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DCA7F1C5D79 for ; Fri, 2 Sep 2022 19:47:02 +0000 (UTC) X-FDA: 79868178684.22.B70AF72 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP id 750F74004E for ; Fri, 2 Sep 2022 19:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=zuR82lnHCE/hSq+W53qYh+bEg1qeXP700ShKnxXJjXg=; b=YOqmub1o5LRM4Od0ty368EWqPB VxPWumz5nQfh5nVqtJ7E4NdbQ1Uao1vEiOPi9qRtDAhMBGpFIyQupAChNHfUx7NBDzugxQ1Xxjvv5 0qHEh6V5uUUuOKMgLu6uWbDZxBsGICtDy+7MFNAKbY4JPBMjf2tp87X44cSWkig2QfRR7XC8AyEnZ pkhs51IBKDV9gQoOZbpTEv4ncp0RabEnsL9K2cMkrdGndiY9r9qZoE/5gW1zf78/c1vUibijc2QJz tMWWCbw7ABAFoKHTgvnxIKnZw26D/+rHcy27yWff39HtkjOXDTFaAV0X53UrYun9y8nxTPwRy9t1m p7XQrcgA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oUCd2-007Ide-Jm; Fri, 02 Sep 2022 19:47:00 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 27/57] shmem: Convert shmem_file_read_iter() to use shmem_get_folio() Date: Fri, 2 Sep 2022 20:46:23 +0100 Message-Id: <20220902194653.1739778-28-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220902194653.1739778-1-willy@infradead.org> References: <20220902194653.1739778-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662148022; a=rsa-sha256; cv=none; b=PKTnXmb6WPopbif9Z3f/A/g9xDVvCf3Ukh1G7/p6HUe0Q/uPEH67uoL8it4KC6J66RQ/wk q9DWtUQFPpj0V9s8Y0+iXBUztA+4lCogAXbcYq3pBdteTcX/+uhJyCVIevqFajcj7HKt7W CecAy9d9ZFHQKr3T4efNvbk5EJKOR6M= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YOqmub1o; dmarc=none; spf=none (imf04.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662148022; h=from:from:sender: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=zuR82lnHCE/hSq+W53qYh+bEg1qeXP700ShKnxXJjXg=; b=PKrTb4SVK/rkqQcCzPSoNAOArM421Je/Hmv/ow1ksd4Z6XzueJIZ98kov2xioFHHqMOa/T Fc8ii3SUAgw9ExaQygwm9m2p7EJPokpQRE+psWj2GeiJIA+zLJY0pZo9lDXGBKuU0oVZEg fU3ZT+JLuKrP7taPgbr8h5j1GeE9y04= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 750F74004E Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YOqmub1o; dmarc=none; spf=none (imf04.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-Stat-Signature: dpgqqyr7r9i77pe99dyzd9xddyd73scz X-HE-Tag: 1662148022-143122 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: Use a folio throughout, saving five calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/shmem.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 44bb6ea11710..214887812adb 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2576,6 +2576,7 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) offset = *ppos & ~PAGE_MASK; for (;;) { + struct folio *folio = NULL; struct page *page = NULL; pgoff_t end_index; unsigned long nr, ret; @@ -2590,17 +2591,18 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) break; } - error = shmem_getpage(inode, index, &page, SGP_READ); + error = shmem_get_folio(inode, index, &folio, SGP_READ); if (error) { if (error == -EINVAL) error = 0; break; } - if (page) { - unlock_page(page); + if (folio) { + folio_unlock(folio); + page = folio_file_page(folio, index); if (PageHWPoison(page)) { - put_page(page); + folio_put(folio); error = -EIO; break; } @@ -2616,14 +2618,14 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) if (index == end_index) { nr = i_size & ~PAGE_MASK; if (nr <= offset) { - if (page) - put_page(page); + if (folio) + folio_put(folio); break; } } nr -= offset; - if (page) { + if (folio) { /* * If users can be writing to this page using arbitrary * virtual addresses, take care about potential aliasing @@ -2635,13 +2637,13 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) * Mark the page accessed if we read the beginning. */ if (!offset) - mark_page_accessed(page); + folio_mark_accessed(folio); /* * Ok, we have the page, and it's up-to-date, so * now we can copy it to user space... */ ret = copy_page_to_iter(page, offset, nr, to); - put_page(page); + folio_put(folio); } else if (user_backed_iter(to)) { /* -- 2.35.1