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 7FAD3EB64DC for ; Mon, 17 Jul 2023 15:55:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EC078D0003; Mon, 17 Jul 2023 11:55:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 09C438D0001; Mon, 17 Jul 2023 11:55:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECE748D0003; Mon, 17 Jul 2023 11:55:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DE14B8D0001 for ; Mon, 17 Jul 2023 11:55:13 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BA1411203F2 for ; Mon, 17 Jul 2023 15:55:13 +0000 (UTC) X-FDA: 81021552906.30.C72B3F6 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id BEC5C20003 for ; Mon, 17 Jul 2023 15:55:11 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MYMB6qFH; dmarc=none; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689609312; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PjCcG9GMHBMdf5iB1swzPe5EzvZ1yf8Qqje/jcuPjk0=; b=SJhBZqf4mYPb0F/cm7im1IY+K0NLUtv4vP1MY/Qzoot99pAJ13HCmyKGEUBI1gqIMcj59l ibWsVBFwlDaLS0o8LfbRaFy0/LSZDHT6fyUasn3a/fgfqljG4bTwCxcOdpXfy+mxahDRVa YP7LnM9IhtSIJBJ3symfVUAxG81LwBQ= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MYMB6qFH; dmarc=none; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689609312; a=rsa-sha256; cv=none; b=tMfT/SV3Iz8TIRFzOkLpPiuh18uRyfnvza/C9dIE9NedFAFqUjme3/KGMGCMpUT76HNqD1 gvXOg2LAw1RyBfLYE/YMZj4WlAGRyPyByLRlOoVsi6F3zgVO+5Mrp/ylqeJF2xe25S5o+V uzpWfC9kxRovG53PDodTbHPapteecxs= 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-Rspamd-Queue-Id: BEC5C20003 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 6shcmq9eedoaf5oyp66eiwoao1if9ucs X-HE-Tag: 1689609311-53964 X-HE-Meta: U2FsdGVkX1+/xPVG8c5+5p+iF6XotoVX7ud13yM4q6zJ4wjONcCoD5BC5M7e43HUCZHsbNVvk0sIqJFMv8jhEcYmXoDxYlG9G8T8NX7n6Y7HZk5OK8VKm63fNrk4DbnbWOiPM9ZpplQ6o41AN97OKEPw8HTx5IfxFbw6SV144/eQ/m1EQ9Cn5+3dUccgFYEiH4+JaEH0n+47vKwcunGAZjl5j8ldWUsLdKcqPosMG1RoZn7pybb2oT85MZJeYp11ITeSBOdM0UsI1a6buAdsLXNLkdKrbBzuVr7o52owZMoyLysD3dHPgbn2mRV5fw9VrOY7aWiuTT4loy5oOo1SfSMlYaLQMJ89j2o2PpEnBe1ufTmMKlLro5HlfCB6Z/RJSKZEUrNSosLSfSN0iokIFTllgzf+bfZSsj+3QjsXuzxbjAl4B5BnjNhdU7oDvW8zL9bTw8zOaPWsEk2Ziofzfi0YhbFC/f/PHnnxniPb0jMDRJoyqSoXifdLjWVUPpjyjI2cJkxRvWF3C1+E410+Ez+mBLOHxdTfUZ2q9N6ONTUeYqVBLtfanQhI9I9YnGzIx0ByEOxY/jGf5rVNA7ICJuPezKdge4hn3rLLPm94zyNxXUCPvTPSdD+oqzld3fQ8OHdnWiB2Cu7XcdgFHzPnt9svaOPlpMx2jDzT0ri9+Z/BazBnjHaQEjdUcHDXDvp8M0l69Zu6I3u/QNWionbRoQa9i1CjjDXDvzfT4Vl4zX/rKlmVYl+tZU2G9+LnM7aCtVM4uRwjDef3r5FBJnGvK/HpApJy5F+TO2fd+rxP305+P/10CrieP7Ipu9aFnpjTK/FfY69iuU5iuiTLeXClcWGOrr7R46PGuQmCzFDOCRbXi205P/Ge6eIZJQVnOptYHw71/+FoMhb+TGqgnJJIJrrgp5NQwnUB1QKSfcRMbg92HRxnC3uJ+IrCZ1gefwPVsljzz1BkLJN9zAaoeRs znn0NsK8 zkXd67esr694xg81iweQ4sFnv0ibU4OHwpIrOhJxXIFNhrNS2b3Rz6Tl3fGZgv7wdueDk49DY4tY3z8YZ8ZR7ZOfwgjN0txdFLWrRYr3SfFNx4RIGMvJ7RdCc4r5qhC4k41Yxkng934u2jkWSZtW1IkCxPEz18r9kkzEJcxTp3qA56WeVhUQOZzzgxGjNd/9K9edbs1ggCAcSPkPM0IR7hGLhxCw8owYsLlZ4y97kO22UoPG2ve8SKCGMa4ZcPFaLOC7sTiA3b+PESFrBTbDZkYFTp8RZXp7OVbe9yspYgFtWtWM= 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, 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.