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 0773BC07E97 for ; Wed, 29 Nov 2023 08:05:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 841918D001A; Wed, 29 Nov 2023 03:05:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C6D98D0001; Wed, 29 Nov 2023 03:05:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61B8D8D001A; Wed, 29 Nov 2023 03:05:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4AF5F8D0001 for ; Wed, 29 Nov 2023 03:05:42 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1DD24120491 for ; Wed, 29 Nov 2023 08:05:42 +0000 (UTC) X-FDA: 81510257724.20.C5B4140 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id B3F2C180017 for ; Wed, 29 Nov 2023 08:05:39 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=equ92SFD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701245139; 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=8v095EuMzzISmu5Y1f0aoY1vTTbA82jShxtCDF/8mD4=; b=oCgoggJwhNZ3UyNxntsrozTUIA7F04DpZ/3oypMbl9rncGsZeXcyL8+Ql6xfHzlOGFnvaG 4ZpDEgUKMVz7o0DMrNdiSzbQRQWQelqtBLv4c/AHyYxJO3RW9yo+cmjy71zPT4jpGbCMej Dc8Dgjfdf3QNAM/i8kH+IhxrMz8iero= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=equ92SFD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701245139; a=rsa-sha256; cv=none; b=G+fqWCTWK0v/q8F1SaUJJi1eQEJfgrP/rCaN7yCz+mX7qqkuq/U0NnhDVEodL1GEsVl34d ev9VcAlWn68NsLf9RvaR46aiq/VJ9FwlgokJMYNIB+1uWLT5UF78yEx/czERUzfFclhmrP ZLim8TOK9a3kcBMWXjricZbZ6NCLtpw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701245139; 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=8v095EuMzzISmu5Y1f0aoY1vTTbA82jShxtCDF/8mD4=; b=equ92SFDhlhyH3yJJxVkwjXK5RwZ/XXnbTuSgXRmes2ZRS6PVO819F4NONFvx1WG7UEYZK eNdHnRR+VkMT9tD3krd70kvsoAqIh4/uA9aInTnCje0wNfXDqJ+HmkQbjnsl3WyvAUNxd4 HlSS9fEDykxsdso4BPBfvoOBdCAHFDc= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-503-KMA4y2EeMfKs5ULFZzNQzA-1; Wed, 29 Nov 2023 03:05:35 -0500 X-MC-Unique: KMA4y2EeMfKs5ULFZzNQzA-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-333120f8976so931317f8f.3 for ; Wed, 29 Nov 2023 00:05:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701245134; x=1701849934; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language: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=8v095EuMzzISmu5Y1f0aoY1vTTbA82jShxtCDF/8mD4=; b=g872IXF6NSRIQY6OPTs1SHEjhqdHvuQIXggtaT0SRXGQXPNevVMgeHPwl5aHpgeTTR SB3hY9ifjGDo/uS6MNtQEZgh27RSgsRzQB7JoSre0P8zTfJBQ3g60UKxgeWDTfKgASW8 uGLrab0J70yDwRgx5rJmC9ltXIee+lodJIyfUV+s9HkK+NUkkEiM+LV2SYGhP5+cBZBM g2KksoyLrmIGBXKkE6j3ZupL1MvMiVyWZKvm5icpuypUG4IteAp+7UQ5WfqRU1GnHTZD ZNGgMbVwcnHIA81nF0NpkEwkF+5O1qq0l/ZsSMJakiha5C0pwOCxfjwHgt9taMweS1gE 5p/A== X-Gm-Message-State: AOJu0YzywGSmxpG7EQO+3CdiKle9R+PebiU81RbhkzXbC0Kc5/D+OTAv UsEV0M5HSMR6rfEwJPZ58l/SyeuHaqd2AYNSXk539f1Pjg8VacSafAGYdnBj8MGMZh6c5Q8OpP8 sM6zSmYl+Myw= X-Received: by 2002:a5d:40c8:0:b0:332:ca80:a9ea with SMTP id b8-20020a5d40c8000000b00332ca80a9eamr15317541wrq.41.1701245134060; Wed, 29 Nov 2023 00:05:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IEH+cIaBxAciCd2fsZSq+1PDb19SejhgJa0v9lNP3Bybizd9hcikvV8V3BG6r7q69GN1MF/Aw== X-Received: by 2002:a5d:40c8:0:b0:332:ca80:a9ea with SMTP id b8-20020a5d40c8000000b00332ca80a9eamr15317508wrq.41.1701245133531; Wed, 29 Nov 2023 00:05:33 -0800 (PST) Received: from ?IPV6:2003:cb:c710:f600:634b:35f:ffa8:475b? (p200300cbc710f600634b035fffa8475b.dip0.t-ipconnect.de. [2003:cb:c710:f600:634b:35f:ffa8:475b]) by smtp.gmail.com with ESMTPSA id df2-20020a5d5b82000000b0032fbe5b1e45sm16817600wrb.61.2023.11.29.00.05.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Nov 2023 00:05:33 -0800 (PST) Message-ID: Date: Wed, 29 Nov 2023 09:05:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RESEND PATCH v7 03/10] mm: thp: Introduce per-size thp sysfs interface To: John Hubbard , Ryan Roberts , Andrew Morton , Matthew Wilcox , Yin Fengwei , 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 , Kefeng Wang Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20231122162950.3854897-1-ryan.roberts@arm.com> <20231122162950.3854897-4-ryan.roberts@arm.com> <1a738e0a-ac11-4cd3-be2f-6b6e7cb4980a@nvidia.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8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wXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <1a738e0a-ac11-4cd3-be2f-6b6e7cb4980a@nvidia.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: 7bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B3F2C180017 X-Stat-Signature: bosruoctdat7jabn8pgtz83g1ao6kmnt X-HE-Tag: 1701245139-488601 X-HE-Meta: U2FsdGVkX18GdDGZw6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rejfCAz6/e9pVHTyEtpIz7o3C86jGuKiMBje7v7Q9xFXOnH1CUGMGRenII6yrRAB1t72uZx4ziojUy1s09hKOjkyCjV/pTi7W2Nai/8hFOMsLWwKNi6b/vZmmiET1HWtxC93ChFQdxhFECkmp5L6jh3xvZgWXpOkNGNOM2ES5Z3SypM6OlUzlRFmJ4vYvSWE1ss3LA9EtlBhgENdTmUiWmXjKGbgseGS4JTAPFJOfCc6WTMNconfKliUAwowzXSpELPT8mj4OsRyerGIlhH98+2PvVvPmRzjlIDDNI7fXQHv32nh6JDe/i2iuSK12NERfUYkRmwvviHzyvY9gOWq2ZkkSMIuGe5Yb9w46ktC6A88Zefqmv/xWuLsevtOa46q+t9AYO0ryyCMqaK2dXm8ZFNDav74+WArnyQgCoLPQomWOsJNK7BCkQ2HgzwJ6NCUzoVnMX3dssQ92bjcPEV6DVMHpKJiYoG0f2GUS030lB7d5+A== 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 29.11.23 04:42, John Hubbard wrote: > On 11/22/23 08:29, Ryan Roberts wrote: >> In preparation for adding support for anonymous small-sized THP, >> introduce new sysfs structure that will be used to control the new >> behaviours. A new directory is added under transparent_hugepage for each >> supported THP size, and contains an `enabled` file, which can be set to >> "global" (to inherrit the global setting), "always", "madvise" or >> "never". For now, the kernel still only supports PMD-sized anonymous >> THP, so only 1 directory is populated. >> >> The first half of the change converts transhuge_vma_suitable() and >> hugepage_vma_check() so that they take a bitfield of orders for which >> the user wants to determine support, and the functions filter out all >> the orders that can't be supported, given the current sysfs >> configuration and the VMA dimensions. If there is only 1 order set in >> the input then the output can continue to be treated like a boolean; >> this is the case for most call sites. >> >> The second half of the change implements the new sysfs interface. It has >> been done so that each supported THP size has a `struct thpsize`, which >> describes the relevant metadata and is itself a kobject. This is pretty >> minimal for now, but should make it easy to add new per-thpsize files to >> the interface if needed in future (e.g. per-size defrag). Rather than >> keep the `enabled` state directly in the struct thpsize, I've elected to >> directly encode it into huge_anon_orders_[always|madvise|global] >> bitfields since this reduces the amount of work required in >> transhuge_vma_suitable() which is called for every page fault. >> >> The remainder is copied from Documentation/admin-guide/mm/transhuge.rst, >> as modified by this commit. See that file for further details. >> >> Transparent Hugepage Support for anonymous memory can be entirely >> disabled (mostly for debugging purposes) or only enabled inside >> MADV_HUGEPAGE regions (to avoid the risk of consuming more memory >> resources) or enabled system wide. This can be achieved >> per-supported-THP-size with one of:: >> >> echo always >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled >> echo madvise >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled >> echo never >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled >> >> where is the hugepage size being addressed, the available sizes >> for which vary by system. Alternatively it is possible to specify that >> a given hugepage size will inherrit the global enabled setting:: >> >> echo global >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled >> >> The global (legacy) enabled setting can be set as follows:: >> >> echo always >/sys/kernel/mm/transparent_hugepage/enabled >> echo madvise >/sys/kernel/mm/transparent_hugepage/enabled >> echo never >/sys/kernel/mm/transparent_hugepage/enabled >> >> By default, PMD-sized hugepages have enabled="global" and all other >> hugepage sizes have enabled="never". If enabling multiple hugepage >> sizes, the kernel will select the most appropriate enabled size for a >> given allocation. >> >> Signed-off-by: Ryan Roberts >> --- >> Documentation/admin-guide/mm/transhuge.rst | 74 ++++-- >> Documentation/filesystems/proc.rst | 6 +- >> fs/proc/task_mmu.c | 3 +- >> include/linux/huge_mm.h | 100 +++++--- >> mm/huge_memory.c | 263 +++++++++++++++++++-- >> mm/khugepaged.c | 16 +- >> mm/memory.c | 6 +- >> mm/page_vma_mapped.c | 3 +- >> 8 files changed, 387 insertions(+), 84 deletions(-) >> >> diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst >> index b0cc8243e093..52565e0bd074 100644 >> --- a/Documentation/admin-guide/mm/transhuge.rst >> +++ b/Documentation/admin-guide/mm/transhuge.rst >> @@ -45,10 +45,23 @@ components: >> the two is using hugepages just because of the fact the TLB miss is >> going to run faster. >> >> +As well as PMD-sized THP described above, it is also possible to >> +configure the system to allocate "small-sized THP" to back anonymous > > Here's one of the places to change to the new name, which lately is > "multi-size THP", or mTHP or m_thp for short. (I've typed "multi-size" > instead of "multi-sized", because the 'd' doesn't add significantly to > the meaning, and if in doubt, shorter is better. > > >> +memory (for example 16K, 32K, 64K, etc). These THPs continue to be >> +PTE-mapped, but in many cases can still provide similar benefits to >> +those outlined above: Page faults are significantly reduced (by a >> +factor of e.g. 4, 8, 16, etc), but latency spikes are much less >> +prominent because the size of each page isn't as huge as the PMD-sized >> +variant and there is less memory to clear in each page fault. Some >> +architectures also employ TLB compression mechanisms to squeeze more >> +entries in when a set of PTEs are virtually and physically contiguous >> +and approporiately aligned. In this case, TLB misses will occur less >> +often. >> + > > OK, all of the above still seems like it can remain the same. > >> THP can be enabled system wide or restricted to certain tasks or even >> memory ranges inside task's address space. Unless THP is completely >> disabled, there is ``khugepaged`` daemon that scans memory and >> -collapses sequences of basic pages into huge pages. >> +collapses sequences of basic pages into PMD-sized huge pages. >> >> The THP behaviour is controlled via :ref:`sysfs ` >> interface and using madvise(2) and prctl(2) system calls. >> @@ -95,12 +108,29 @@ Global THP controls >> Transparent Hugepage Support for anonymous memory can be entirely disabled >> (mostly for debugging purposes) or only enabled inside MADV_HUGEPAGE >> regions (to avoid the risk of consuming more memory resources) or enabled >> -system wide. This can be achieved with one of:: >> +system wide. This can be achieved per-supported-THP-size with one of:: >> + >> + echo always >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled >> + echo madvise >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled >> + echo never >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled >> + >> +where is the hugepage size being addressed, the available sizes >> +for which vary by system. Alternatively it is possible to specify that >> +a given hugepage size will inherrit the global enabled setting:: > > typo: inherrit > >> + >> + echo global >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled >> + >> +The global (legacy) enabled setting can be set as follows:: >> >> echo always >/sys/kernel/mm/transparent_hugepage/enabled >> echo madvise >/sys/kernel/mm/transparent_hugepage/enabled >> echo never >/sys/kernel/mm/transparent_hugepage/enabled >> >> +By default, PMD-sized hugepages have enabled="global" and all other >> +hugepage sizes have enabled="never". If enabling multiple hugepage >> +sizes, the kernel will select the most appropriate enabled size for a >> +given allocation. >> + > > This is slightly murky. I wonder if "inherited" is a little more directly > informative than global; it certainly felt that way my first time running > this and poking at it. > > And a few trivial examples would be a nice touch. > > And so overall with a few other minor tweaks, I'd suggest this: > > ... > where is the hugepage size being addressed, the available sizes > for which vary by system. > > For example: > echo always >/sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabled > > Alternatively it is possible to specify that a given hugepage size will inherit > the top-level "enabled" value: > > echo inherited >/sys/kernel/mm/transparent_hugepage/hugepages-kB/enabled > > For example: > echo inherited >/sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabled > > The top-level setting (for use with "inherited") can be by issuing one of the > following commands:: > > echo always >/sys/kernel/mm/transparent_hugepage/enabled > echo madvise >/sys/kernel/mm/transparent_hugepage/enabled > echo never >/sys/kernel/mm/transparent_hugepage/enabled > > By default, PMD-sized hugepages have enabled="inherited" and all other > hugepage sizes have enabled="never". "inherited" works for me as well. -- Cheers, David / dhildenb