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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3AEFC83F17 for ; Wed, 30 Aug 2023 19:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235820AbjH3TmK (ORCPT ); Wed, 30 Aug 2023 15:42:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233710AbjH3TkT (ORCPT ); Wed, 30 Aug 2023 15:40:19 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D00801D906 for ; Wed, 30 Aug 2023 12:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=Tqz/DZawdYZxdUO9cH0CNTKU0VPKN8BYJEeAbOf2UBM=; b=oe+LBcOaZkEVCF8aJtKZlvfWSg ZhPQg99fcqS1AWvoK39kdwiB+SKWjXItaWk3dAAgcHfB2FVAE2ZeKq9EhhnnsxehM4JrCu0d3AFHV SOa60NHEU1h7Jfn154TvmjndfOdAHJBgxH8BjePTNgJRNbyojEQtxroskuLDOjFdjtbNJJlUp8mr9 zomm2H6pEf5PJjmOwHhroH9ekX4sPwNE5B0knDdAlygRyfdDuTSQ5Kg248kaPKPBwH74x+rImIsmc byLHGWpiEmHQkNG6tOD1W4FimhTEwUUfeMYxhs7KDd17cuvTCkHcHIlc10L4/ibzdy3NW08OeZ9x6 wIxJsDFQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qbQap-00ET8A-Fp; Wed, 30 Aug 2023 19:11:07 +0000 Date: Wed, 30 Aug 2023 20:11:07 +0100 From: Matthew Wilcox To: Ryan Roberts Cc: Will Deacon , "Aneesh Kumar K.V" , Andrew Morton , Nick Piggin , Peter Zijlstra , Christian Borntraeger , Sven Schnelle , Arnd Bergmann , David Hildenbrand , Yu Zhao , "Kirill A. Shutemov" , Yin Fengwei , Yang Shi , "Huang, Ying" , Zi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 4/5] mm: Refector release_pages() Message-ID: References: <20230830095011.1228673-1-ryan.roberts@arm.com> <20230830095011.1228673-5-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230830095011.1228673-5-ryan.roberts@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 30, 2023 at 10:50:10AM +0100, Ryan Roberts wrote: > In preparation for implementing folios_put_refs() in the next patch, > refactor release_pages() into a set of helper functions, which can be > reused. The primary difference between release_pages() and > folios_put_refs() is how they iterate over the set of folios. The > per-folio actions are identical. As you noted, we have colliding patchsets. I'm not hugely happy with how patch 4 turned out, so I thought I'd send some addendum patches to my RFC series that implement pfn_range_put() (maybe should have been pfn_ranges_put()?) on top of my patch series. I think it's a bit nicer, but not quite as nice as it could be. I'm thinking about doing ... void release_unref_folios(struct folio_batch *folios) { struct lruvec *lruvec = NULL; unsigned long flags = 0; int i; for (i = 0; i < folios->nr; i++) { struct folio *folio = folios->folios[i]; free_swap_cache(folio); __page_cache_release(folio, &lruvec, &flags); } mem_cgroup_uncharge_folios(folios); free_unref_folios(folios); } then this becomes: void folios_put(struct folio_batch *folios) { int i, j; for (i = 0, j = 0; i < folios->nr; i++) { struct folio *folio = folios->folios[i]; if (is_huge_zero_page(&folio->page)) continue; if (folio_is_zone_device(folio)) { if (put_devmap_managed_page(&folio->page)) continue; if (folio_put_testzero(folio)) free_zone_device_page(&folio->page); continue; } if (!folio_put_testzero(folio)) continue; if (folio_test_hugetlb(folio)) { free_huge_folio(folio); continue; } if (j != i) folios->folios[j] = folio; j++; } folios->nr = j; if (!j) return; release_unref_folios(folios); } and pfn_range_put() also becomes shorter and loses all the lruvec work. Thoughts?