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 C36A6C00140 for ; Mon, 8 Aug 2022 19:35:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA058940019; Mon, 8 Aug 2022 15:35:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D972940017; Mon, 8 Aug 2022 15:35:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8522F940018; Mon, 8 Aug 2022 15:35:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6CD10940017 for ; Mon, 8 Aug 2022 15:35:28 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 55DF7C0121 for ; Mon, 8 Aug 2022 19:35:28 +0000 (UTC) X-FDA: 79777429536.03.58B3A95 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id EC7A118016B for ; Mon, 8 Aug 2022 19:35:27 +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=bIVlghjHX5ZoI79ilxenPX7R4/CW8hGR+dhD1yFJKb4=; b=OsOiOsF8EmL+6IGFE8rriYSeQU OJd1fu4CKbwWHXf2AfReObqnRd8s9certrnAkpX1j0IFSWWefMX336Es7/hV9nNs3ROd7QfSZ753h OMnAdP6aPhzJmq8I6haBRbisQ0CLU/iLW8/XnsrTAl2ezSrYZghwKuHlqyHxHmAlxIOmwyh2fTtYX IqJZ7A4bRIwJza0umd2WsBme6QmWY3UZIPAcX9UYEb+lcl1xL+aNljTsO7dxy63CG3BF7pJfO6SfS y7f5TXstzyQbWA9GXYrkL+LykkGcHnahOZ6vq+/IFnLfeAdPE3VoLnKLzwGWl0vHhap0O01XomP7H 4ho0jK/w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oL8X6-00EAxt-P2; Mon, 08 Aug 2022 19:35:24 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , hughd@google.com Subject: [PATCH 30/59] shmem: Convert shmem_file_read_iter() to use shmem_get_folio() Date: Mon, 8 Aug 2022 20:33:58 +0100 Message-Id: <20220808193430.3378317-31-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220808193430.3378317-1-willy@infradead.org> References: <20220808193430.3378317-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659987328; a=rsa-sha256; cv=none; b=ruPYL0HHnxY5GKEKQGPTKnCqesbvKAldtRxFCo4pAwi6AeXszADWZCSPhd+bxpTpauYCtP ONYLTgtF0ieXFQmw/Fh1SAMH5QWUj2mfwQY/6vN8EdqfVBlwmri02K9JjP8w2oeVVgA2T7 mYb7R1Li7QzHhwwXVtbPOEtbntjvzM4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OsOiOsF8; spf=none (imf16.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659987328; 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=bIVlghjHX5ZoI79ilxenPX7R4/CW8hGR+dhD1yFJKb4=; b=WafseohRYBocpiqexv4pVEyPG5kJuwjGcstEhQpaiYAvPzVYdQMJo6Azh9uhNPw4FQpe+C gYQlAceuc9rkpOTNpo1F6JYdP75L1K3qF5ojHJVsR9Qk1uTlF+BvRTsu1jzXtvCkC1wTtn InhKRthGyBYoMmIpS9hcXhQqZHj8To4= X-Rspamd-Queue-Id: EC7A118016B Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OsOiOsF8; spf=none (imf16.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: tsrg6qrsjkggkgj5fzi1athhbkpsbg8c X-HE-Tag: 1659987327-311854 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 45212001effd..51a1934f8353 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2561,6 +2561,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; @@ -2575,17 +2576,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; } @@ -2601,14 +2603,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 @@ -2620,13 +2622,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 (iter_is_iovec(to)) { /* -- 2.35.1