Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp31702838rwd; Fri, 7 Jul 2023 03:15:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlH2csTsaQ/8qTyHf70d0Hsj/JvapmcNn9qcBDLS2OrylnRSnLMffMBXxZT5VLP6Wkosvd5N X-Received: by 2002:a05:6808:150:b0:3a0:4faf:accd with SMTP id h16-20020a056808015000b003a04fafaccdmr4138800oie.32.1688724959447; Fri, 07 Jul 2023 03:15:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688724959; cv=none; d=google.com; s=arc-20160816; b=RT6VAxn1so5HYTlFsXDESIiTZ1oNEcEh3WSfhT/PPUlbIvvN989BuVkI85EXzJajpp Z8QQgHa/fu6gz5xJfZbOBkxj56T9kyqkelqPALs3PWujDdinC1sXRU4Q1OzDFXwlKMCQ 5KWgD2rC5nsmMA27B/KXtAUo6HkgJOy9OoX1ChVjJZjInT0bV67DYsLRsyfT5MmG3FIQ EjVcwJclaNfRsHZafAqbVmRDziT705rvKw6YAIsn2IaO5+a1aaAoDu6jhG82otz1AmmZ 81MOlHoEmXabjAM2IbJR5Cw/5Be9ZtC+iNHhAh214sWJ/kTBECY2PGktroKa0q+8Jtm6 MHow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=T44E6yhPUhlQx4fPHFAqbiEHMt+6vWxLZGL6p9gkIP4=; fh=fdRB1Ba8h+wqZwueZYXh3muZcK9qCV+IYPaHCc2HKgA=; b=jaL2ZST+Wi/D1XvVTxR+HycOjGcG/0F/5hFld5IJivbeoPBnP6suS2FW8BJv95l9Tf rcB1+wyDJa0dHIWNoyGsIbd6YFC1htAVTwSuQ13VrwgF+KMGYY6HaFaNwlQ5XjAYLXnr rYxVu4O+h6nNwpRBTzSs9OA8yYBqtWJh/b1ATWdNLdEhAXHv21LzUi36Mr3eZ47LiDK3 HushR0++eFL/phpi9VkOlz9uDINOZOtWhMRVUvf2OSRPddftNmXoJGet06SG3yvVPShs U0CX9+JM+0W/0g4b2ommtEH9NvPAMcsiL5RkXgL1AvIuFHLVj1mkMt1DhOhRe0XMWJYV B//Q== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a63e444000000b0055bc30ae086si3500743pgk.594.2023.07.07.03.15.45; Fri, 07 Jul 2023 03:15:59 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232836AbjGGJwy (ORCPT + 99 others); Fri, 7 Jul 2023 05:52:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232853AbjGGJwr (ORCPT ); Fri, 7 Jul 2023 05:52:47 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EB0BF170F for ; Fri, 7 Jul 2023 02:52:43 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 59F45D75; Fri, 7 Jul 2023 02:53:25 -0700 (PDT) Received: from [10.57.77.63] (unknown [10.57.77.63]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BEF063F740; Fri, 7 Jul 2023 02:52:40 -0700 (PDT) Message-ID: <44e60630-5e9d-c8df-ab79-cb0767de680e@arm.com> Date: Fri, 7 Jul 2023 10:52:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v2 4/5] mm: FLEXIBLE_THP for improved performance To: "Huang, Ying" Cc: Andrew Morton , Matthew Wilcox , "Kirill A. Shutemov" , Yin Fengwei , David Hildenbrand , Yu Zhao , Catalin Marinas , Will Deacon , Anshuman Khandual , Yang Shi , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230703135330.1865927-1-ryan.roberts@arm.com> <20230703135330.1865927-5-ryan.roberts@arm.com> <87edlkgnfa.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Ryan Roberts In-Reply-To: <87edlkgnfa.fsf@yhuang6-desk2.ccr.corp.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 07/07/2023 09:01, Huang, Ying wrote: > Ryan Roberts writes: > >> Introduce FLEXIBLE_THP feature, which allows anonymous memory to be >> allocated in large folios of a specified order. All pages of the large >> folio are pte-mapped during the same page fault, significantly reducing >> the number of page faults. The number of per-page operations (e.g. ref >> counting, rmap management lru list management) are also significantly >> reduced since those ops now become per-folio. > > I likes the idea to share as much code as possible between large > (anonymous) folio and THP. Finally, THP becomes just a special kind of > large folio. > > Although we can use smaller page order for FLEXIBLE_THP, it's hard to > avoid internal fragmentation completely. So, I think that finally we > will need to provide a mechanism for the users to opt out, e.g., > something like "always madvise never" via > /sys/kernel/mm/transparent_hugepage/enabled. I'm not sure whether it's > a good idea to reuse the existing interface of THP. I wouldn't want to tie this to the existing interface, simply because that implies that we would want to follow the "always" and "madvise" advice too; That means that on a thp=madvise system (which is certainly the case for android and other client systems) we would have to disable large anon folios for VMAs that haven't explicitly opted in. That breaks the intention that this should be an invisible performance boost. I think it's important to set the policy for use of THP separately to use of large anon folios. I could be persuaded on the merrits of a new runtime enable/disable interface if there is concensus. > > Best Regards, > Huang, Ying