Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp747806rwj; Fri, 23 Dec 2022 07:36:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXsCkzoMfuwbm8SR7tbojzFQViLhmjnnsoYgSVKAKSp+UIL7PszifTGSHWHvuHhzTr/5p76h X-Received: by 2002:a05:6a20:3d85:b0:a3:587b:56ac with SMTP id s5-20020a056a203d8500b000a3587b56acmr16046938pzi.52.1671809766390; Fri, 23 Dec 2022 07:36:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671809766; cv=none; d=google.com; s=arc-20160816; b=ey61tbt4qtLi4C3t6slCkA0VzHzzwfkGK3aYL0BKK2vAsGi7R0/FZNlZDFgXDSFMfA lhi1e1qakIuiwtudXy5uEzElRVFdY8kwdzl3hrpPU34qyuN+Zy5ndMAY85SgZd1st7YQ Az2FOZsKp1mI7dnAGBcjEzXz1k7tdK8435rHIoffh3nrRDpSOXaj7O+0Cd1srfLUNxsz xRwdXr1iTpMmv6wpJRNUMRj3Q7a8KcZFTcbRab0DaVvL9FGp15SQcMp8M9BYr7VLA7iC 50642LmAGMIsGlsg8bEX4JYKlSdpJH9rp684rlGWR0LOftvuAKIekc4V0/6y3VzP3+K3 UuEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YI+GETaE07zfIF6gTr93yZkoaqmkXGRyTSkPLa22IzA=; b=GC3OhlyuKoPrJxg2+7kX3ZnRbsRh7S/AwMtzyI1LoUyjfuFYjBSdh2Jw/1hSadcz/0 97Ox6X+65d2/7rz8KxI2tY7TOdlasV4Gmjqt+nSfiSvDAfna+/Kfght4OCkhbTdrYsiN wEyASEX6VvGUOzV+tyJar2JlmXYdioBuW+qmYh0SkOeN2Sm933cR9qrOCzzF9u2sXtQx IN38tzNxOiB14RS1aPr17xBDxNzDrTQrtmcmCawg9rmHDAuPIPTn9ng6kqmKfiLkNmSN U3s9GuTp/gAR+XXpuVDHk27LFKahTWfDRlWTHPYiBcgBBBqvO47V50j9SeNkT/z7L6zp UCUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=RkLgtlP2; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t33-20020a056a0013a100b00562a956d979si3983233pfg.67.2022.12.23.07.35.46; Fri, 23 Dec 2022 07:36:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=RkLgtlP2; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236479AbiLWPbg (ORCPT + 99 others); Fri, 23 Dec 2022 10:31:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236398AbiLWPbf (ORCPT ); Fri, 23 Dec 2022 10:31:35 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E485B2; Fri, 23 Dec 2022 07:31:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YI+GETaE07zfIF6gTr93yZkoaqmkXGRyTSkPLa22IzA=; b=RkLgtlP2zs+0grtCP2XKKuFJes 6FHjSru80hSAyAYCWjR4giWwoV3DaU3XpMF7/3HZDUa+E/kozrd+x6VmAXg4TRMKJHW9b8wzSyfeD VokI0tlui9x8PQhh88Z82EqORo/ZAaFcoi8Gbx6S9ZrNjmqThuHWTTIRq3+YEjgq3IX5yINDVvjt+ e0+/qxQDLcU/llLFjIUrhW0P/9m/nHcrhbkOptvrE3r4S9ZgmuFyMLR/rPv50gmRKgcXjautu9IC5 U8MyiLTneJokeOtEKvUEFCZUMIUmLTbzJVU1SPbmDcoK0FIf2BAPGpTW1uoenfctyu+YHc+9jx57b guycEkxA==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8k0x-009SnO-0o; Fri, 23 Dec 2022 15:31:15 +0000 Date: Fri, 23 Dec 2022 07:31:14 -0800 From: Christoph Hellwig To: David Howells Cc: Matthew Wilcox , Linus Torvalds , Steve French , Shyam Prasad N , Rohith Surabattula , Dave Wysochanski , Dominique Martinet , Ilya Dryomov , linux-cachefs@redhat.com, linux-cifs@vger.kernel.org, linux-afs@lists.infradead.org, v9fs-developer@lists.sourceforge.net, ceph-devel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Jeff Layton , linux-erofs@lists.ozlabs.org, linux-ext4@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 3/3] mm: Make filemap_release_folio() better inform shrink_folio_list() Message-ID: References: <167172131368.2334525.8569808925687731937.stgit@warthog.procyon.org.uk> <167172134962.2334525.570622889806603086.stgit@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <167172134962.2334525.570622889806603086.stgit@warthog.procyon.org.uk> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, Dec 22, 2022 at 03:02:29PM +0000, David Howells wrote: > Make filemap_release_folio() return one of three values: > > (0) FILEMAP_CANT_RELEASE_FOLIO > > Couldn't release the folio's private data, so the folio can't itself > be released. > > (1) FILEMAP_RELEASED_FOLIO > > The private data on the folio was released and the folio can be > released. > > (2) FILEMAP_FOLIO_HAD_NO_PRIVATE These names read really odd, due to the different placementments of FOLIO, the present vs past tense and the fact that 2 also released the folio, and the reliance of callers that one value of an enum must be 0, while no unprecedented, is a bit ugly. But do we even need them? What abut just open coding filemap_release_folio (which is a mostly trivial function) in shrink_folio_list, which is the only place that cares? if (folio_has_private(folio) && folio_needs_release(folio)) { if (folio_test_writeback(folio)) goto activate_locked; if (mapping && mapping->a_ops->release_folio) { if (!mapping->a_ops->release_folio(folio, gfp)) goto activate_locked; } else { if (!try_to_free_buffers(folio)) goto activate_locked; } if (!mapping && folio_ref_count(folio) == 1) { ... alternatively just keep using filemap_release_folio and just add the folio_needs_release in the first branch. That duplicates the test, but makes the change a one-liner.