From patchwork Fri Sep 2 19:46:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12964568 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 5541BC6FA83 for ; Fri, 2 Sep 2022 19:47:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E1EA80110; Fri, 2 Sep 2022 15:47:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 97289800FF; Fri, 2 Sep 2022 15:47:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E38B4800FF; Fri, 2 Sep 2022 15:47:05 -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 2F0EB80109 for ; Fri, 2 Sep 2022 15:47:04 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 11F4A140EE2 for ; Fri, 2 Sep 2022 19:47:04 +0000 (UTC) X-FDA: 79868178768.24.8CF2406 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id AE98D140064 for ; Fri, 2 Sep 2022 19:47:03 +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=L+G3lzPsb0oPAWAGOjNGo3IbzotK51wOth4YKCXiMyw=; b=j9rAl9Og+x3QoCKAlYTpCJS/Nc QavwzAwfbF5Wl/8JOzq9DoVHxA72cen4cu02q4vUM6toq1pON6Y63IAYgZu+tP1CPpe8O/le9mJQi e4MjQ4nMBrOfEqo5tdbN9dxPxNnvyNIoEAxFApdnjdWa3sr21SK6fj82JoDniUlkcIRTUGxPDe2OC zMUAs9FG3GIEN+G+i6ciPI53lQ4D05XAFHayM5n3/UUrYTJcQ81jNzRYLuDjLjnzmPDeVyWyeNWzD dMW/jrClqDhbLpVTjpmj9JrVOirM5oJ8NuvpLEvaR5RlLRn+509lSgQqH19BWNo48bhJIpEG8yJLk Va7rpyYA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oUCd1-007Icq-ON; Fri, 02 Sep 2022 19:46:59 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 20/57] shmem: Eliminate struct page from shmem_swapin_folio() Date: Fri, 2 Sep 2022 20:46:16 +0100 Message-Id: <20220902194653.1739778-21-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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662148023; a=rsa-sha256; cv=none; b=OsrK/L1JfHkleeKs5EwiLxNM/JUa4x43or+yk9/+qFb8JEMIPAK5VSulvv4tHUnbMMzmfM /sKfufJ4JG3ZXll+prGUJDdUh7ZFQ5HNnsmu/+IWe9Q5WzOPLQaJgei5v2/xiAygXKHGJH r4R2uU8GuZcPQRG1D6Piz15OJ990LKw= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=j9rAl9Og; dmarc=none; spf=none (imf23.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=1662148023; 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=L+G3lzPsb0oPAWAGOjNGo3IbzotK51wOth4YKCXiMyw=; b=HURh5KAGfeA0PxTq6kEK/FwbIOYrrzJIgmfzDBDSR2O4Po2nQ9TcP0Qny9BPFS2LKii6KW RyvaBpKoZZ8uLPj44cDRe5L0HRkod+MLGb1rDzWejtI5qmyGkmsfIpIL8XS9UX4gg7IU2z Lh0CMZfZQpPuVABaBHXwQOI9sGEgHTE= X-Stat-Signature: 7tuunac11sk97th3ig9hhnyhgdmmggrs X-Rspamd-Queue-Id: AE98D140064 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=j9rAl9Og; dmarc=none; spf=none (imf23.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-Rspamd-Server: rspam02 X-HE-Tag: 1662148023-647427 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: Convert shmem_swapin() to return a folio and use swap_cache_get_folio(), removing all uses of struct page in this function. Signed-off-by: Matthew Wilcox (Oracle) --- mm/shmem.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 2bb6f5cfdc11..b685acd9f149 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1486,7 +1486,7 @@ static void shmem_pseudo_vma_destroy(struct vm_area_struct *vma) mpol_cond_put(vma->vm_policy); } -static struct page *shmem_swapin(swp_entry_t swap, gfp_t gfp, +static struct folio *shmem_swapin(swp_entry_t swap, gfp_t gfp, struct shmem_inode_info *info, pgoff_t index) { struct vm_area_struct pvma; @@ -1499,7 +1499,9 @@ static struct page *shmem_swapin(swp_entry_t swap, gfp_t gfp, page = swap_cluster_readahead(swap, gfp, &vmf); shmem_pseudo_vma_destroy(&pvma); - return page; + if (!page) + return NULL; + return page_folio(page); } /* @@ -1721,7 +1723,6 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, struct address_space *mapping = inode->i_mapping; struct shmem_inode_info *info = SHMEM_I(inode); struct mm_struct *charge_mm = vma ? vma->vm_mm : NULL; - struct page *page; struct folio *folio = NULL; swp_entry_t swap; int error; @@ -1734,8 +1735,8 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, return -EIO; /* Look it up and read it in.. */ - page = lookup_swap_cache(swap, NULL, 0); - if (!page) { + folio = swap_cache_get_folio(swap, NULL, 0); + if (!folio) { /* Or update major stats only when swapin succeeds?? */ if (fault_type) { *fault_type |= VM_FAULT_MAJOR; @@ -1743,13 +1744,12 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, count_memcg_event_mm(charge_mm, PGMAJFAULT); } /* Here we actually start the io */ - page = shmem_swapin(swap, gfp, info, index); - if (!page) { + folio = shmem_swapin(swap, gfp, info, index); + if (!folio) { error = -ENOMEM; goto failed; } } - folio = page_folio(page); /* We have to do this with folio locked to prevent races */ folio_lock(folio);