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 4680EC83F1A for ; Thu, 17 Jul 2025 08:22:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C153E8D0002; Thu, 17 Jul 2025 04:22:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BECFB8D0001; Thu, 17 Jul 2025 04:22:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B02948D0002; Thu, 17 Jul 2025 04:22:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A25728D0001 for ; Thu, 17 Jul 2025 04:22:58 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DE3171106A8 for ; Thu, 17 Jul 2025 08:22:57 +0000 (UTC) X-FDA: 83673065994.19.339F78C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 6E0E61C000B for ; Thu, 17 Jul 2025 08:22:55 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Bh05Yzsm; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752740575; a=rsa-sha256; cv=none; b=oBiwq+vFRi0mkLYpTLdE//fOaz+sNV0sm8cVvhpbU+Lnln9BGpWaamjHxDFugZOutiQ76q flwm7SnD0ISXlMHKjh5YNT8l8XWPQ6ldzOvS1Teh7D9ep1nJZZ1j5RsJXzLj9895Sp/dtJ ycQzmsZal5BQP8jU/cu8IMKjLFYx1Ng= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Bh05Yzsm; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of david@redhat.com designates 170.10.133.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=1752740575; 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=2mqJS3et2ZSRNW2i5XCwL2/M6iyAhSDP2a7lJi9KcHs=; b=fFLK6KKx1lJ5pqK3uT7JpTeiUMKd8TcoIdFzgf2OynFGC7xivwOCvIQ47Eblu+j1ohtf9e SoGWZati6BEU1l190vs4gXw7mg7HWajrCKcMGQ3KxyniJVlCy0dbu+sDdhtgKayqcCdZS1 NLIJKQWyTRhp7HQNUCFY9twZFPGJdls= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752740574; 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=2mqJS3et2ZSRNW2i5XCwL2/M6iyAhSDP2a7lJi9KcHs=; b=Bh05YzsmKItACcqAoYnTSkHrQBTBDGG5bZQyDBw+mJbiM8ZHw47DBXjwVQ1gp0IqDzAydQ b09DW8UStmdNyMb+AMAsRuxmSi11TdEDs6Utc7QKd9JzjjZWTteLAzUzddPwfinjX3Z1xi yy0r54lQe5+infZLLgD0M7l/RsMo4N8= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-270-0ByV2U8gOI-j128rJ81nig-1; Thu, 17 Jul 2025 04:22:51 -0400 X-MC-Unique: 0ByV2U8gOI-j128rJ81nig-1 X-Mimecast-MFC-AGG-ID: 0ByV2U8gOI-j128rJ81nig_1752740570 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-45600d19a2aso5816675e9.1 for ; Thu, 17 Jul 2025 01:22:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752740570; x=1753345370; 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=2mqJS3et2ZSRNW2i5XCwL2/M6iyAhSDP2a7lJi9KcHs=; b=msf0+w9egRDTIBmNPzPblK9pV8ZG4r50b75qKVpdOoeNkK+fBs8a5bux51rXcLvpYd lmXxu+ZYTT6A4z7HGm55noI1qIUy0Lv9YQXSLMiPYlITP3LmPZdJeXd+99wOr069agxT xhygf+tK00xLzE8IpYo95pMtw6BKwMKBORIbUItFi8Gn+yaG20xuqU9m3iMyTzKA1mEI G9/64jten/YuxSBN8fTzt8wheS3E5mbB+vX6uSfpQcXTDoxNfCD8XaabnGPpEboQxttM e+bQPTLmgs+9pxoE49GeyhscceLrYrSSzWv2Ihq0Qxh72opquyvUe8n9Vg3jXEtBkpXf 7U3w== X-Forwarded-Encrypted: i=1; AJvYcCXI0J8lI6j8Q7Y//K++kiO3pDWTkYZG92D59L3qJDJbId9ZbFeSZrvBCx21DADIjIjn4shvyLQ1gA==@kvack.org X-Gm-Message-State: AOJu0Yw2dM9Tl1KUpoXJxLV9K6rqn6CbOPk+7MwmwSdQi+11PRFm2VZA mtHqBpiquUdquz8bMbKYcYdlZhByU42keshUUUo7uoZTdhKbJ6HJonCWJ+ApOYkPzBxmDYA5M6V cO2tEWsHrRaxiLn2M6ly1+AQQaFp0DLmIUzfiQPHyqbMbj9Jxfmb1 X-Gm-Gg: ASbGncsXq04iis5+KDpbtXaMOiRvTrutMqVlgSuUkRF9gp+a83CVXMYxaJw/7lkxDrg +uNRAHGFvv9p7a9Yk6IGfh/mjxPddxG8ROV77PCU4OktXP5jaKicxskf4+DqEcAGaugfSqNEbIx Vml/9wso2N0hahOFDCDwveNEJJPZB6OiNs4psl0oVzyJvjB1X3lsa5ZqX0hkNmy6a/8xam62e/x E977K2dFmU+5SZqasesfP2SrEa1psbaiM7gBVXTOq261o5NGu7Q1UOk4pCpiKDZI7wwgVts75Dv jqJ7bRZVJRPEHGsoa2y8rfbzZDBgCr3GzstgxcB229oAL/yRNlBpt0bgDEttdIiuZ7+QSWpbhR1 UUHCs3HlFpAmax9WnOoLWTjApSJ2X08nCiaYfVLbi0r6yEmL7/q8Ofa+uOzA5MRtZ X-Received: by 2002:a05:600c:4e8c:b0:456:1fd9:c8f0 with SMTP id 5b1f17b1804b1-4562e32e669mr62039285e9.2.1752740570013; Thu, 17 Jul 2025 01:22:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEx08OSLhPGt3YPyqddHzKgpSak7sIe+Ln7zA5D5N8r+GtXX0XTFT09KimbjZO7HxCEMVUzrQ== X-Received: by 2002:a05:600c:4e8c:b0:456:1fd9:c8f0 with SMTP id 5b1f17b1804b1-4562e32e669mr62038895e9.2.1752740569493; Thu, 17 Jul 2025 01:22:49 -0700 (PDT) Received: from ?IPV6:2003:d8:2f1f:3600:dc8:26ee:9aa9:fdc7? (p200300d82f1f36000dc826ee9aa9fdc7.dip0.t-ipconnect.de. [2003:d8:2f1f:3600:dc8:26ee:9aa9:fdc7]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b5e8dc2025sm20378744f8f.31.2025.07.17.01.22.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Jul 2025 01:22:48 -0700 (PDT) Message-ID: <2513a63d-b11a-48fc-922a-288785817df4@redhat.com> Date: Thu, 17 Jul 2025 10:22:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] mm: fault in complete folios instead of individual pages for tmpfs To: Baolin Wang , Hugh Dickins , Lorenzo Stoakes , Andrew Morton Cc: Matthew Wilcox , ziy@nvidia.com, Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <440940e78aeb7430c5cc8b6d2088ae98265b9809.1751599072.git.baolin.wang@linux.alibaba.com> <20250704151858.73d35a24b4c2f53bdb0c1b85@linux-foundation.org> <4c055849-d7dd-4b9f-9666-fcb0bccf8681@linux.alibaba.com> <007c4a94-c94a-418e-9907-7510422f8ca4@lucifer.local> <23f1c3ab-16ca-41db-b008-22448d9e08f2@linux.alibaba.com> <3bf50873-4d1b-a7c7-112e-3a17ac16077f@google.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//bL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HIfcQzl88G83oaO7vb7s/cWMYRKOg+WIgp0MJ8DO2IU5JmUtyJB+V3YzzM4cMic3 bNn8nHjTWw/9+QQ5vg3TXHZ5XMu9mtfw2La3bHJ6AybL0DvEkdGxk6YHqJVEukciLMWDWqQQ RtbBhqcprgUxipNvdn9KwNpGciM+hNtM9kf9gt0fjv79l/FiSw6KbCPX9b636GzgNy0Ev2UV m00EtcpRXXMlEpbP4V947ufWVK2Mz7RFUfU4+ETDd1scMQDHzrXItryHLZWhopPI4Z+ps0rB CQHfSpl+wG4XbJJu1D8/Ww3FsO42TMFrNr2/cmqwuUZ0a0uxrpkNYrsGjkEu7a+9MheyTzcm vyU2knz5/stkTN2LKz5REqOe24oRnypjpAfaoxRYXs+F8wml519InWlwCra49IUSxD1hXPxO WBe5lqcozu9LpNDH/brVSzHCSb7vjNGvvSVESDuoiHK8gNlf0v+epy5WYd7CGAgODPvDShGN g3eXuA== Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: KIQUkYa5kAsZkfym3qyhUJAyjCZnAzjume_F0nXIePQ_1752740570 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: rspam12 X-Rspamd-Queue-Id: 6E0E61C000B X-Stat-Signature: xdwpzw3d8rm1snfpf5p4oqrqrhgkwosd X-Rspam-User: X-HE-Tag: 1752740575-881635 X-HE-Meta: U2FsdGVkX1/jrSyahlfrmfkOdMwD0TLj7sH3OZQVgbB9hHfVMdRvT/hT0mEz9RH2GhgdOPr0DB67GeInRFrL40NO4GnUUkp3Sm999ukACNxBZMMVLJrttIB4AKj+Z70flEFS+Tnw3rBzwv7mZUmoZvVJyhqWavm+yzhhZ6jAPmC9zr6IbeCoSQglwuR2iVKdBCtTb0YS+aNMwL/+C9zK8ZF7GY73aVWxeuAW3tDOK1XbhLf9AB3erfQhZoCHAYip+ceS2N6vBu8YnsqtPZ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jPNWmfLE5bes58U5zy5Rcjdp9lpljGkN6gIlY0Tg0DJ07a/L8KD6/UFvJkmLK0BwjYO66kQKKjO+IOF+tB6wPF537oNY0omUPEG7SsdZkVGb1bF1blwJCAMg6XUexErIWbGn4GxF5/8P7FKI/yff7fzwoLwPH/6pkic8Y4WLOvXu0n1w4UqVUyqdRzrdgh5ptWr0hIGXjknQos= 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 17.07.25 10:01, Baolin Wang wrote: > > > On 2025/7/16 04:03, Hugh Dickins wrote: >> On Wed, 9 Jul 2025, Lorenzo Stoakes wrote: >>> On Tue, Jul 08, 2025 at 03:53:56PM +0800, Baolin Wang wrote: >>>> On 2025/7/7 21:33, Lorenzo Stoakes wrote: >>>>> On Sun, Jul 06, 2025 at 10:02:35AM +0800, Baolin Wang wrote: >>>>>> On 2025/7/5 06:18, Andrew Morton wrote: >>>>>>> On Fri, 4 Jul 2025 11:19:26 +0800 Baolin Wang wrote: >>>>>>> >>>>>>>> After commit acd7ccb284b8 ("mm: shmem: add large folio support for tmpfs"), >>>>>>>> tmpfs can also support large folio allocation (not just PMD-sized large >>>>>>>> folios). >>>>>>>> >>>>>>>> However, when accessing tmpfs via mmap(), although tmpfs supports large folios, >>>>>>>> we still establish mappings at the base page granularity, which is unreasonable. >>>>>>>> >>>>>>>> We can map multiple consecutive pages of a tmpfs folios at once according to >>>>>>>> the size of the large folio. On one hand, this can reduce the overhead of page >>>>>>>> faults; on the other hand, it can leverage hardware architecture optimizations >>>>>>>> to reduce TLB misses, such as contiguous PTEs on the ARM architecture. >>>>>>>> >>>>>>>> Moreover, tmpfs mount will use the 'huge=' option to control large folio >>>>>>>> allocation explicitly. So it can be understood that the process's RSS statistics >>>>>>>> might increase, and I think this will not cause any obvious effects for users. >>>>>>>> >>>>>>>> Performance test: >>>>>>>> I created a 1G tmpfs file, populated with 64K large folios, and write-accessed it >>>>>>>> sequentially via mmap(). I observed a significant performance improvement: >>>>>>> >>>>>>> That doesn't sound like a crazy thing to do. >>>>>>> >>>>>>>> Before the patch: >>>>>>>> real 0m0.158s >>>>>>>> user 0m0.008s >>>>>>>> sys 0m0.150s >>>>>>>> >>>>>>>> After the patch: >>>>>>>> real 0m0.021s >>>>>>>> user 0m0.004s >>>>>>>> sys 0m0.017s >>>>>>> >>>>>>> And look at that. >>>>>>> >>>>>>>> diff --git a/mm/memory.c b/mm/memory.c >>>>>>>> index 0f9b32a20e5b..9944380e947d 100644 >>>>>>>> --- a/mm/memory.c >>>>>>>> +++ b/mm/memory.c >>>>>>>> @@ -5383,10 +5383,10 @@ vm_fault_t finish_fault(struct vm_fault *vmf) >>>>>>>> /* >>>>>>>> * Using per-page fault to maintain the uffd semantics, and same >>>>>>>> - * approach also applies to non-anonymous-shmem faults to avoid >>>>>>>> + * approach also applies to non shmem/tmpfs faults to avoid >>>>>>>> * inflating the RSS of the process. >>>>>>>> */ >>>>>>>> - if (!vma_is_anon_shmem(vma) || unlikely(userfaultfd_armed(vma)) || >>>>>>>> + if (!vma_is_shmem(vma) || unlikely(userfaultfd_armed(vma)) || >>>>>>>> unlikely(needs_fallback)) { >>>>>>>> nr_pages = 1; >>>>>>>> } else if (nr_pages > 1) { >>>>>>> >>>>>>> and that's it? >>>>>>> >>>>>>> I'm itching to get this into -stable, really. What LTS user wouldn't >>>>>>> want this? >>>>>> >>>>>> This is an improvement rather than a bugfix, so I don't think it needs to go >>>>>> into LTS. >>>>>> >>>>>> Could it be viewed as correcting an oversight in >>>>>>> acd7ccb284b8? >>>>>> >>>>>> Yes, I should have added this optimization in the series of the commit >>>>>> acd7ccb284b8. But obviously, I missed this :(. >>>>> >>>>> Buuut if this was an oversight for that patch that causes an unnecessary >>>>> perf degradation, surely this should have fixes tag + cc stable no? >>>> >>>> IMO, this commit acd7ccb284b8 won't cause perf degradation, instead it is >>>> used to introduce a new feature, while the current patch is a further >>>> reasonable optimization. As I mentioned, this is an improvement, not a >>>> bugfix or a patch to address performance regression. >>> >>> 4Well :) you say yourself it was an oversight, and it very clearly has a perf >>> _impact_, which if you compare backwards to acd7ccb284b8 is a degradation, but I >>> get your point. >>> >>> However, since you say 'oversight' this seems to me that you really meant to >>> have included it but hadn't noticed, and additionally, since it just seems to be >>> an unequivical good - let's maybe flip this round - why NOT backport it to >>> stable? >> >> I strongly agree with Baolin: this patch is good, thank you, but it is >> a performance improvement, a new feature, not a candidate for the stable >> tree. I'm surprised anyone thinks otherwise: Andrew, please delete that >> stable tag before advancing the patch from mm-unstable to mm-stable. >> >> And the Fixee went into 6.14, so it couldn't go to 6.12 LTS anyway. > > Agree. > >> An unequivocal good? I'm not so sure. >> >> I expect it ought to be limited, by fault_around_bytes (or suchlike). >> >> If I understand all the mTHP versus large folio versus PMD-huge handling >> correctly (and of course I do not, I'm still weeks if not months away >> from understanding most of it), the old vma_is_anon_shmem() case would >> be limited by the shmem mTHP tunables, and one can reasonably argue that >> they would already take fault_around_bytes-like considerations into account; >> but the newly added file-written cases are governed by huge= mount options >> intended for PMD-size, but (currently) permitting all lesser orders. >> I don't think that mounting a tmpfs huge=always implies that mapping >> 256 PTEs for one fault is necessarily a good strategy. >> >> But looking in the opposite direction, why is there now a vma_is_shmem() >> check there in finish_fault() at all? If major filesystems are using >> large folios, why aren't they also allowed to benefit from mapping >> multiple PTEs at once (in this shared-writable case which the existing >> fault-around does not cover - I presume to avoid write amplification, >> but that's not an issue when the folio is large already). > > This is what I'm going to do next. For other filesystems, I think they > should also map multiple PTEs at once. I recall [1]. But that would, of course, only affect the RSS of a program and not the actual memory consumption (the large folio resides in memory ...). The comments in the code spells that out: "inflating the RSS of the process." [1] https://www.suse.com/support/kb/doc/?id=000019017 -- Cheers, David / dhildenb