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 22150C4167B for ; Sat, 25 Nov 2023 17:02:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57F7A6B0156; Sat, 25 Nov 2023 12:02:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 507836B0159; Sat, 25 Nov 2023 12:02:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35AD06B0158; Sat, 25 Nov 2023 12:02:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1AA6E6B0153 for ; Sat, 25 Nov 2023 12:02:14 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E49ECB5662 for ; Sat, 25 Nov 2023 17:02:13 +0000 (UTC) X-FDA: 81497094546.09.A03316B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id BC9A9C0018 for ; Sat, 25 Nov 2023 17:02:10 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ACiQPqGV; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.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=1700931730; 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=r2m8MsdEA6I0cTu0yk+FCxltGAW5Bh00EQieM20jSRA=; b=GaW+LYiWbF+ws3eYwHCTXyObB5NC5TVur5XufFgga86lHAEysDNUacMEHPmyeQZFF/6/gT /A9HKfDhkYJOFMByOloXSxeYDbAXHzQmN4jW+GVBTGSDH+6cCZAXr4cLiLNVRczgNjQcvl NInJK17YBI5NK+rDZSgcpOJ1xWbTews= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ACiQPqGV; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.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=1700931730; a=rsa-sha256; cv=none; b=cNk+jIG+xwUp7+QQDPbCn4SgbxbRC1toya+9KsoJR+Wuc4ciSI+FS/MVIM8HEPJud74SS4 NvKt0GnSRxktVSoZg0HGW1SfmuBCKIz5OROSVRrrh92CU3Y37b4WslBKsksPTv+tkTV973 U+8QEzPL7LLquQD0uEY3AaLBRkU/A24= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700931730; 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=r2m8MsdEA6I0cTu0yk+FCxltGAW5Bh00EQieM20jSRA=; b=ACiQPqGVrQ5ubwx8Rfln7AYRUgKnUGMmdHL5IPrb9/R8vXPKhgnKhCqrxo/h/Oaw/UMVUz JkYvP/hPNf33tbf9jJJ5NEh/CeT+WyqnyCYorHsWhPQ1HFl47NOP4QzQ7nOHdOIVU2e/3d yOZH9Qy2Vo5hHi0hc8Peeqt/WjTZh7E= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-163-Wfb-B217PFiyCKiN0LR8WA-1; Sat, 25 Nov 2023 12:02:08 -0500 X-MC-Unique: Wfb-B217PFiyCKiN0LR8WA-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2c87eb73f42so24814121fa.0 for ; Sat, 25 Nov 2023 09:02:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700931727; x=1701536527; 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=r2m8MsdEA6I0cTu0yk+FCxltGAW5Bh00EQieM20jSRA=; b=sAZk5A6doRkKhrACGpVhxWYspcKmVES/W2jSKroXJoa8ua8uN30B3C0JnQh7YUKEDN s59/g12tE9MoMzJ6hbBKumC4zyT+mTwqensaz35Oo+QoTsZ2KRMPn0ICtBm2qL0vJWs8 NUXjrxwWdp//xrv4fIw0rNWZcVXPwu+q2ABAFLenZ8yzywy/GqUevUYYmPiUBQPbiAA2 vvEusTq8yPpuYrOkv8DFUsIA5wLOaW7Ij1VykEktwDSeVgCFRfMRnsPhphWvbitmsmAQ 1UwqylleMQOQIpCRF8Fw6YYyewhAG3nrBOrjlTIntv16Njos1TC+FJ0hjeL7tefhwS0O Osow== X-Gm-Message-State: AOJu0Yy/Nni7w1eNzrlJR5/yW3R1vRhVc/tDIOeBD5s7/nuhkwQPCv/7 9rq4qilhjXl+eiUQUToojPCa7Z0S0A3nyhkv8eKEXjea3FJGpqsx3sKg3sApu7NI7/su++Z7rFE xoOYFOF36UJs= X-Received: by 2002:a2e:874f:0:b0:2c5:22c0:582c with SMTP id q15-20020a2e874f000000b002c522c0582cmr4170884ljj.11.1700931727065; Sat, 25 Nov 2023 09:02:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkSc9qNO/RU7x/979BuNlQWnXjB5B5aW1x7IS06s2SVfHqBlHyueZqyw4NKTX9LSbNddAQ+Q== X-Received: by 2002:a2e:874f:0:b0:2c5:22c0:582c with SMTP id q15-20020a2e874f000000b002c522c0582cmr4170859ljj.11.1700931726505; Sat, 25 Nov 2023 09:02:06 -0800 (PST) Received: from ?IPV6:2003:cb:c72b:f000:d472:dd67:5dd2:10bd? (p200300cbc72bf000d472dd675dd210bd.dip0.t-ipconnect.de. [2003:cb:c72b:f000:d472:dd67:5dd2:10bd]) by smtp.gmail.com with ESMTPSA id c37-20020a05600c4a2500b003fee6e170f9sm8222933wmp.45.2023.11.25.09.02.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Nov 2023 09:02:06 -0800 (PST) Message-ID: Date: Sat, 25 Nov 2023 18:02:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH WIP v1 00/20] mm: precise "mapped shared" vs. "mapped exclusively" detection for PTE-mapped THP / partially-mappable folios To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Ryan Roberts , Matthew Wilcox , Hugh Dickins , Yin Fengwei , Yang Shi , Ying Huang , Zi Yan , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , "Paul E. McKenney" References: <20231124132626.235350-1-david@redhat.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb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5tZTwNB 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: rspam09 X-Rspamd-Queue-Id: BC9A9C0018 X-Stat-Signature: sotctamnxhe1nyzw7k8tewufgya551af X-Rspam-User: X-HE-Tag: 1700931730-578687 X-HE-Meta: U2FsdGVkX1/hw0RSvIwIJlZKIXGrJH1nOwIVZjxUjysEEDXzMI6+HPLuiwPerd1P4QQ1bIM44jEzDq0LlSm4pbSFUUpJhROcqZsrd07lcQWAVmrQdrKbvEFm8m7XR0+vRPmKNoZ1jGPM6iR7PU8ebB2bMYrvMgWcieHeyKJ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dbNP7vOofmDuRlEJr3m4LDGuhjC3dgM2o6fLZuwc2BZocffcJaO7S77iaMh4XzyWJEqAk/NourZ3JstXsTjqxZI47prVwu3+pdwEdwBSVtQXCm1GaAD188Sfna9CqrLu065mKkvavPb7LS/3NgkQVeqi6mnLhFkaPlDZnXVwDM+FKsFeWs7rHKdbCNYHjUlioi53rAcaO64pGEqXghhlCh9wlP+Lngrx+ufahxqmRvafnM+8arm97Oa2Gnt7LhzJ23GiUKx 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 24.11.23 21:55, Linus Torvalds wrote: > On Fri, 24 Nov 2023 at 05:26, David Hildenbrand wrote: >> >> Are you interested in some made-up math, new locking primitives and >> slightly unpleasant performance numbers on first sight? :) Hi Linus, first of all -- wow -- thanks for that blazing fast feedback! You really had to work through quite some text+code to understand what's happening. Thanks for prioritizing that over Black Friday shopping ;) > > Ugh. I'm not loving the "I have a proof, but it's too big to fit in > the margin" model of VM development. > > This does seem to be very subtle. Yes, compared to other kernel subsystems, this level of math in the VM is really new. The main reason I excluded the proof in this WIP series is not the size, though. I wanted to get the implementation out after talking about it (and optimizing it ...) for way too long and (a) proofs involving infinite sequences in pure ascii are just horrible to read; (b) I think the proof can be cleaned-up / simplified, especially after I came up with the "intuition" in the patch some days ago and decided to use that one instead for now. No questions asked, if this ever gets discussed for actual merging, only with a public, reviewed proof available. [most of the "magic" goes away once one simply uses one rmap value for each bit in the mm->mm_rmap_id; 22 bit -> 22 rmap values. Of course, 22 values are undesirable.] > > Also, please benchmark what your rmap changes do to just plain regular > pages - it *looks* like maybe all you did was to add some > VM_WARN_ON_FOLIO() for those cases, but I have this strong memory of > that > > if (likely(!compound)) { > > case being very critical on all the usual cases (and the cleanups by > Hugh last year were nice). Yes, indeed. I separated small vs. large folio handling cleanly, such that we always have a pattern like: + if (likely(!folio_test_large(folio))) + return atomic_add_negative(-1, &page->_mapcount); So, the fast default path is "small folio". As stated, I want to do much more benchmarking to better understand all performance impacts; especially, on top of Ryan's work of having THPs that are always PTE-mapped and we don't have to "artificially" force a PTE-mapped THP. > > I get the feeling that you are trying to optimize a particular case > that is special enough that some less complicated model might work. > > Just by looking at your benchmarks, I *think* the case you actually > want to optimize is "THP -> fork -> child exit/execve -> parent write > COW reuse" where the THP page was really never in more than two VM's, > and the second VM was an almost accidental temporary thing that is > just about the whole "fork->exec/exit" model. That's the most obvious/important case regarding COW reuse, agreed. And also where I originally started, because it looked like the low-hanging fruit (below). For the benchmarks I have so far, I focused mostly on the performance/harm of individual operations. Conceptually, with rmap IDs, there is no performance difference if you end up reusing a THP in the parent or the child, the performance is the same, so I didn't add it manually to the micro benchmarks. > > Which makes me really feel like your rmap_id is very over-engineered. > It seems to be designed to handle all the generic cases, but it seems > like the main cause for it is a very specific case that I _feel_ > should be something that could be tracked with *way* less information > (eg just have a "pointer to owner vma, and a simple counter of > non-owners"). That's precisely where I originally started [1], but quickly wondered (already in that mail): (a) How to cleanly and safely stabilize refcount vs. mapcount. Without playing tricks such that it's just "obvious" how it's just correct and race-free in the COW reuse path. (b) How to extend it to !anon folios, where we don't have a clean entry point like folio_add_new_anon_rmap(); primarily to get a sane replacement for folio_estimated_shares(), which I just dislike at this point. (c) If it's possibly to easily and cleanly change owners (creators in my mail), without involving locks. So I started thinking about the possibility of a precise and possibly more universal/cleaner way of handling it, that doesn't add too much runtime overhead. A way to just have what we have for small folios. I was surprised to find an approach that gives a precise answer and simply changes the owner implicitly, primarily just by adding/subtracting numbers. [I'll note that having a universal way to stabilize the mapcount vs. refcount could be quite valuable. But achieving that also for small folios would require e.g., having shared, hashed atomic seqcounts. And I'm not too interested in harming small-folio performance at this point :)] Now, if we want all that sooner, later, or maybe never, is a different question. This WIP version primarily tries to show what's possible, at which price, and what the limitations are. > > I dunno. I was cc'd, I looked at the patches, but I suspect I'm not > really the target audience. If Hugh is ok with this kind of Well, I really value your feedback, and you are always in my CC list when I'm messing with COW and mapcounts. Having that said, it's encouraging that you went over the patches (thanks again!) and nothing immediately jumped at you (well, besides the proof, but that will be fixed if this ever gets merged). > complexity, I bow to a higher authority. This *does* seem to add a lot > of conceptual complexity to something that is already complicated. I'll note that while it all sounds complicated, in the end it's "just" adding/subtracting numbers, and having a clean scheme to detect concurrent (un)mapping. Further, it's handled without any new rmap hooks. But yes, there sure is added code and complexity, and personally I dislike having to go from 3 to 6 rmap values to support arm64 with 512 MiB THP. If we could just squeeze it all into a single rmap value, it would all look much nicer: one total mapcount, one rmap value. Before this would get merged a lot more has to happen, and most rmap batching (and possibly including the exclusive atomic seqcount) could be beneficial even without the rmap ID handling, so it's natural to start with that independently. Thanks again! [1] https://lore.kernel.org/all/6cec6f68-248e-63b4-5615-9e0f3f819a0a@redhat.com/T/#u -- Cheers, David / dhildenb