Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5767801rwp; Mon, 17 Jul 2023 09:08:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlHsCzz3q4GU+snOFkcfVxj1jwdK2dtXlP8DBU/47CKpmfQ3wmAa/FdXRzhY/ujXsZdFWy4+ X-Received: by 2002:a17:906:60d:b0:993:f9b2:93c1 with SMTP id s13-20020a170906060d00b00993f9b293c1mr11338496ejb.9.1689610116331; Mon, 17 Jul 2023 09:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689610116; cv=none; d=google.com; s=arc-20160816; b=LyUp83iAL1EhjkkLdLRHVwuNDoC/VRq2ZLhDbvvakI696CsGjoJwvZrQjBqi9qLa+0 2hkEa1LGGwKtSmKP5NmCyK3xboba3vphF/BLIwypgB9zkHiPvO5y4sndRV9+Lv4GXORP MK9KLG2z1PZRSiqNjWXG/c180AyBmmSU2WypL1OJCjqh0xF1HA1WriPNeMx34fi0bbdq yWhzpz2mo++ICYBXXhhVY8VcgPVQQ5eZOFrh/Nkv1WiGqAf08RU5qF9EkfIY9zp5KC1m TVTXf9qerQh+uK0CH/WFetqwukWrom4EAOuNfqp8AvD9/ZEp4bGm9Dsw3M+a0PUrUOlB XYjA== 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=PjCcG9GMHBMdf5iB1swzPe5EzvZ1yf8Qqje/jcuPjk0=; fh=NIRv1XTTOJEPkt+EEB+ENBk6YWfmMMXSOfNshlXTI1U=; b=x5CuLnSQ+Az5snD1FCs/GOpQD+XASxzbHrH479UWDTsVobTZUETpE/EaBgt/177fEX Om8sg/tA5WMbYrUx7nEpdlXJRPrmF3b3RPSlhE7zoLH1UKSyVgcpnI8vBeCvsp5RzD92 W8T6J3YPatYcUNiL0GMBvVOXeX8X9/+6Ynt2t1q94u8kCfyxs0wELaelMPiSd+7eTAiI 8SGSHE78F1jp1ISxiWB5ItEIoaYFCLLd+Mer1L+BDbsql/5Mjz3uG2TrqJljvpzDLonm T1GIdN1W6Ob9wskl9cfSZMP3daNLBPXDcyIQERfQHHavqCF0mNeny7NSD5upd26rDzKD Mscg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=MYMB6qFH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 qc15-20020a170906d8af00b009924806ccffsi8259057ejb.488.2023.07.17.09.08.11; Mon, 17 Jul 2023 09:08:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=casper.20170209 header.b=MYMB6qFH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231895AbjGQPzL (ORCPT + 99 others); Mon, 17 Jul 2023 11:55:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbjGQPzK (ORCPT ); Mon, 17 Jul 2023 11:55:10 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44C92A4 for ; Mon, 17 Jul 2023 08:55:09 -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=PjCcG9GMHBMdf5iB1swzPe5EzvZ1yf8Qqje/jcuPjk0=; b=MYMB6qFHsfey39Gq6ZMPCsAz15 N+LIcWiSErJvhVYjCEfoHts27sXhwSyGgYrm80DT53qMnC723NVbXFs54ywzFkwoXXhnc0fVVEtVB WFK8BxmthSxTRrNlnWFBxNTuo+91uRpQMdkEMpcOdB+nl75GMne+VxdPb9SjW1HarvP3qEnonx776 sfoEeYtHGzyw00UXWWWJViCewsYbmOaNqC7D++PMupN61AGCfW2H4pRLZ57FaZT7KYFRCvzEexZIq Mdzzfvq8jLEGTkRQV0zciAcGUOkzFLeAgwyABNnREupzHGAh4F7KeeJCqDuVTD3YiUExKyShr0olV A5/7I5mw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qLQYs-0043W7-R6; Mon, 17 Jul 2023 15:54:59 +0000 Date: Mon, 17 Jul 2023 16:54:58 +0100 From: Matthew Wilcox To: David Hildenbrand Cc: Ryan Roberts , Andrew Morton , Yin Fengwei , Yu Zhao , Yang Shi , "Huang, Ying" , Zi Yan , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v1 1/3] mm: Allow deferred splitting of arbitrary large anon folios Message-ID: References: <20230717143110.260162-1-ryan.roberts@arm.com> <20230717143110.260162-2-ryan.roberts@arm.com> <283e4122-c23f-35a1-4782-fddde32f4ad4@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org On Mon, Jul 17, 2023 at 05:43:40PM +0200, David Hildenbrand wrote: > On 17.07.23 17:41, Ryan Roberts wrote: > > On 17/07/2023 16:30, Matthew Wilcox wrote: > > > On Mon, Jul 17, 2023 at 03:31:08PM +0100, Ryan Roberts wrote: > > > > In preparation for the introduction of large folios for anonymous > > > > memory, we would like to be able to split them when they have unmapped > > > > subpages, in order to free those unused pages under memory pressure. So > > > > remove the artificial requirement that the large folio needed to be at > > > > least PMD-sized. > > > > > > > > Signed-off-by: Ryan Roberts > > > > Reviewed-by: Yu Zhao > > > > Reviewed-by: Yin Fengwei > > > > > > Reviewed-by: Matthew Wilcox (Oracle) > > > > Thanks! > > > > > > > > > */ > > > > - if (folio_test_pmd_mappable(folio) && folio_test_anon(folio)) > > > > + if (folio_test_large(folio) && folio_test_anon(folio)) > > > > if (!compound || nr < nr_pmdmapped) > > > > deferred_split_folio(folio); > > > > > > I wonder if it's worth introducing a folio_test_deferred_split() (better > > > naming appreciated ...) to allow us to allocate order-1 folios and not > > > do horrible things. Maybe it's not worth supporting order-1 folios; > > > we're always better off going to order-2 immediately. Just thinking. > > > > There is more than just _deferred_list in the 3rd page; you also have _flags_2a > > and _head_2a. I guess you know much better than me what they store. But I'm > > guessing its harder than jsut not splitting an order-1 page? Those are page->flags and page->compound_head for the third page in the folio. They don't really need a name; nothing refers to them, but it's important that space not be reused ;-) This is slightly different from _flags_1; we do have some flags which reuse the bits (they're labelled as PF_SECOND). Right now, it's only PF_has_hwpoisoned, but we used to have PF_double_map. Others may arise. > > With the direction of large anon folios (_not_ retrying with every order down to > > 0), I'm not sure what the use case would be for order-1 anyway? > > Just noting that we might need some struct-page space for better > mapcount/shared tracking, which might get hard for order-1 pages. My assumption had been that we'd be able to reuse the _entire_mapcount and _nr_pages_mapped fields and not spill into the third page, but the third page is definitely available today if we want it. I'm fine with disallowing order-1 anon/file folios forever.