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 D1C56C4345F for ; Thu, 25 Apr 2024 08:26:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63AF26B007B; Thu, 25 Apr 2024 04:26:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EA616B0082; Thu, 25 Apr 2024 04:26:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 464126B0083; Thu, 25 Apr 2024 04:26:47 -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 1F01D6B007B for ; Thu, 25 Apr 2024 04:26:47 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 77FB98114D for ; Thu, 25 Apr 2024 08:26:46 +0000 (UTC) X-FDA: 82047373212.25.7E92DF5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 3990E4000C for ; Thu, 25 Apr 2024 08:26:43 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E2KYzzhz; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.129.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=1714033603; a=rsa-sha256; cv=none; b=3mNQ/9QsBhkFvHwMponrsvuzcP2IwsMQfcpLROtyMv7mueKZZsdi7NqPRv62o2kUaam77q Rfen236J6HFEPzk73ubniiNJednf7k0gEGEqMAvJ9ESbxVvNWm3XOiQQrsrBOMVJoZtZ0m /jgL79zk1G20LVwPLBDu4JFPCajP8uA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E2KYzzhz; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.129.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=1714033603; 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=kghZ7NSaCZFV0M/Xc1wvQWlGakuhyfaOna+6mlQjMq8=; b=US9zsl/fdTm7Pgj+7jM8KOnIJo4m1Rg2tjXSSQiOIIFYLzvOwsR7ZZd31xxOyc0z2cbkHg qchRV7RDLfe/MgJXh3sNwwVa9+22YcxWETteHXu824If9p8gPs1mqS793XzkKNNgRE7NZ0 HJXOJ2QkLuSVHVP/apkmQyj3CfiND5E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714033602; 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:autocrypt:autocrypt; bh=kghZ7NSaCZFV0M/Xc1wvQWlGakuhyfaOna+6mlQjMq8=; b=E2KYzzhzctuItz5Em3RwdGNQ4S5bKGqpFVnyJB/PDMZBqrtQhBIXyGGOoBj6aUnluHsfO1 C4JY6Kvy3mUwTr810m4M+cu5ywBQvpwl+Rt0iqLOqww/zzMhlND3txurtYk0PKsGlWAuPw airvI2Yp4G2oAlM02XpzfcgYCv5KZlI= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-329-KZHMUeEyOIGPGZdX7S3ZHA-1; Thu, 25 Apr 2024 04:26:40 -0400 X-MC-Unique: KZHMUeEyOIGPGZdX7S3ZHA-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-51c23bafc49so567753e87.1 for ; Thu, 25 Apr 2024 01:26:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714033599; x=1714638399; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=kghZ7NSaCZFV0M/Xc1wvQWlGakuhyfaOna+6mlQjMq8=; b=CM3tc42M0sgBL0DHpg9MKF9scp54XiQA+ekcoHGsAuMpBuDUzC3qZdU4ZkjZXsnuuA v2da6dplx6rpjOzyCGlXmE1hcVDYIBCe+DK0JrIOB9AGOy7zIXeIo2VO8Ss9970I0WoQ dg2qprv8sHAYfUlExhRjJ4iJA0vfWzlYOlOkulGKJD904VdSNCKTKjo92ZWq6Zp+z9qn /tZ2bKbFzo2JlJdvJn31+bQPt0TIzQi3KnMrKl0fbuHdBpAT+lh4wYuuUDeraGZvNOih a0cZR/NvzFu8pywmXn3mWaatDie7TNcEUGlS8O1plCJAB6ZOegQjXX3Luwh1IXh2Xlom r9Bg== X-Forwarded-Encrypted: i=1; AJvYcCWppiI6/QynKMAQqEJ4ufhbKp1v/3yC7YQIZgEz3MEFOIWqMtfxTlq3hCiPU7DC9loLxS2xg0Bbs0bAI8xgdOFj0Gc= X-Gm-Message-State: AOJu0YyD6/BKDHJEzul529z0wGiSCSdIliLQHbY8gkuGI7NIryVh1Fho KSbZ+bXJIm0+C0EOuhR01qoMqpK87e3OrNJujdahTNYO0yXknT8rccnN1iUgpKH0X9vfnWGeqUd SxcwCBwqJM6hmF65HLiViShfbT5k8ASZUoLJx+W+PP1achX56 X-Received: by 2002:ac2:546b:0:b0:518:bc7c:413a with SMTP id e11-20020ac2546b000000b00518bc7c413amr3339053lfn.69.1714033599220; Thu, 25 Apr 2024 01:26:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2rDh0RbiLvH7tzPc1rSgUygrDqOW1pNu+SekelcV4r3SRYgkQVcOXmYKWzQEtVzxKo2Nzng== X-Received: by 2002:ac2:546b:0:b0:518:bc7c:413a with SMTP id e11-20020ac2546b000000b00518bc7c413amr3339022lfn.69.1714033598643; Thu, 25 Apr 2024 01:26:38 -0700 (PDT) Received: from ?IPV6:2003:cb:c719:8200:487a:3426:a17e:d7b7? (p200300cbc7198200487a3426a17ed7b7.dip0.t-ipconnect.de. [2003:cb:c719:8200:487a:3426:a17e:d7b7]) by smtp.gmail.com with ESMTPSA id z9-20020a05600c0a0900b0041668162b45sm29951027wmp.26.2024.04.25.01.26.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Apr 2024 01:26:38 -0700 (PDT) Message-ID: <94ae96f7-79ce-4b3f-a272-6af62d01a3f8@redhat.com> Date: Thu, 25 Apr 2024 10:26:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 0/5] add mTHP support for anonymous share pages To: Ryan Roberts , Baolin Wang , akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, wangkefeng.wang@huawei.com, 21cnbao@gmail.com, ying.huang@intel.com, shy828301@gmail.com, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <4b998e7d-153f-48cc-a9bb-8c84bb675581@arm.com> <80b5f87e-c156-4ccc-98f0-96f1fd864273@arm.com> <5b8b22e7-6355-4b08-b5b5-1e33ebae6f16@arm.com> <813fe7fd-3004-4e8b-801d-95c33559a025@linux.alibaba.com> <76f816dd-3bbf-48c9-a630-3787051cf289@arm.com> <8c0d6358-3c16-4a57-822c-04b3b3403fe6@linux.alibaba.com> <4204b5f6-21f0-4aa2-a625-3dd2f416b649@arm.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoFD/XSeVv jwBRNjPAubK9/k5NoRrYqztM9W6sJqrH8+UWZ1Idd/DdmogJh0gNC0+N42Za9yBRURfIdKSb B3JfpUqcWwE7vUaYrHG1nw54pLUoPG6sAA7Mehl3nd4pZUALHwARAQABzSREYXZpZCBIaWxk ZW5icmFuZCA8ZGF2aWRAcmVkaGF0LmNvbT7CwZgEEwEIAEICGwMGCwkIBwMCBhUIAgkKCwQW AgMBAh4BAheAAhkBFiEEG9nKrXNcTDpGDfzKTd4Q9wD/g1oFAl8Ox4kFCRKpKXgACgkQTd4Q 9wD/g1oHcA//a6Tj7SBNjFNM1iNhWUo1lxAja0lpSodSnB2g4FCZ4R61SBR4l/psBL73x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4204b5f6-21f0-4aa2-a625-3dd2f416b649@arm.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-Transfer-Encoding: 8bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 3990E4000C X-Stat-Signature: m49hcf4uzrwe4bne843dpjwraejmz7md X-Rspam-User: X-HE-Tag: 1714033603-802345 X-HE-Meta: U2FsdGVkX1+vKtShrxzBGE/fqULKmR69WmweF6Hhe7HxZNObaKBduHINlQh3Lk8ofTptLEGNoBR+bIyZsjK+HW6I3D85QH1g0RGdft+ysaSq6fJvQWPJvuB2LA247ovd7/SPp4otz2sMHa0xDMT475AOU3swEv7de8XkmXtLj0+qqHbh3M1vYHoupgbSLulsdHCzjsCrAPjhujDUSBweoe2UH1v3TdTTys/fx+k8ph2NwlaZLJ16c9T9TFUVuCVsmqopCSMUb6QZ4jxKbJ/ozY2MrMsenzCKMCXP02Jkmh91/ryBkmzKaHt1LBSV/XEadL4qsT+9gccBN8ngQ1UGaq4ZShRTyq241qVZ27OA1lDh5f56QhEKX3sJpJcN3gAwAyBpAt43ZmnjpOcVMKWT1dgWAiQlPriZRCcJzo9e5YXDVVXkVuQ5KHHN7WGP8kAeVXrFjFMp0pZU8FJZqP89Qkwako4On1SB36k5x8ZYg2ST9hSHsgQ0tIH53nmsH0wTNh0cLIhWowK3THVw8xkpke8/om5u4O24ZunmdyilseOP7rQhDU6MHEIVjQ9Lz6OEugwoxJgXdRFrUuTM7cYNsrvid9rGvLvqnu+G/mBGubOQ9j4UDq42hwXNKm4iTNHy3VDjcPZmzg3DogdWjfnCLifhN4Y/cj6Tp+vLEkhHZL29qoStguaVnWm4XwjDOeJbnLUzjbDnz140MGV2WY8ruwiXxJJtCgJ0fgpJx4zZgSK2IRPEw4os13J1VQhfVX+ruMYONKQHxxz7xAws03HNMnvqf8bJ44JXsNgIaYoozpQiPO6MeX5i8nYSR8wHjyylAqhGZPRIy103RvZv+d52Fec9BDRGQp96f1NEWXYzZJJ654FayEK3FRXXHdPx6lCxOH6c5Ijyl7LcktyZ15TfVnkODTCo9PJisuv3R8hcwOBVuV+PLSxkN/Dfu5ukAfnzKBRNK/+4QdmdDZPCxr0 ApIfGnQm mgdHprxWq3fOO8vwJt7nahaKOZFwEJr9cCE4D33YUXSQX1LREeNdjUbw9Kqv+QcusA+BWYsn2+Yd0/A2eYWAz3lXjfkgxdPOjb93eJ6r8m3aaRjJKQbL4D+iBUWXXVcsUPFwRUSNqxK9/mlBVWcATlqnyVH7aNlBO1kSwRX/8bYJDU7IzuRaP0iwtAjeNsRfv2YQwV4bULMgF/wGbux+AHFNnM4sVGAe/DQ/bBHBHDi+5LL9dY45ztPRsUyyYxKHV2vIzz8p4EQYdBj/Za6EkV2gHRg73j75fyVUEgXVD4lh7wwKWMAucIvybXx//Snx4oDZPy0/Meb0IAOkSKZpGoqsNBUt/lClc9WaBkCZRanSkNQhj0blVXh6qzfoRsogtc8N+u1Awi8BH40s3X/i2huzQDvIjs7Q9WjxN1RdgTt4nb4pqYzruK/1ptzMd97O+F6ZzsSwlTEF7ImX1GuKj15/OnsLQoqNkYXiI 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: List-Subscribe: List-Unsubscribe: On 25.04.24 10:17, Ryan Roberts wrote: > On 25/04/2024 07:20, Baolin Wang wrote: >> >> >> On 2024/4/24 22:20, Ryan Roberts wrote: >>> On 24/04/2024 14:49, Baolin Wang wrote: >>>> >>>> >>>> On 2024/4/24 18:01, Ryan Roberts wrote: >>>>> On 24/04/2024 10:55, Baolin Wang wrote: >>>>>> >>>>>> >>>>>> On 2024/4/24 16:26, Ryan Roberts wrote: >>>>>>> On 24/04/2024 07:55, Baolin Wang wrote: >>>>>>>> >>>>>>>> >>>>>>>> On 2024/4/23 18:41, Ryan Roberts wrote: >>>>>>>>> On 22/04/2024 08:02, Baolin Wang wrote: >>>>>>>>>> Anonymous pages have already been supported for multi-size (mTHP) >>>>>>>>>> allocation >>>>>>>>>> through commit 19eaf44954df, that can allow THP to be configured >>>>>>>>>> through the >>>>>>>>>> sysfs interface located at >>>>>>>>>> '/sys/kernel/mm/transparent_hugepage/hugepage-XXkb/enabled'. >>>>>>>>>> >>>>>>>>>> However, the anonymous shared pages will ignore the anonymous mTHP rule >>>>>>>>>> configured through the sysfs interface, and can only use the PMD-mapped >>>>>>>>>> THP, that is not reasonable. Many implement anonymous page sharing through >>>>>>>>>> mmap(MAP_SHARED | MAP_ANONYMOUS), especially in database usage scenarios, >>>>>>>>>> therefore, users expect to apply an unified mTHP strategy for anonymous >>>>>>>>>> pages, >>>>>>>>>> also including the anonymous shared pages, in order to enjoy the >>>>>>>>>> benefits of >>>>>>>>>> mTHP. For example, lower latency than PMD-mapped THP, smaller memory bloat >>>>>>>>>> than PMD-mapped THP, contiguous PTEs on ARM architecture to reduce TLB >>>>>>>>>> miss >>>>>>>>>> etc. >>>>>>>>> >>>>>>>>> This sounds like a very useful addition! >>>>>>>>> >>>>>>>>> Out of interest, can you point me at any workloads (and off-the-shelf >>>>>>>>> benchmarks >>>>>>>>> for those workloads) that predominantly use shared anon memory? >>>>>>>> >>>>>>>> As far as I know, some database related workloads make extensive use of >>>>>>>> shared >>>>>>>> anonymous page, such as PolarDB[1] in our Alibaba fleet, or MySQL likely >>>>>>>> also >>>>>>>> uses shared anonymous memory. And I still need to do some investigation to >>>>>>>> measure the performance. >>>>>>>> >>>>>>>> [1] https://github.com/ApsaraDB/PolarDB-for-PostgreSQL >>>>>>> >>>>>>> Thanks for the pointer! >>>>>>> >>>>>>>> >>>>>>>>>> The primary strategy is that, the use of huge pages for anonymous shared >>>>>>>>>> pages >>>>>>>>>> still follows the global control determined by the mount option "huge=" >>>>>>>>>> parameter >>>>>>>>>> or the sysfs interface at >>>>>>>>>> '/sys/kernel/mm/transparent_hugepage/shmem_enabled'. >>>>>>>>>> The utilization of mTHP is allowed only when the global 'huge' switch is >>>>>>>>>> enabled. >>>>>>>>>> Subsequently, the mTHP sysfs interface >>>>>>>>>> (/sys/kernel/mm/transparent_hugepage/hugepage-XXkb/enabled) >>>>>>>>>> is checked to determine the mTHP size that can be used for large folio >>>>>>>>>> allocation >>>>>>>>>> for these anonymous shared pages. >>>>>>>>> >>>>>>>>> I'm not sure about this proposed control mechanism; won't it break >>>>>>>>> compatibility? I could be wrong, but I don't think shmem's use of THP >>>>>>>>> used to >>>>>>>>> depend upon the value of /sys/kernel/mm/transparent_hugepage/enabled? So it >>>>>>>> >>>>>>>> Yes, I realized this after more testing. >>>>>>>> >>>>>>>>> doesn't make sense to me that we now depend upon the >>>>>>>>> /sys/kernel/mm/transparent_hugepage/hugepage-XXkb/enabled values (which by >>>>>>>>> default disables all sizes except 2M, which is set to "inherit" from >>>>>>>>> /sys/kernel/mm/transparent_hugepage/enabled). >>>>>>>>> >>>>>>>>> The other problem is that shmem_enabled has a different set of options >>>>>>>>> (always/never/within_size/advise/deny/force) to enabled >>>>>>>>> (always/madvise/never) >>>>>>>>> >>>>>>>>> Perhaps it would be cleaner to do the same trick we did for enabled; >>>>>>>>> Introduce >>>>>>>>> /mm/transparent_hugepage/hugepage-XXkb/shmem_enabled, which can have all >>>>>>>>> the >>>>>>>>> same values as the top-level >>>>>>>>> /sys/kernel/mm/transparent_hugepage/shmem_enabled, >>>>>>>>> plus the additional "inherit" option. By default all sizes will be set to >>>>>>>>> "never" except 2M, which is set to "inherit". >>>>>>>> >>>>>>>> Sounds good to me. But I do not want to copy all same values from top-level >>>>>>>> '/sys/kernel/mm/transparent_hugepage/shmem_enabled': >>>>>>>> always within_size advise never deny force >>>>>>>> >>>>>>>> For mTHP's shmem_enabled interface, we can just keep below values: >>>>>>>> always within_size advise never >>>>>>>> >>>>>>>> Cause when checking if mTHP can be used for anon shmem, 'deny' is equal to >>>>>>>> 'never', and 'force' is equal to 'always'. >>>>>>> >>>>>>> I'll admit it wasn't completely clear to me after reading the docs, but my >>>>>>> rough >>>>>>> understanding is: >>>>>>> >>>>>>>     - /sys/kernel/mm/transparent_hugepage/shmem_enabled controls >>>>>>>       mmap(SHARED|ANON) allocations (mostly; see rule 3) >>>>>>>     - huge=... controls tmpfs allocations >>>>>>>     - deny and force in shmem_enabled are equivalent to never and always for >>>>>>>       mmap(SHARED|ANON) but additionally override all tmpfs mounts so they >>>>>>> act as >>>>>>>       if they were mounted with huge=never or huge=always >>>>>>> >>>>>>> Is that correct? If so, then I think it still makes sense to support per-size >>>>>> >>>>>> Correct. >>>>>> >>>>>>> deny/force. Certainly if a per-size control is set to "inherit" and the >>>>>>> top-level control is set to deny or force, you would need that to mean >>>>>>> something. >>>>>> >>>>>> IMHO, the '/mm/transparent_hugepage/hugepage-XXkb/shmem_enabled' interface >>>>>> should only control the anonymous shmem. And 'huge=' controls tmpfs >>>>>> allocation, >>>>>> so we should not use anonymous control to override tmpfs control, which >>>>>> seems a >>>>>> little mess? >>>>> >>>>> I agree it would be cleaner to only handle mmap(SHARED|ANON) here, and leave >>>>> the >>>>> tmpfs stuff for another time. But my point is that >>>>> /mm/transparent_hugepage/shmem_enabled already interferes with tmpfs if the >>>>> value is deny or force. So if you have: >>>>> >>>>> echo deny > /mm/transparent_hugepage/shmem_enabled >>>> >>>> IIUC, this global control will cause shmem_is_huge() to always return false, so >>>> no matter how '/mm/transparent_hugepage/hugepage-xxxkB/shmem_enabled' is set, >>>> anonymous shmem will not use mTHP. No? >>> >>> No, that's not how '/mm/transparent_hugepage/hugepage-xxxkB/enabled' works, and >>> I think '/mm/transparent_hugepage/hugepage-xxxkB/shmem_enabled' should follow >>> the established pattern. >>> >>> For anon-private, each size is controlled by its >>> /mm/transparent_hugepage/hugepage-xxxkB/enabled value. Unless that value is >>> "inherit", in which case the value in /mm/transparent_hugepage/enabled is used >>> for that size. >>> >>> That approach enables us to 1) maintain back-compat and 2) control each size >>> independently >>> >>> 1) is met because the default is that all sizes are initially set to "never", >>> except the PMD-size (e.g. /mm/transparent_hugepage/hugepage-2048kB/enabled) >>> which is initially set to inherit. So any mTHP unaware SW can still modify >>> /mm/transparent_hugepage/enabled and it will still only apply to PMD size. >>> >>> 2) is met because mTHP aware SW can come along and e.g. enable the 64K size >>> (echo always > /mm/transparent_hugepage/hugepage-64kB/enabled) without having to >>> modify the value in /mm/transparent_hugepage/enabled. >> >> Thanks for explanation. Initially, I want to make >> ‘/mm/transparent_hugepage/shmem_enabled’ be a global control for huge page, but >> I think it should follow the same strategy as anon mTHP as you said. >> >>>>> echo inherit > /mm/transparent_hugepage/hugepage-64kB/shmem_enabled >>>>> >>>>> What does that mean? >>> >>> So I think /mm/transparent_hugepage/hugepage-xxxkB/shmem_enabled will need to >>> support the deny and force values. When applied to non-PMD sizes, "deny" can >>> just be a noop for now, because there was no way to configure a tmpfs mount for >>> non-PMD size THP in the first place. But I'm not sure what to do with "force"? >> >> OK. And I also prefer that "force" should be a noop too, since anon shmem >> control should not configure tmpfs huge page allocation. > > I guess technically they won't be noops, but (for the non-PMD-sizes) "force" > will be an alias for "always" and "deny" will be an alias for "never"? > > I was just a bit concerned about later changing that behavior to also impact > tmpfs once tmpfs supports mTHP; could that cause breaks? But thinking about it, > I don't see that as a problem. Is the question what should happen if we "inherit" "force" or if someone specifies "force" for a mTP size explicitly? -- Cheers, David / dhildenb