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 4B617C83F2B for ; Thu, 31 Aug 2023 08:09:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF9788E0011; Thu, 31 Aug 2023 04:09:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B829F8D0001; Thu, 31 Aug 2023 04:09:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D5128E0011; Thu, 31 Aug 2023 04:09:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 88AD88D0001 for ; Thu, 31 Aug 2023 04:09:30 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 50EC240186 for ; Thu, 31 Aug 2023 08:09:30 +0000 (UTC) X-FDA: 81183675300.30.04C0AF6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 1676C14001C for ; Thu, 31 Aug 2023 08:09:27 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QXZeTOEX; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693469368; a=rsa-sha256; cv=none; b=PpjvwyZuxBjrCYTuCTSESrZR67brZ0kbYFQd78n6AtN9pKqKRhfExP3aMFbBthoTvX7f8B uomX4vzPB7IhBaG4AfQqpF39PunaXFFQRFauoSJEs0VM1Aq/TSKhMEU5EWRYA6TKsKd3Jx LRvD3q6E0Ba8L+2ayMxBVoD6HcNL/6s= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QXZeTOEX; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693469368; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H0ofhpazPjwKjea88CcdW/OVZwJHwubosedHXv1QjBs=; b=K9fTT4V+iCds3kV5IuS6G2lidUFtoHS+zW6eWmvxLK5igHx7iu9rqHybkrXBrHGPobQ64o XEZIJzEhW/IU33woLfxeK1DFjRH+Zy9hQZ3ISjc7gBVBpK931rMJi948P3q/bwucePyqAt faln2JyKfNYHUstf5QAterIEpbTK320= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693469367; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H0ofhpazPjwKjea88CcdW/OVZwJHwubosedHXv1QjBs=; b=QXZeTOEXzEKiniLqdmK+sQhR+itpuoapTcYwF1lLgkYS3rOtOuGBTAsQFvKVPXnd27oMH9 hB6vp0NfQ4mJ26HGc1cxqZrnI01BLUzIMnrJENhj0i1ODwW0SZgd+jfjZTfoNXMo/tPglP XXgk6+UMipC0Q707RAbY63/x5lpWNz0= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-648-ZciBS0zDOyuIdLv2aEXelA-1; Thu, 31 Aug 2023 04:09:23 -0400 X-MC-Unique: ZciBS0zDOyuIdLv2aEXelA-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-500be41e54dso787651e87.1 for ; Thu, 31 Aug 2023 01:09:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693469362; x=1694074162; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=H0ofhpazPjwKjea88CcdW/OVZwJHwubosedHXv1QjBs=; b=E8PFsAY16fMsl4omJG7C2wUbN/mAJozVPYZOXxzXrRAD5O6HMaqwTDE+9/BynhZ6CE vrs+gNKCC3h8X7ucxeh4aK4mXQ7pt4ruQRwRDJw9aVW3hXh01CND/+DY90aNT1upiBgl s7BuuDgrUvd9itvcVrJVbxxhRT2rEkSaRqjNNlMsVd5HtT9K1QMPbRj1rOkYv230mxQv KYErvvvke73j+YQkxnFWaASA8sUqaAl6VauBjJrkDscmSzD9gY2fNt4JXGIU3YL+CGC3 AqJGb5MyIbhbDOh2MXRP5X76StCy1FECIRbBcTHzR/d+hoVhhikmM61Ml9ma2suFbujZ tEPw== X-Gm-Message-State: AOJu0YxkO0Ma/fTak2vxzZa0Y16k8mGUNCNX4gOOceN6PsQraR2iPGV1 9wqP4m5IGwCC9da7eXgoUr7I9rsb2mfFS1McvJLWv58eta7tKzCDMIm4MIaepJz7ogI6y0MlY+y QTY492tJhlMc= X-Received: by 2002:a05:6512:52f:b0:4fe:af1:c3ae with SMTP id o15-20020a056512052f00b004fe0af1c3aemr3126417lfc.15.1693469362299; Thu, 31 Aug 2023 01:09:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbwaEbzS0C90AS2MC0WV7pkbdVAR2o61qG9h2rNGTcqhh7JTUilAK4ff+DZB/AAaSv5eO8sQ== X-Received: by 2002:a05:6512:52f:b0:4fe:af1:c3ae with SMTP id o15-20020a056512052f00b004fe0af1c3aemr3126391lfc.15.1693469361790; Thu, 31 Aug 2023 01:09:21 -0700 (PDT) Received: from [10.59.19.200] (pd956a06e.dip0.t-ipconnect.de. [217.86.160.110]) by smtp.gmail.com with ESMTPSA id p3-20020a05600c1d8300b00401e32b25adsm1193765wms.4.2023.08.31.01.09.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 31 Aug 2023 01:09:20 -0700 (PDT) Message-ID: Date: Thu, 31 Aug 2023 10:09:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v5 3/5] mm: LARGE_ANON_FOLIO for improved performance To: "Yin, Fengwei" , "Huang, Ying" , Ryan Roberts Cc: Andrew Morton , Matthew Wilcox , Yu Zhao , Catalin Marinas , Anshuman Khandual , Yang Shi , Zi Yan , Luis Chamberlain , Itaru Kitayama , "Kirill A. Shutemov" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20230810142942.3169679-1-ryan.roberts@arm.com> <20230810142942.3169679-4-ryan.roberts@arm.com> <87v8dg6lfu.fsf@yhuang6-desk2.ccr.corp.intel.com> <5c9ba378-2920-4892-bdf0-174e47d528b7@arm.com> <87cyz43s63.fsf@yhuang6-desk2.ccr.corp.intel.com> <4e14730b-4e4c-de30-04bb-9f3ec4a93754@redhat.com> <747deb43-68c8-449f-b41a-91864820a699@intel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <747deb43-68c8-449f-b41a-91864820a699@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Trans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s4FKxP1DMnPbeL4si4mC7Z4hS40u4uFv8+hFQZJj BGeFNMho JEPiuFZ+68DcMdB3vcAmvl+xK8wMwZWB4h4KX82gRcuuwLSxYv9TKbBcqglFJBD9BN/etRzHQQBvEEDJZ+F6GKQK4t84cLBC63Wa4GlNg4OWpiadvBMFWpF55gHhCQyv/mPC1jo83P1WMYh1yVC6aN92D0qEzYPPDoTSikFIsvrXVK8VcPFd2WYmnNYpAhtEBQwhHH0RtZejoJrU/r8p+k4r1ZS+p+qoyv3KXNbqCnqXVQLVZWh4RH5hk562WKRUtJUcklSWQ3XwZrWFNomVHhbyWUnSB7Gqo708gk7ks/GJbatTk8z/aWfIUDrWPRV20of3cLTrzHVMmOwKvmN5hjm4siKcSfTOSR7uR5Gpo1EMLz5sNulyazeJwN/1At/bBOZ3ismmLLPuJlJoYklgqelKKPLsSxwRtr1bElkryfINe0qQcDdzXGXDGdbCI/xI5TKTDQOpBH8yBORDttEyCLCfFV/ZcMYVZGueTl8giD2TPqGCo41I2ckG4EAEygL/wK0YthzG9Dvg8ZpTA0wqXJXTtpSC17jop1yGep+WRnpkSpXinDLrut7NYBKUnh2y8UiqvMDMUaomtX9w= 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 31.08.23 10:02, Yin, Fengwei wrote: > > > On 8/31/2023 3:57 PM, David Hildenbrand wrote: >> On 31.08.23 03:40, Huang, Ying wrote: >>> Ryan Roberts writes: >>> >>>> On 15/08/2023 22:32, Huang, Ying wrote: >>>>> Hi, Ryan, >>>>> >>>>> Ryan Roberts writes: >>>>> >>>>>> Introduce LARGE_ANON_FOLIO feature, which allows anonymous memory to be >>>>>> allocated in large folios of a determined 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. >>>>>> >>>>>> The new behaviour is hidden behind the new LARGE_ANON_FOLIO Kconfig, >>>>>> which defaults to disabled for now; The long term aim is for this to >>>>>> defaut to enabled, but there are some risks around internal >>>>>> fragmentation that need to be better understood first. >>>>>> >>>>>> Large anonymous folio (LAF) allocation is integrated with the existing >>>>>> (PMD-order) THP and single (S) page allocation according to this policy, >>>>>> where fallback (>) is performed for various reasons, such as the >>>>>> proposed folio order not fitting within the bounds of the VMA, etc: >>>>>> >>>>>>                  | prctl=dis | prctl=ena   | prctl=ena     | prctl=ena >>>>>>                  | sysfs=X   | sysfs=never | sysfs=madvise | sysfs=always >>>>>> ----------------|-----------|-------------|---------------|------------- >>>>>> no hint         | S         | LAF>S       | LAF>S         | THP>LAF>S >>>>>> MADV_HUGEPAGE   | S         | LAF>S       | THP>LAF>S     | THP>LAF>S >>>>>> MADV_NOHUGEPAGE | S         | S           | S             | S >>>>> >>>>> IMHO, we should use the following semantics as you have suggested >>>>> before. >>>>> >>>>>                  | prctl=dis | prctl=ena   | prctl=ena     | prctl=ena >>>>>                  | sysfs=X   | sysfs=never | sysfs=madvise | sysfs=always >>>>> ----------------|-----------|-------------|---------------|------------- >>>>> no hint         | S         | S           | LAF>S         | THP>LAF>S >>>>> MADV_HUGEPAGE   | S         | S           | THP>LAF>S     | THP>LAF>S >>>>> MADV_NOHUGEPAGE | S         | S           | S             | S >>>>> >>>>> Or even, >>>>> >>>>>                  | prctl=dis | prctl=ena   | prctl=ena     | prctl=ena >>>>>                  | sysfs=X   | sysfs=never | sysfs=madvise | sysfs=always >>>>> ----------------|-----------|-------------|---------------|------------- >>>>> no hint         | S         | S           | S             | THP>LAF>S >>>>> MADV_HUGEPAGE   | S         | S           | THP>LAF>S     | THP>LAF>S >>>>> MADV_NOHUGEPAGE | S         | S           | S             | S >>>>> >>>>>  From the implementation point of view, PTE mapped PMD-sized THP has >>>>> almost no difference with LAF (just some small sized THP).  It will be >>>>> confusing to distinguish them from the interface point of view. >>>>> >>>>> So, IMHO, the real difference is the policy.  For example, prefer >>>>> PMD-sized THP, prefer small sized THP, or fully auto.  The sysfs >>>>> interface is used to specify system global policy.  In the long term, it >>>>> can be something like below, >>>>> >>>>> never:      S               # disable all THP >>>>> madvise:                    # never by default, control via madvise() >>>>> always:     THP>LAF>S       # prefer PMD-sized THP in fact >>>>> small:      LAF>S           # prefer small sized THP >>>>> auto:                       # use in-kernel heuristics for THP size >>>>> >>>>> But it may be not ready to add new policies now.  So, before the new >>>>> policies are ready, we can add a debugfs interface to override the >>>>> original policy in /sys/kernel/mm/transparent_hugepage/enabled.  After >>>>> we have tuned enough workloads, collected enough data, we can add new >>>>> policies to the sysfs interface. >>>> >>>> I think we can all imagine many policy options. But we don't really have much >>>> evidence yet for what it best. The policy I'm currently using is intended to >>>> give some flexibility for testing (use LAF without THP by setting sysfs=never, >>>> use THP without LAF by compiling without LAF) without adding any new knobs at >>>> all. Given that, surely we can defer these decisions until we have more data? >>>> >>>> In the absence of data, your proposed solution sounds very sensible to me. But >>>> for the purposes of scaling up perf testing, I don't think its essential given >>>> the current policy will also produce the same options. >>>> >>>> If we were going to add a debugfs knob, I think the higher priority would be a >>>> knob to specify the folio order. (but again, I would rather avoid if possible). >>> >>> I totally understand we need some way to control PMD-sized THP and LAF >>> to tune the workload, and nobody likes debugfs knob. >>> >>> My concern about interface is that we have no way to disable LAF >>> system-wise without rebuilding the kernel.  In the future, should we add >>> a new policy to /sys/kernel/mm/transparent_hugepage/enabled to be >>> stricter than "never"?  "really_never"? >> >> Let's talk about that in a bi-weekly MM session. (I proposed it as a topic for next week). > > The time slot of the meeting is not friendly to our timezone. Like > it's 1 or 2 AM. Yes. I know it's very hard to find a good time slot > for US, EU and Asia. :(. :/ Yeah, even for me in Germany it's usually already around 6-7pm. > > So maybe we still need to discuss it through mail? I don't think we'll be done discussing that in one session. One of the main goals is to get some input from the wider MM community. -- Cheers, David / dhildenb