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 95ABFD2AB35 for ; Tue, 29 Oct 2024 12:21:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC2D56B0098; Tue, 29 Oct 2024 08:21:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E72D36B0099; Tue, 29 Oct 2024 08:21:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CEC3D6B009A; Tue, 29 Oct 2024 08:21:06 -0400 (EDT) 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 AFDAA6B0098 for ; Tue, 29 Oct 2024 08:21:06 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4F2BF410ED for ; Tue, 29 Oct 2024 12:21:06 +0000 (UTC) X-FDA: 82726547652.20.5033213 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 84EB7180003 for ; Tue, 29 Oct 2024 12:20:38 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CovoGUxj; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.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=1730204288; 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=gPPs0+CUPj5G4mr0G9qtS6gLC/HhMtUnQLQJptozAAA=; b=Z3Wpi1wasnpfxvgzOmuh2RlemBC9+vTAGRzBhs5NxL8fuIxYKeQ3A10fMoewVp/dgjls64 8Q1FzjpjwtTgioerY4LW4+vTrF9afoktCSo3675wcHiQfdXoq8d4hikPZn3dQVyMkBkqld EjJ6oBUxRuhDIQr+OEI6149XF0Iq0cU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730204288; a=rsa-sha256; cv=none; b=cWMC+pXQGIFzKWUzpeAJHbOi3unbuGcd40YVbsvR/LJ64972foq3jwwu5zKKY/wAgOymsb R7aNIDKsF9yq/O5C5Vr0nNHm/MMP1zJ9Eu2gMiwul9rxK3vl+Ml4bnNFIaeKAKUDz7LmHr V9WnN1tMxosFJLOXeg8prSCbPPKCuxE= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CovoGUxj; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730204462; 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=gPPs0+CUPj5G4mr0G9qtS6gLC/HhMtUnQLQJptozAAA=; b=CovoGUxjaKqaIluGQMAgYoiRu3ofcMXmq9Tojo96oa0055q6haVOhKAhzuHeytj1EyO2cQ G194yGMO7pefaprp3Y1S2TOMenNAriRWHvSJdKx0MKzYMtru0LxlktkzXISnPvOemyHko0 QB5PFCqS++UKVSL3eRyBy1Dz1UuK/zI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-299-7-XNS539NKeyfBM9DcYxXw-1; Tue, 29 Oct 2024 08:20:59 -0400 X-MC-Unique: 7-XNS539NKeyfBM9DcYxXw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d4922d8c7so2976100f8f.1 for ; Tue, 29 Oct 2024 05:20:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730204458; x=1730809258; 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=gPPs0+CUPj5G4mr0G9qtS6gLC/HhMtUnQLQJptozAAA=; b=iml0AX6s/p9plRQL6QWaAkZ7m6DqQx8lrqh98XeIOb/kXilzQMSFzKOX183VavjQP6 SJeOneeVpoyqv22xmG+KsGmbhdbSPbqhgKdL6W/QJ/0ltn7MajiZ0Uw7pCEkJpkO/cjE ddEoB9IICH5vFcOTS8AB5N4tohIl5LMpwoeFPhvziW+ztZjdScSKhxXlLgSWiShLav21 wG/995TkUzX2VJpUm6L3kuG3WrbbCLCVGpbBbG3DRGJ097pwqiEh0vOvpCkdNX6Mu0BM f42ammnP+NH0FUCA+DoZvyMHh75Nu4HDQtOLvUgNdV9Y5freXdwZBsqnwrqLixmHn5QN 7yCQ== X-Forwarded-Encrypted: i=1; AJvYcCXQ+mixzo9AqO88ESqBM59QOU1atps67rIGzEMO9xiroXkfzsHZq94ZaliT1U2QcWOUJNrP4TYvAg==@kvack.org X-Gm-Message-State: AOJu0Yz8t8T1TvjKDio6RtwmUxkAaIxQXzFzQq5dEN9zoOJPwB45rphy sRomDTlSuAYZdFoZ5rP2mrhCiqgllI3adKJAgnh93oAqw32WNsb9mDy4FYPgZorzEdfkkABIoX8 jrbQ62GaEJop5U1AVvGvKRJklorNy9qpBKMVcGg+shqQoioOI X-Received: by 2002:adf:e58f:0:b0:37c:babe:2c49 with SMTP id ffacd0b85a97d-38061128ef1mr7604533f8f.19.1730204457936; Tue, 29 Oct 2024 05:20:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJbMMeDjIu1DI5jNTZEhmaFaxxbUnwOb2nMscklDaVJq5aebRKgtU65pH7ernvrB290cCtgg== X-Received: by 2002:adf:e58f:0:b0:37c:babe:2c49 with SMTP id ffacd0b85a97d-38061128ef1mr7604507f8f.19.1730204457422; Tue, 29 Oct 2024 05:20:57 -0700 (PDT) Received: from ?IPV6:2003:cb:c72d:8500:d87a:ed8e:1e80:5a7e? (p200300cbc72d8500d87aed8e1e805a7e.dip0.t-ipconnect.de. [2003:cb:c72d:8500:d87a:ed8e:1e80:5a7e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b47f6fsm12331687f8f.50.2024.10.29.05.20.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Oct 2024 05:20:56 -0700 (PDT) Message-ID: Date: Tue, 29 Oct 2024 13:20:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v3 0/4] Support large folios for tmpfs To: Daniel Gomez , Baolin Wang , Daniel Gomez , "Kirill A. Shutemov" Cc: Matthew Wilcox , akpm@linux-foundation.org, hughd@google.com, wangkefeng.wang@huawei.com, 21cnbao@gmail.com, ryan.roberts@arm.com, ioworker0@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A . Shutemov" References: <6dohx7zna7x6hxzo4cwnwarep3a7rohx4qxubds3uujfb7gp3c@2xaubczl2n6d> <8e48cf24-83e1-486e-b89c-41edb7eeff3e@linux.alibaba.com> <486a72c6-5877-4a95-a587-2a32faa8785d@redhat.com> <7eb412d1-f90e-4363-8c7b-072f1124f8a6@linux.alibaba.com> <1b0f9f94-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IuCL4YjVoylWiBNknvQWBXS lQCWmavOT9sttGQXdPCC5ynI+1ymZC1ORZKANLnRAb0NH/UCzcsstw2TAkFnMEbo9Zu9w7Kv AxBQXWeXhJI9XQssfrf4Gusdqx8nPEpfOqCtbbwJMATbHyqLt7/oz/5deGuwxgb65pWIzufa N7eop7uh+6bezi+rugUI+w6DABEBAAHCwXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/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: 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 84EB7180003 X-Stat-Signature: kd4obkopyfqrskfddsefoizgotx3nt4i X-Rspam-User: X-HE-Tag: 1730204438-912339 X-HE-Meta: U2FsdGVkX1+5IUmfwX2DAs64JfdHv6k3KtvoDNO0anIvKBj73XmUmleNjgpknBizXoItj/TqY3BxmiUxLrGPsKt4zDAFAu5IT7y6AtYI5VdnOhlwGCVq5hqq87BxRrzvoNNcwKjC/3P0BAbl8j8wxlmQg8x/PL8QYGfswfG9JeB4oQTCcR5jFu3gIRTwXlwRGuLco40bkBkZ9lzWF/Al/iI49yHNxTJQIh60+VtoFbQaNO5IraPun2CWUzfRlgira8fEnRMvuadyqxb+axrD86nFLvpN+Ny1R5/F2dtqQGjFygVc7KRUTXzsb3OUyj4EYVkjm0ecIpwxS27+dkjegbO3wzQEkcePGhj356dGHx+OBB/KBI9vrH7UZamVKOZScasK5E99xWLg7kCvUDiERvFWihUTxlHAaOVyEY7d0tlG3TM6dTMFRgZE1BlslEvOGwd+9DbPWE7+e41LKp6zEQzUdRCuKtb13R8Cu5zjU/pUS3f45SxHy213PW8j6SbPYbhcKCNpxl2cgYduVqyp3XP5XkZM+FEPobohraSpvC3AM7ASPLI+rKBnJAGZDn68927oKl6jDLH4JZTWwleKdhZKLk1w5rBvFtHNQAd1q6PLWFPtFq8o/EDEUp96HoyHqq0v8VmLihaBV4Z9dvWWnqaKDL9fwTh/wc5kXSIRVhei5ZND8b46eH4ZYaUGzpiccj5wVUMnwzTI4wC8zLZVcZqLTr5pZgx7m7+qjO9GczRL3uymgYj85/WLr/Ao5zKw3TpRM7lsmryURgABNARfrt+iF8WiCt5MyZzuMomz/McZbeCH1fqIU+pNuTqPAdyy89tJklEiMvAK/MERjtLY5c908r9dmi/s1bjOBD6+mQeeQwJObH7OlJnp1YjtQVKWmq99R80HkIRtIySFeNpouw4pTVlg5boLUiEjfk96L1UYawXymKDRKp8jEzp7k6Tk9zm/jJRzU5u/rCbRYnw H3cxwGRK D7yoOQXGW/3XbvukulNwTIHiPdeeminNGlvteD9kPuvOcKSrhStrBTO1C5MPnRPNQ8FwyshsfFft+gIr1nC8GBWhC/UDj+7Zsk8AHq497xPDAV9bWWd1GNZQJJSthJ8fJqs4EdxdIYHMqtnaFTDClqmegFZBA4bIWN3tY903EwvEH+rc274IwdPPgcK3pVeIvVeo9+Y0r2bO6JcBE3x9l7geZ3cq0ZqRxuDj/69F2bC65uIIKSXE8huyiRxEa+v13oX/krcIR67sxa1FTGapdksbSeVO8pClQDQim1LhGnY6Xn76d66eh4cNY+BBIONg9XUlgLfszCk3wgHXOFIkuy/qrSp0OU9Jin4e0HulPSwkcaHzoP+ZVxcwsfkJFBayBHb6r3lpKqZyiD2jneiL7oExYGQ== 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 28.10.24 22:56, Daniel Gomez wrote: > On Fri Oct 25, 2024 at 10:21 PM CEST, David Hildenbrand wrote: >> Sorry for the late reply! >> >>>>>>> IMHO, as I discussed with Kirill, we still need maintain compatibility >>>>>>> with the 'huge=' mount option. This means that if 'huge=never' is set >>>>>>> for tmpfs, huge page allocation will still be prohibited (which can >>>>>>> address Hugh's request?). However, if 'huge=' is not set, we can >>>>>>> allocate large folios based on the write size. >>> >>> So, in order to make tmpfs behave like other filesystems, we need to >>> allocate large folios by default. Not setting 'huge=' is the same as >>> setting it to 'huge=never' as per documentation. But 'huge=' is meant to >>> control THP, not large folios, so it should not have a conflict here, or >>> else, what case are you thinking? >> >> I think we really have to move away from "huge/thp == PMD", that's a >> historical artifact. Everything else will simply be inconsistent and >> confusing in the future -- and I don't see any real need for that. For >> anonymous memory and anon shmem we managed the transition. (there is a >> longer writeup from me about this topic, so I won't go into detail). >> >> >> I think I raised this in the past, but tmpfs/shmem is just like any >> other file system .. except it sometimes really isn't and behaves much >> more like (swappable) anonymous memory. (or mlocked files) >> >> There are many systems out there that run without swap enabled, or with >> extremely minimal swap (IIRC until recently kubernetes was completely >> incompatible with swapping). Swap can even be disabled today for shmem >> using a mount option. >> >> That's a big difference to all other file systems where you are >> guaranteed to have backend storage where you can simply evict under >> memory pressure (might temporarily fail, of course). >> >> I *think* that's the reason why we have the "huge=" parameter that also >> controls the THP allocations during page faults (IOW possible memory >> over-allocation). Maybe also because it was a new feature, and we only >> had a single THP size. >> >> There is, of course also the "fallocate() might not free up memory if >> there is an unexpected reference on the page because splitting it will >> fail" problem, that even exists when not over-allocating memory in the >> first place ... >> >> >> So ...I don't think tmpfs behaves like other file system in some cases. >> And I don't think ignoring these points is a good idea. > > Assuming a system without swap, what's the difference you are concern > about between using the current tmpfs allocation method vs large folios > implementation? As raised above, there is the interesting interaction between fallocate(FALLOC_FL_PUNCH_HOLE) and raised refcounts, where we can fail to reclaim memory. shmem_fallocate()->shmem_truncate_range()->truncate_inode_pages_range()->truncate_inode_partial_folio(). It's better than it was in the past -- in the past we didn't even try splitting, but today splitting can still fail and we'll never try reclaiming that memory again later. This is very different to anonymous memory where we have the deferred split queue+remember which pages where zapped implicitly using the page tables (instead of zeroing them out and not freeing up the memory). It's one of the issues people ran into when using THP+shmem for backing guest VMs along with memory ballooning. For that reason, the recommendation still is to disable THP when using shmem for backing guest VMs and relying on memory overcommit optimizations such as memory balloon inflation. > >> >> Fortunately I don't maintain that code :) >> >> >> If we don't want to go with the shmem_enabled toggles, we should >> probably still extend the documentation to cover "all THP sizes", like >> we did elsewhere. >> >> huge=never: no THPs of any size >> huge=always: THPs of any size (fault/write/etc) >> huge=fadvise: like "always" but only with fadvise/madvise >> huge=within_size: like "fadvise" but respect i_size >> >> We could think about adding a "nowaste" extension and try make it the >> default. >> >> For example >> >> "huge=always:nowaste: THPs of any size as long as we don't over-allocate >> memory (write)" > > This is the default behaviour in other fs too. I don't think is > necessary to make it explicit. Please keep in mind that allocating THPs of different size during *page faults* will have to fit into the whole picture we are creating here. That's also what "huge=always" controls for shmem today IIRC. >>> >>>>>> >>>>>> I consider allocating large folios in shmem/tmpfs on the write path less >>>>>> controversial than allocating them on the page fault path -- especially >>>>>> as long as we stay within the size to-be-written. >>>>>> >>>>>> I think in RHEL THP on shmem/tmpfs are disabled as default (e.g., >>>>>> shmem_enabled=never). Maybe because of some rather undesired >>>>>> side-effects (maybe some are historical?): I recall issues with VMs with >>>>>> THP+ memory ballooning, as we cannot reclaim pages of folios if >>>>>> splitting fails). I assume most of these problematic use cases don't use >>>>>> tmpfs as an ordinary file system (write()/read()), but mmap() the whole >>>>>> thing. >>>>>> >>>>>> Sadly, I don't find any information about shmem/tmpfs + THP in the RHEL >>>>>> documentation; most documentation is only concerned about anon THP. >>>>>> Which makes me conclude that they are not suggested as of now. >>>>>> >>>>>> I see more issues with allocating them on the page fault path and not >>>>>> having a way to disable it -- compared to allocating them on the write() >>>>>> path. >>>>> >>>>> I may not understand your issues. IIUC, you can disable allocating huge >>>>> pages on the page fault path by using the 'huge=never' mount option or >>>>> setting shmem_enabled=deny. No? >>>> >>>> That's what I am saying: if there is some way to disable it that will >>>> keep working, great. >>> >>> I agree. That aligns with what I recall Hugh requested. However, I >>> believe if that is the way to go, we shouldn't limit it to tmpfs. >>> Otherwise, why should tmpfs be prevented from allocating large folios if >>> other filesystems in the system are allowed to allocate them? >> >> See above. On systems without/little swap you might not want them for >> shmem/tmpfs, but would happily use them elsewhere. >> >> The "write() won't waste memory" case is really interesting, the >> "fallocate cannot free the memory" still exists. A shrinker might help. > > The previous implementation with large folios allocation was wrong > and was actually wasting memory by rounding up while trying to find > the order. Matthew already pointed it out [1]. So, with that fixed, we > should not end up wasting memory. Again, we should have a clear path forward how we deal with page faults and how this fits into the picture. -- Cheers, David / dhildenb