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 81BB3C83F01 for ; Wed, 30 Aug 2023 22:14:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237651AbjH3WOQ (ORCPT ); Wed, 30 Aug 2023 18:14:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245479AbjH3WON (ORCPT ); Wed, 30 Aug 2023 18:14:13 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59AB18F for ; Wed, 30 Aug 2023 15:13:48 -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=wMEggmZxL4goGk4wIRAVlREtoAybKHItWmob2C6lubM=; b=llJXqS/aqU/78wYjuMyvbcGWf6 S/KvkO/6Ce2cTAS51CSTeEBsicD7Vzm3cAIWiBRFtI0RUFcfwCLT0WW3oWi96wAUBtgQYO4UMfZqe JceZLNrzFwRLlnlITHPjeDXV0SmeS5SWbiKmO4I58vv1n8itO02cdOsR2BEwcmQzn/beQgmSeuiBe ygBdX/R4mgrlRYoA3nQVmGUxhTy0lEvE6R6uDtIdkwc2po0Xo0W4dAOxJ8MEbRIyUmAhpzj2mGbrL g318SBKNpqf892YiCGyCi/OH899J2pjyXQax/I+50mdDSF0n2VSHRO+fE5A1fVOD78WCZ5LRM8njP dgBqrarg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qbSZF-00F1N4-Fo; Wed, 30 Aug 2023 21:17:37 +0000 Date: Wed, 30 Aug 2023 22:17:37 +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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 30, 2023 at 08:11:07PM +0100, Matthew Wilcox wrote: > 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); No, can't do that here. Swap cache has refs on the folio, so it'll never trigger. > __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; > } Must go at least here, maybe earlier. > 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? >