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 CBB8CC433EF for ; Mon, 14 Feb 2022 20:00:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 85D226B0080; Mon, 14 Feb 2022 15:00:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 553FA6B0085; Mon, 14 Feb 2022 15:00:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C2606B0085; Mon, 14 Feb 2022 15:00:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0124.hostedemail.com [216.40.44.124]) by kanga.kvack.org (Postfix) with ESMTP id 0231D6B0089 for ; Mon, 14 Feb 2022 15:00:24 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B96BF82DD384 for ; Mon, 14 Feb 2022 20:00:23 +0000 (UTC) X-FDA: 79142452326.23.70B14BB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id 4E2D2160012 for ; Mon, 14 Feb 2022 20:00:23 +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=qzMc3QSSV5ESROmRFN8IQpYHZFKRe03/W9Iz1/bJKQk=; b=wJ53S14AFxGTS9ic8170NO+Tlc IprUAZEXrgDhn+6tpVW9dApTcofV/EHrAtXneJXUERvkhsbjt2VlxbAlaPqFQyzz6tzPTmN0KCwMM eq5UPb+Jr7olj8O8PANKDZ2dZD5HfA/x3aMHjKvOV9qWGKoRkOQdAoBOuJLcA0fqD+U63zQlxVdkI Rn2HAfjyjlx7yPItPGTBe9kQoxMJBeZ3Fnk2eY5Yt3T7pmdtCw/+vSSiDVIWTm6sXMdyV/1O+HCRW qaMFK/8iznLIZ6QzlJ66dui/KG4nDN+lrRWK15YtQpVCGC+mrQcrGheQdAuE39qx4YLysFWZmTJeN cqkRe14w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJhWG-00DDdm-4L; Mon, 14 Feb 2022 20:00:20 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 05/10] mm: Convert remove_mapping() to take a folio Date: Mon, 14 Feb 2022 20:00:12 +0000 Message-Id: <20220214200017.3150590-6-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220214200017.3150590-1-willy@infradead.org> References: <20220214200017.3150590-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4E2D2160012 X-Stat-Signature: fh86yywcqm13hdpghzo4qe9k7es35kf4 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=wJ53S14A; spf=none (imf08.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-HE-Tag: 1644868823-869877 Content-Transfer-Encoding: quoted-printable 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: Add kernel-doc and return the number of pages removed in order to get the statistics right in __invalidate_mapping_pages(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/splice.c | 5 ++--- include/linux/swap.h | 2 +- mm/truncate.c | 2 +- mm/vmscan.c | 23 ++++++++++++++--------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 23ff9c303abc..047b79db8eb5 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -46,8 +46,7 @@ static bool page_cache_pipe_buf_try_steal(struct pipe_inode_info *pipe, struct pipe_buffer *buf) { - struct page *page =3D buf->page; - struct folio *folio =3D page_folio(page); + struct folio *folio =3D page_folio(buf->page); struct address_space *mapping; =20 folio_lock(folio); @@ -74,7 +73,7 @@ static bool page_cache_pipe_buf_try_steal(struct pipe_i= node_info *pipe, * If we succeeded in removing the mapping, set LRU flag * and return good. */ - if (remove_mapping(mapping, page)) { + if (remove_mapping(mapping, folio)) { buf->flags |=3D PIPE_BUF_FLAG_LRU; return true; } diff --git a/include/linux/swap.h b/include/linux/swap.h index e7cb7a1e6ceb..304f174b4d31 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -395,7 +395,7 @@ extern unsigned long mem_cgroup_shrink_node(struct me= m_cgroup *mem, unsigned long *nr_scanned); extern unsigned long shrink_all_memory(unsigned long nr_pages); extern int vm_swappiness; -extern int remove_mapping(struct address_space *mapping, struct page *pa= ge); +long remove_mapping(struct address_space *mapping, struct folio *folio); =20 extern unsigned long reclaim_pages(struct list_head *page_list); #ifdef CONFIG_NUMA diff --git a/mm/truncate.c b/mm/truncate.c index d67fa8871b75..8aa86e294775 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -292,7 +292,7 @@ int invalidate_inode_page(struct page *page) if (folio_has_private(folio) && !filemap_release_folio(folio, 0)) return 0; =20 - return remove_mapping(mapping, page); + return remove_mapping(mapping, folio); } =20 /** diff --git a/mm/vmscan.c b/mm/vmscan.c index 2965be8df713..7959df4d611b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1335,23 +1335,28 @@ static int __remove_mapping(struct address_space = *mapping, struct folio *folio, return 0; } =20 -/* - * Attempt to detach a locked page from its ->mapping. If it is dirty o= r if - * someone else has a ref on the page, abort and return 0. If it was - * successfully detached, return 1. Assumes the caller has a single ref= on - * this page. +/** + * remove_mapping() - Attempt to remove a folio from its mapping. + * @mapping: The address space. + * @folio: The folio to remove. + * + * If the folio is dirty, under writeback or if someone else has a ref + * on it, removal will fail. + * Return: The number of pages removed from the mapping. 0 if the folio + * could not be removed. + * Context: The caller should have a single refcount on the folio and + * hold its lock. */ -int remove_mapping(struct address_space *mapping, struct page *page) +long remove_mapping(struct address_space *mapping, struct folio *folio) { - struct folio *folio =3D page_folio(page); if (__remove_mapping(mapping, folio, false, NULL)) { /* - * Unfreezing the refcount with 1 rather than 2 effectively + * Unfreezing the refcount with 1 effectively * drops the pagecache ref for us without requiring another * atomic operation. */ folio_ref_unfreeze(folio, 1); - return 1; + return folio_nr_pages(folio); } return 0; } --=20 2.34.1