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 D81A6C48260 for ; Tue, 13 Feb 2024 15:29:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F0728D0015; Tue, 13 Feb 2024 10:29:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 652378D0001; Tue, 13 Feb 2024 10:29:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CBCF8D0015; Tue, 13 Feb 2024 10:29:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 36AC28D0001 for ; Tue, 13 Feb 2024 10:29:33 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id ED6FB1A09CB for ; Tue, 13 Feb 2024 15:29:32 +0000 (UTC) X-FDA: 81787164984.20.470491A Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf10.hostedemail.com (Postfix) with ESMTP id E5DABC0013 for ; Tue, 13 Feb 2024 15:29:30 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf10.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707838171; 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; bh=hvDVRocUvY5yyNPAjc921ReXjYi/f4/NSpKuxDh0Vr0=; b=prbgH+JwH0tQT2MTt6BamIMjt4n1LmWQh2NOx4Yl7IrkgnL/zeGiXmdVGjPgRThmVZ7Zpe snPpC/Eg2WYv9BhV/4fLorTvZaRinRRQmJZFU5pwsToeJH0mcYsM1d5PY324FMUC7DgWgp fvRkSCDbdl5BjG8EnodcYYlL/3bxfFo= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf10.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707838171; a=rsa-sha256; cv=none; b=gcao0qXa9a8WYg57pYOdS4DZ/Cfl2Djs/CbNvaSf3ZZvbspzbOqNMOQ41+gVI3mJZNm8lA qh+xWNHPqcAnkc856trtnm8pFI+jmRB55dyn+fvK75DDaXQ1qfKnRbg3qY0d3M1PmLpCOf 5Yb86I3E7Qf35pY+ctCkz//n5uZOmys= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 19912DA7; Tue, 13 Feb 2024 07:30:11 -0800 (PST) Received: from [10.1.36.184] (XHFQ2J9959.cambridge.arm.com [10.1.36.184]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 37F103F7B4; Tue, 13 Feb 2024 07:29:26 -0800 (PST) Message-ID: Date: Tue, 13 Feb 2024 15:29:24 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 19/25] arm64/mm: Wire up PTE_CONT for user mappings Content-Language: en-GB To: David Hildenbrand , Mark Rutland Cc: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240202080756.1453939-1-ryan.roberts@arm.com> <20240202080756.1453939-20-ryan.roberts@arm.com> <502a3ea7-fd86-4314-8292-c7999eda92eb@arm.com> <427ba87a-7dd0-4f3e-861f-fe6946b7cd97@redhat.com> <55a1e0ef-14b3-4311-b2aa-a6add76fa2ed@redhat.com> From: Ryan Roberts In-Reply-To: <55a1e0ef-14b3-4311-b2aa-a6add76fa2ed@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: E5DABC0013 X-Stat-Signature: fhoecraq5c7g9jw6bq93rw6thtx7s1zf X-HE-Tag: 1707838170-121229 X-HE-Meta: U2FsdGVkX189uDRCs/9TzFMCZXBkef7kmPtnC78FzA7hMMWBFdePmwMlJpSPlu6sfKjd8eSXh7MYqmCt3OSVP/aVP8WXejYeIX7eSUJVZyoL5/tECgU/5mPHlQ5pXn7ewW7qVMB2Vs/VQAc2IVUf8BH3hgX+HoUMJZdODiJ+fm7CMJC46siOJd/IauhLAMzJmBuG3y26I07fMPM6wa9r4kLxvePlRFOZJ3Ou0rDxCKP+ny7R72kgoDQ5jN+G1QipSxABfFX7Y/8opd6I0nJngU5a97WP4p2k7pdn/pAGEavivmyTQ4TqDiDC+4J3gxAIz2JwJf7M+Dy91JJ/ywxvvyDbqrEVtstKkYsx6oYMKOgm6YIFdP2q8X6S6B6PP7mnP+o3w2jSJE3luhX2Ejlkk8WbhExH1nIRWRXoyezc2KX4Gx0qgH42EVI2Vzfho9Hmpg1FlD0G1X73UIOXqbN+ypRVN5qF8qpKHwcz+NdVG/8MoXoOslHZCcG900LQI44cFtIGrXhzYMgWyV8/SQgSeCpSU/Xs2NrKcGCqwkRL/014zgmXxYDE3Ftji7+3aloA9aDPsiLbV4nqPg3HErY2sSJQthU193F3fVcItcGN5FGQWw6kqk24RBg5EP0qQKC4x+ePbi7doNnc9JKHrBiJHtMPRj2IfCw+uRdx+uLUJk+7vLqrA6ILE4PuQewqH53WeiwVuBcyFDgsx/Yf7dEKWmbq+N4FUQriqTu+Y6RNDlz09iUnoqSAw+ycjOxN1UKhSicnD/3DZ7ib/JSTSIv80wBSl5xTkOXTn+LasdvKNoWH3xrtt/dXo4+YCEULpYz2lQ+L0es2u1GAhhzfTuX2mAb6p3/T21xaoX9IYJjVh33AMLvT1GefBq4AhwnOIGAScUr6XNDVlWUbP5qz6uIp/9XDzLc8GJ2b3yp7MILq4oZA07NXsm+/msPbEPJ23ZAS7KsFRMBywFLwEGUvW6A cZ6y3alf EBLONhKd4CvjCLHeoHJzLO3U49XAUsNLs0e8A3XlDKoL/e2Rgaj5HUoi9Ikw4/o2ntZ9UQDM4jCL4M3cXu5Q2dvL/U+tggfqZTlvNcWj44oX8oEI/BenpvM1wuq2MKFJavvjC0E3xeLDihkMl0fam4L6ubKG2b9TWxOU8biRa212J/TdAgRWQ2GabXSi5OQz9XwxCfhrLxae+RvLiOpT05K1gr9OIqoN19H1e3iemKgNQVB3gIq1ip8d4Y3teaMcj5ZynSfIJHDS9PZI= 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 12/02/2024 16:24, David Hildenbrand wrote: > On 12.02.24 16:34, Ryan Roberts wrote: >> On 12/02/2024 15:26, David Hildenbrand wrote: >>> On 12.02.24 15:45, Ryan Roberts wrote: >>>> On 12/02/2024 13:54, David Hildenbrand wrote: >>>>>>> If so, I wonder if we could instead do that comparison modulo the >>>>>>> access/dirty >>>>>>> bits, >>>>>> >>>>>> I think that would work - but will need to think a bit more on it. >>>>>> >>>>>>> and leave ptep_get_lockless() only reading a single entry? >>>>>> >>>>>> I think we will need to do something a bit less fragile. ptep_get() does >>>>>> collect >>>>>> the access/dirty bits so its confusing if ptep_get_lockless() doesn't >>>>>> IMHO. So >>>>>> we will likely want to rename the function and make its documentation >>>>>> explicit >>>>>> that it does not return those bits. >>>>>> >>>>>> ptep_get_lockless_noyoungdirty()? yuk... Any ideas? >>>>>> >>>>>> Of course if I could convince you the current implementation is safe, I >>>>>> might be >>>>>> able to sidestep this optimization until a later date? >>>>> >>>>> As discussed (and pointed out abive), there might be quite some callsites >>>>> where >>>>> we don't really care about uptodate accessed/dirty bits -- where ptep_get() is >>>>> used nowadays. >>>>> >>>>> One way to approach that I had in mind was having an explicit interface: >>>>> >>>>> ptep_get() >>>>> ptep_get_uptodate() >>>>> ptep_get_lockless() >>>>> ptep_get_lockless_uptodate() >>>> >>>> Yes, I like the direction of this. I guess we anticipate that call sites >>>> requiring the "_uptodate" variant will be the minority so it makes sense to use >>>> the current names for the "_not_uptodate" variants? But to do a slow migration, >>>> it might be better/safer to have the weaker variant use the new name - that >>>> would allow us to downgrade one at a time? >>> >>> Yes, I was primarily struggling with names. Likely it makes sense to either have >>> two completely new function names, or use the new name only for the "faster but >>> less precise" variant. >>> >>>> >>>>> >>>>> Especially the last one might not be needed. >>>> I've done a scan through the code and agree with Mark's original conclusions. >>>> Additionally, huge_pte_alloc() (which isn't used for arm64) doesn't rely on >>>> access/dirty info. So I think I could migrate everything to the weaker variant >>>> fairly easily. >>>> >>>>> >>>>> Futher, "uptodate" might not be the best choice because of PageUptodate() and >>>>> friends. But it's better than "youngdirty"/"noyoungdirty" IMHO. >>>> >>>> Certainly agree with "noyoungdirty" being a horrible name. How about "_sync" / >>>> "_nosync"? >>> >>> I could live with >>> >>> ptep_get_sync() >>> ptep_get_nosync() >>> >>> with proper documentation :) >> >> but could you live with: >> >> ptep_get() >> ptep_get_nosync() >> ptep_get_lockless_nosync() >> >> ? >> >> So leave the "slower, more precise" version with the existing name. > > Sure. > I'm just implementing this (as a separate RFC), and had an alternative idea for naming/semantics: ptep_get() ptep_get_norecency() ptep_get_lockless() ptep_get_lockless_norecency() The "_norecency" versions explicitly clear the access/dirty bits. This is useful for the "compare to original pte to check we are not racing" pattern: pte = ptep_get_lockless_norecency(ptep) ... if (!pte_same(pte, ptep_get_norecency(ptep))) // RACE! ... With the "_nosync" semantic, the access/dirty bits may or may not be set, so the user has to explicitly clear them to do the comparison. (although I considered a pte_same_nosync() that would clear the bits for you - but that name is pretty naff). Although the _norecency semantic requires always explicitly clearing the bits, so may be infinitesimally slower, it gives a very clear expectation that the access/dirty bits are always clear and I think that's conveyed well in the name too. Thoughts?