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 B93D7C6FD1F for ; Tue, 26 Mar 2024 17:51:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3195D6B008C; Tue, 26 Mar 2024 13:51:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C98A6B0092; Tue, 26 Mar 2024 13:51:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1917C6B0095; Tue, 26 Mar 2024 13:51:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 07B096B008C for ; Tue, 26 Mar 2024 13:51:29 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9EC14140A6F for ; Tue, 26 Mar 2024 17:51:28 +0000 (UTC) X-FDA: 81939932256.24.469FE26 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 547A4180016 for ; Tue, 26 Mar 2024 17:51:25 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.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=1711475487; 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=ZBgX4ZeYUUEL0ZieXIdYKnpAK3nWk3WnDvE7Btab5hU=; b=tSUge3KI88SYBr7HYxcqozOaFUN7z2tRwHRlABG6IT6NEyb/RgDx+oyV2NpUdshKmC7732 eS3hKW+FxHKRZuP+thsBtly7T55tJHGbTLetQ+J+UkxKLfpWVSXDIparRgpK6t6AaSoods o8QI3YgWN/+pOFlG7v+dv6JdF88zAyo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.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=1711475487; a=rsa-sha256; cv=none; b=2FKJ9Glm1MVJRVUDvQkwcZd3ZnK1wNpQvtk897M0iMWBN1NwtZLki0/Kh8FgzruyyoSO96 AbpJGaICx9TH18XoqV/Lqy4xpK6gnTc8ssZRf221jKBRunGorLMW/BL11JidG5VuDGFLq4 Z16/vsSzNIZVfB9exoT2ZlKJK3K3ikU= 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 732322F4; Tue, 26 Mar 2024 10:51:58 -0700 (PDT) Received: from [10.1.29.179] (XHFQ2J9959.cambridge.arm.com [10.1.29.179]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF1E43F64C; Tue, 26 Mar 2024 10:51:22 -0700 (PDT) Message-ID: <86680856-2532-495b-951a-ea7b2b93872f@arm.com> Date: Tue, 26 Mar 2024 17:51:21 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v1 0/4] Reduce cost of ptep_get_lockless on arm64 Content-Language: en-GB To: David Hildenbrand , Mark Rutland , Catalin Marinas , Will Deacon , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Andrew Morton , Muchun Song Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240215121756.2734131-1-ryan.roberts@arm.com> <0ae22147-e1a1-4bcb-8a4c-f900f3f8c39e@redhat.com> <374d8500-4625-4bff-a934-77b5f34cf2ec@arm.com> <8bd9e136-8575-4c40-bae2-9b015d823916@redhat.com> From: Ryan Roberts In-Reply-To: <8bd9e136-8575-4c40-bae2-9b015d823916@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 547A4180016 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: fjcap7g7sw6k69swfwp39pyknwrcpes5 X-HE-Tag: 1711475485-956661 X-HE-Meta: U2FsdGVkX1/LDfnSwE1OgXatj+9/uoXZaft5EF4eze2+InlVPn8MO7A1HJSiXuTzILZsXY9m1hyOlkpUBDVRcyqYYFPdNhWsgJ2YiBjdj8TFrLidZ4Gk/xgYgFzD3ScplLbxHthvh86JwnCqWk+0HG9utKnFsXJC9ylGdHtcwqaxcePGl4cwansihC1lVQvZzhycyxnQyAyFfVCRCCt76Ke1wC5LiMwzHZoaCLqZdYNHDQiatGzYwBSOQOfFZdab4H+xWw2NU9QLdEv6MkS3w6+zmD8DDUguLPLjX7meTEqGomWnR4HGhlq6EkP5PmwqU9TynUPH20r30e5j2sUwx/Kk02FWbeXR4D/pJPVJmX7XVZk2cXFqDQRvZjFwEiKVzTXV+q4JbcEGegxWGOzOl0vJQtPdvDEx9EDcjTHMqldy8PFQOSbBFlBAhhYPYtxoUaEMtyD9yRffK5nuegOHnKJWXHeyO3H3xl0DV+WY9LW1Jh9YNlBffHj2wk4aiyH+7acLRWex7aICPrkV4ah3+p8SmoPdM52vU3PSQ/S8fHhNOAwmUaHjbvaZYv04HkzjJObPXtkcyxTui9WabSgUBgAQjlpG8mTXv7atAtLRo9Y9VrEzsKmvIrhV/CZsPVIrrK58hlNc4KpX6L61z8vmPNkUjRjVGI53XnKeZaHVDPTDU3OfZDrbK+okpBwFZua2mFYThZcda0x8oOLvPlQY5DSUBKhWoeT+5vJi+9eXHZUAI40u/xRldq4ySsh5onbQDE1KeNlQ/9oykkQ+wxQ1kKVllbQ6RZTVqkv64NhAIUfpEBZjyWLZ71aH4PkZ0Lie29XKnuXcZac3HOJCZJuKyd+fDWvUbqXgeqDZzEhtSjRpD5SRAK4TXzk9UY1Ct6zRweF0n9I0sSvcW76VVCKTtBdV8QWwv9YXViea7gM8Q4sU+50mQuVI5T6OMwzadVMysO7sgeWJ/srxeoPQydb gL1HA8rn bBf52rIFlCzIw9ymcvJTi2rtd0O6Ekq2bLkZolKDgI5X5/s9HQyfCr+lOJxtU1Sqvhy8M/SxLvYOKnsE/uUKMFKYA9cdxlMLKw0/d7rvATNT88AkGuZEceKc7ZojI6d49fC+px8SyltM/64PeoqqgQAamaEdWdMyBsS8+S4/wMQrJh/8GxTzjE7xav2LLwGW+9zxR 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 26/03/2024 17:39, David Hildenbrand wrote: > On 26.03.24 18:32, Ryan Roberts wrote: >> On 26/03/2024 17:04, David Hildenbrand wrote: >>>>>>> >>>>>>> Likely, we just want to read "the real deal" on both sides of the pte_same() >>>>>>> handling. >>>>>> >>>>>> Sorry I'm not sure I understand? You mean read the full pte including >>>>>> access/dirty? That's the same as dropping the patch, right? Of course if >>>>>> we do >>>>>> that, we still have to keep pte_get_lockless() around for this case. In an >>>>>> ideal >>>>>> world we would convert everything over to ptep_get_lockless_norecency() and >>>>>> delete ptep_get_lockless() to remove the ugliness from arm64. >>>>> >>>>> Yes, agreed. Patch #3 does not look too crazy and it wouldn't really affect >>>>> any >>>>> architecture. >>>>> >>>>> I do wonder if pte_same_norecency() should be defined per architecture and the >>>>> default would be pte_same(). So we could avoid the mkold etc on all other >>>>> architectures. >>>> >>>> Wouldn't that break it's semantics? The "norecency" of >>>> ptep_get_lockless_norecency() means "recency information in the returned pte >>>> may >>>> be incorrect". But the "norecency" of pte_same_norecency() means "ignore the >>>> access and dirty bits when you do the comparison". >>> >>> My idea was that ptep_get_lockless_norecency() would return the actual result on >>> these architectures. So e.g., on x86, there would be no actual change in >>> generated code. >> >> I think this is a bad plan... You'll end up with subtle differences between >> architectures. >> >>> >>> But yes, the documentation of these functions would have to be improved. >>> >>> Now I wonder if ptep_get_lockless_norecency() should actively clear >>> dirty/accessed bits to more easily find any actual issues where the bits still >>> matter ... >> >> I did a version that took that approach. Decided it was not as good as this way >> though. Now for the life of me, I can't remember my reasoning. > > Maybe because there are some code paths that check accessed/dirty without > "correctness" implications? For example, if the PTE is already dirty, no need to > set it dirty etc? I think I decided I was penalizing the architectures that don't care because all their ptep_get_norecency() and ptep_get_lockless_norecency() need to explicitly clear access/dirty. And I would have needed ptep_get_norecency() from day 1 so that I could feed its result into pte_same().