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 D087EEB64DA for ; Mon, 10 Jul 2023 23:17:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A7908E0001; Mon, 10 Jul 2023 19:17:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 656E38D0001; Mon, 10 Jul 2023 19:17:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5463F8E0001; Mon, 10 Jul 2023 19:17:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 450F38D0001 for ; Mon, 10 Jul 2023 19:17:32 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F3D481C7B65 for ; Mon, 10 Jul 2023 23:17:31 +0000 (UTC) X-FDA: 80997265902.26.18F22C3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id 8BE86180012 for ; Mon, 10 Jul 2023 23:17:29 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=qrES5FI2; dmarc=none; spf=pass (imf16.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689031050; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LCO8eQUtR+QZzKo7JW+/z7W+OqgHy3GJDwiFHD5OP/k=; b=qoMWvWl/5GFQueb+LH37ZJbWtWL1M4G2ALSMtfXVCeM2C6W/kBLtwyTj4CCUoOmtwXfAMS OpkP/2dZk5sch9wnwy9dekJMKg6pV4FpOK9L6+XarwkafKhuiM4Rxyv3dCcKCTFuA7H9Zx 0GWtoikwDwUnhPjyGJiAGiF2eKkb3qc= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=qrES5FI2; dmarc=none; spf=pass (imf16.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689031050; a=rsa-sha256; cv=none; b=WVTgMNsqsJurfPyMEY3E1TM1+UYeFofQvl1Y52UdOZRXxz3VH8BaFpLDSsZmmKo+fqCa4K OI8tJMcgFFRgBLshffjMMKfP5zTwIiqr5jX4LzSznl2JxlbcPHfXwfcG6Y8/yHcuF2L0Yc WvFVpGS74wrhMD6mYwZiws7A8o0HgtI= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8F2386120F; Mon, 10 Jul 2023 23:17:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7FA3C433C7; Mon, 10 Jul 2023 23:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1689031049; bh=7ukpBqH/JEmoGMFAy/Thf+Mx7ToPtH7Q/rOGM1Ckpq0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qrES5FI2lpsIScl39Znj/jOshaskk/NkA2AyV6WuOqpYH+1elY3CL6cnOwZPu4ZGY 6qv03tx+3gYQwG2RRh0zrVI85DPu5QW987ZV827dCV46fmR3nFpjzWKywhx/7jDZVX IzZICXcjA1V/Kkyd7eloRoHLZeMi8we/7rwcYkt4= Date: Mon, 10 Jul 2023 16:17:27 -0700 From: Andrew Morton To: "Matthew Wilcox (Oracle)" Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport , Anshuman Khandual Subject: Re: [PATCH v5 04/38] mm: Add folio_flush_mapping() Message-Id: <20230710161727.7a676996b64e9885cc15eaeb@linux-foundation.org> In-Reply-To: <20230710204339.3554919-5-willy@infradead.org> References: <20230710204339.3554919-1-willy@infradead.org> <20230710204339.3554919-5-willy@infradead.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 8BE86180012 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 7ofmji57ajmm6onm3aiah1s8qeffcp34 X-HE-Tag: 1689031049-758006 X-HE-Meta: U2FsdGVkX1+slBQzJKFpSEIQuDoUfD/loJ6zSSr4KK/EhqJkCY6bRpOxOcE0a9IGcpK33VYTLWXuq0OT/p8hsSElJb99xpcFvCMVdd6q2QSbH0MTI0KSb+o42Vs1Xq0kAdKHwcMpGYxPoSGjneMjeiLzb+rIy56A3CmSE21u0TsyLC8mkG3QhaOHe4QfVWsa3cWFn1CnE1jC8kRTcionZEtWOUCjsucFpfs9gMzSu8YePWbHtXTOSWl/k04f6spRg1VdSERzp337HFqHrI5JhVnCvPB7SKVCcWQzeAfoYNi6suJUSrPJVQjXn0gtWq9roWC1/JGo14c+8XnDoc5vq25/0G4tq/ao3tk/DsEKNQTakLVjB/i0oNf/djuTNH2FEFmF6RC5d6Ln0UPb8RlMMLYywLPSnLrtCJ3PeER5VqipDZzclWyOUJMBliZwEFFLXxztQWo72GXhpvcimyAq/l9aT2uU2eOj2xSWPhgd5euzacaeNrKAQ8CPXcpz5qgQeh1upzzc/N8xA8Grw4iXh9PXijdT4DH3uk1RvxFqfssTB6DYxhcTysS7jYxEcOksr7X6XPIU+Hc/qVHUAxqKecnugb6X8fvnM2gNn4e8vFwiHxnGBrSQWYq4mhUaX83BuvkCaVRXoTnjcwrUEU6Rhc92+MYgekmdBVzurmgm67/dy7VDxiFPXnsPkzUUjMmPZlVz7lYw/X9ZsnTO4cu70120nIR6fjYs98o0CKD/0nMeG1/jFXpRne48xYUSbXLdrmXvjKvnmdHro6/H9aS421S/oQzeazP3jZedDaid0g7gGagvMKs3y45JpHUqAoMQSH9tkJM9gzpuDIFhdDzA97l4inUf4F3jbPQv2VLwFYeqhJGHXbM5DShz8QWg8Mg3J+JhoOsq+uN6Dt1bkk8YmqkJJ2uYA8Aw5Mj2qXsJIZIiz+rikJgoDacBN0PU5iHkriY6y/xknSIw5DoQlVt hdrJ+hm1 dutOYOcgDJ7qeJeQHZ56AJomIGssLw6A38Xw3kCkQWPbyozkBgemN2ucET1AbFWfvf/a4gs3sT1g7ODaWF4TDrFFeg4wShamWUV8WJHMkdBkJW5vntToDyEAU2OocqdahdfT36hIb/3Lkf/3eB3Cu3QWV5OXUQit/5/yWg9uF+o1LKpUIgxROlHjLUZaadT6oZX9LVRAeNSfp1PZp1W3NC/qh2FkGuWwVMl0XYyBh0Ajl/+qKh6LXRrN0bMySPf39jb7pqiveYmW85/JpvJyGzPfJWYXW1ftcWFY+0hTAFuCmDn0Ko40jV5vkif1cy53N+Fki/XBZmKiNvVJbhoBUZXmeVCXoUA6Z7uP85PoiKA0ETTvP0Gd/bxrSTP3b3vq3mkzSNDyYbLmt26IR3xuOom7pTj7g7HueY5LV1nmwFr47aH/ZpQ8LajI2fw== 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: On Mon, 10 Jul 2023 21:43:05 +0100 "Matthew Wilcox (Oracle)" wrote: > This is the folio equivalent of page_mapping_file(), but rename it > to make it clear that it's very different from page_file_mapping(). > Theoretically, there's nothing flush-only about it, but there are no > other users today, and I doubt there will be; it's almost always more > useful to know the swapfile's mapping or the swapcache's mapping. > > Signed-off-by: Matthew Wilcox (Oracle) > +++ b/include/linux/pagemap.h > @@ -389,6 +389,26 @@ static inline struct address_space *folio_file_mapping(struct folio *folio) > return folio->mapping; > } > > +/** > + * folio_flush_mapping - Find the file mapping this folio belongs to. > + * @folio: The folio. > + * > + * For folios which are in the page cache, return the mapping that this > + * page belongs to. Anonymous folios return NULL, even if they're in > + * the swap cache. Other kinds of folio also return NULL. > + * > + * This is ONLY used by architecture cache flushing code. If you aren't > + * writing cache flushing code, you want either folio_mapping() or > + * folio_file_mapping(). > + */ > +static inline struct address_space *folio_flush_mapping(struct folio *folio) > +{ > + if (unlikely(folio_test_swapcache(folio))) > + return NULL; > + > + return folio_mapping(folio); > +} The name makes it sound like it flushes something. Wouldn't folio_flushable_mapping() be clearer? > static inline struct address_space *page_file_mapping(struct page *page) > { > return folio_file_mapping(page_folio(page)); > @@ -399,11 +419,7 @@ static inline struct address_space *page_file_mapping(struct page *page) > */ > static inline struct address_space *page_mapping_file(struct page *page) > { > - struct folio *folio = page_folio(page); > - > - if (unlikely(folio_test_swapcache(folio))) > - return NULL; > - return folio_mapping(folio); > + return folio_flush_mapping(page_folio(page)); > }