Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp388729rdb; Tue, 5 Dec 2023 08:07:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGorVLgnyvgPFE6E5eRICAWCXhjUBqFYzRJiQsoAKD8YVxjVm0LLolIbRX+I3fWGisM51O X-Received: by 2002:a05:6a20:e186:b0:18f:97c:9788 with SMTP id ks6-20020a056a20e18600b0018f097c9788mr7940222pzb.112.1701792431567; Tue, 05 Dec 2023 08:07:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701792431; cv=none; d=google.com; s=arc-20160816; b=jVrW6fD17fMbNspsqYuECU5uwLqNUX9l96C+IvbIhbPyO1bYesM8lfKc3lmii2aIkt W7TUJUaRHdf16ulT6+yIjCxmIEcA+3gQ8zxbR0QzDhcAEPmcYgYKkjm8kzwoWTmauIQc xs2+69BZUrtjxZ2auVpU+wkVApnLNccJOZZjUBc6r8KinzIrkIAZ9mmeUnFCjrBmaVhZ 1OjwYwIRrhSaKyOoL/SJbtfy2KwiElQxHKTG+aHQQBsbpQlWsmT/aEOGVoYxvDMq0nwE wtg8dAxPgZs/iyBT46MJw/G90zsdRjEx7PALoDVOYnsTB6IYuCsJk2rdan/kQ1u5cOuw cVgw== 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=vZ9hGmOAU2FBZdAcWBT4EroA4dZyM8ao7E1RVyy5W1Q=; fh=iDft61qgIX1JZPojfOHTPzm3JN6OwiMquZMT+ic6gg0=; b=We/JIoH7vLKXYjGEXIw/qFbV46mDFa+KRD2WaR59isZ5A38INiMUS6fqyJA2ecXtNf kU7nOd1ZzVfw0OEzYkfA5SAXar6I2SvH3e1o0etDreyEKW82DoNmDYDBo/I/p6lX3W0y RaRdDUjI/1yqn/DVRWh7TAcgpiTpRgdnSWPO2oIpf1gfSGZpzJj6qCSQVHDWtS7rgvgy i+pEfNe+aQBbtcTZuFdkNFLjVKDSep7BwYRd1FYMSfz3tbNwhWB2dVfZ5XLaWMiZYjqq tVx7LSKkP7gM4AftzYao1iitAHI6UEdVLESE6FAkvoy3Y6d7+aMvhYxRV+qpe7D8yU3Q dR9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JfAYiPlI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id z19-20020a63e113000000b005c14fc66cc4si5425120pgh.380.2023.12.05.08.07.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 08:07:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JfAYiPlI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2B20680AD946; Tue, 5 Dec 2023 08:06:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235598AbjLEQG0 (ORCPT + 99 others); Tue, 5 Dec 2023 11:06:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235614AbjLEQGQ (ORCPT ); Tue, 5 Dec 2023 11:06:16 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11F54D62 for ; Tue, 5 Dec 2023 08:06:20 -0800 (PST) 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=vZ9hGmOAU2FBZdAcWBT4EroA4dZyM8ao7E1RVyy5W1Q=; b=JfAYiPlIjHY6yui/t2m/kE0wwI NQ+2jYzHxNa0mPbd0fmcYgXvhv1NLrJ5ufZAOKI5GeGjrSTknq7p2pKaPTDOxqhZGPcCk0hsGAvwN FQ9iDXDki6wTVSFIHpXWiZoF7qh/DD4rSm9SX9yTLrkn/1CjUcf+W1NHn4VSyiizp7h/kk4ZcImh1 60HHfxOOehBijlCbWAJsEoulSTiEIpMiFMX+0aftLr1+veiUBaBSdh82CB3/txeuAhQsjmreIAHe+ 24RZQgCsAM8qSjBcquM5jzjbUwQ1txDmwnq25RI28EikbuYdQhlRmba18Ls5HIJDDhUvx3N9zFvtl gnYjTGNg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rAXvi-0022Oo-57; Tue, 05 Dec 2023 16:05:50 +0000 Date: Tue, 5 Dec 2023 16:05:50 +0000 From: Matthew Wilcox To: Ryan Roberts Cc: John Hubbard , Andrew Morton , Yin Fengwei , David Hildenbrand , Yu Zhao , Catalin Marinas , Anshuman Khandual , Yang Shi , "Huang, Ying" , Zi Yan , Luis Chamberlain , Itaru Kitayama , "Kirill A. Shutemov" , David Rientjes , Vlastimil Babka , Hugh Dickins , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v6 0/9] variable-order, large folios for anonymous memory Message-ID: References: <20230929114421.3761121-1-ryan.roberts@arm.com> <181a25c2-219e-4af9-9f8e-e5f514bbc4b6@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <181a25c2-219e-4af9-9f8e-e5f514bbc4b6@arm.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 05 Dec 2023 08:06:40 -0800 (PST) On Tue, Nov 14, 2023 at 10:57:07AM +0000, Ryan Roberts wrote: > On 13/11/2023 15:04, Matthew Wilcox wrote: > > On Mon, Nov 13, 2023 at 10:19:48AM +0000, Ryan Roberts wrote: > >> On 13/11/2023 05:18, Matthew Wilcox wrote: > >>> My hope is to abolish the 64kB page size configuration. ie instead of > >>> using the mixture of page sizes that you currently are -- 64k and > >>> 1M (right? Order-0, and order-4) > >> > >> Not quite; the contpte-size for a 64K page size is 2M/order-5. (and yes, it is > >> 64K/order-4 for a 4K page size, and 2M/order-7 for a 16K page size. I agree that > >> intuitively you would expect the order to remain constant, but it doesn't). > >> > >> The "recommend" setting above will actually enable order-3 as well even though > >> there is no HW benefit to this. So the full set of available memory sizes here is: > >> > >> 64K/order-0, 512K/order-3, 2M/order-5, 512M/order-13 > >> > >>> , that 4k, 64k and 2MB (order-0, > >>> order-4 and order-9) will provide better performance. > >>> > >>> Have you run any experiements with a 4kB page size? > >> > >> Agree that would be interesting with 64K small-sized THP enabled. And I'd love > >> to get to a world were we universally deal in variable sized chunks of memory, > >> aligned on 4K boundaries. > >> > >> In my experience though, there are still some performance benefits to 64K base > >> page vs 4K+contpte; the page tables are more cache efficient for the former case > >> - 64K of memory is described by 8 bytes in the former vs 8x16=128 bytes in the > >> latter. In practice the HW will still only read 8 bytes in the latter but that's > >> taking up a full cache line vs the former where a single cache line stores 8x > >> 64K entries. > > > > This is going to depend on your workload though -- if you're using more > > 2MB than 64kB, you get to elide a layer of page table with 4k base, > > rather than taking up 4 cache lines with a 64k base. > > True, but again depending on workload/config, you may have few levels of lookup > for the 64K native case in the first place because you consume more VA bits at > each level. Sorry, missed this email ... let's work it through. With 4k, and a 48-bit VA space, we get 12 bits at the lowest level, then 9 bits each layer, so 4 * 9 + 12 = 48. With a 2MB allocation, we eliminate the bottom layer and examine three cachelines to find it (PGD entry, PUD entry, PMD entry) With 64k, we get 16 bits at the lowest level, then 13 bits each layer, so 3 * 13 + 16 = 55. With a 2MB allocation, we can't eliminate the bottom layer, so we still have to examine three cachelines to find it (PGD, PMD, PTE). If you can fit into a 42-bit address space, you can reduce it by one cache miss, but my impression is that applications which use 21 bits of address space for a single allocation want more address space than your average application.