Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3494928lqp; Tue, 26 Mar 2024 10:33:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbl/T9lERYuBMzOBBI3l/IN7DFI+zqNOfQNOLwgKES5vv9rNetCN0ikyIZpTmdqi3+d2+W+XHwaEJ5SIDZibbtnu4omiDeswmpbJWizQ== X-Google-Smtp-Source: AGHT+IGJxaJJmzeVGYwLLsETfYs3WQGIb2ixRgW+HYfgzvjlaU3axSnLWwZZCZwFNWLHSdjdoj2v X-Received: by 2002:a05:6214:b6b:b0:696:96ff:c71f with SMTP id ey11-20020a0562140b6b00b0069696ffc71fmr3972873qvb.9.1711474383491; Tue, 26 Mar 2024 10:33:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711474383; cv=pass; d=google.com; s=arc-20160816; b=A3HRDJd46lOWJ/4SFCmcY+L5LfjR6/olVo1Xvy0aguY4S/92SR8E61SZp6+xrwFZn1 500oXbxOh9K2XZmos9SoEiEkS9sPKknl4HUnL+blu+sPmfqX3Iw6EG2+FBEuhyPJkJBh DKpDqXMomCziTqLhPpDcXozo6Rfjq2LcHP2AcFPAp5AcwclEFfzKlis1CABeeD9JKWH8 MOx57oN8itdFlrL0fom4+9H3LqobOr50Igp8kjxFCFr/XhMzpgcU52QniLj8tTw0zQSa 0NyFqZC0L1J9XWR9q3/49ZekxgIgK6Zd5zlKHStVng58Tn/iYJ7TJQ+1g+Uwu9TMXH7Z o0vg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=tmTjHU2OPFWNEuuxmVlWppayNT5BlFwStTscJIt2AWc=; fh=5ElpXvGotM0/udMhnvi0GjXf9RQ5OKrboCm54T8RE10=; b=VetI9khfV2kre9VQyNzyGQijJV/Gb8b4bpZil1FMBGCJ28ZauQPgJxECckm7Zbzlm+ O4pS0HEypm2KGGlhALylnkhatABzUas/Z4CsyWL0resWPuY48Uj+KzNj9VOhGzClIDnu Uk7PjO2xj+USwt5RmcSpkHo9B9RvygJdY4Zav1lHwIBw8sO/PX0HMio0aauDv+ICEWfw qXdAFoYv/Y2cLz2bPYduAdwOWwhzxdd38TMgwEqaqLKPyHXGJp24Ae39GVY6V1mpM1J/ 8zJfj0Mxhr5LjV4RnHH65WEEk/P8oTMBKmiYqkT5guWXaymjDozVeBdUeaunjbJyC15a YAfw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-119602-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ed2-20020ad44ea2000000b00690ba75f8a4si10484585qvb.534.2024.03.26.10.33.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 10:33:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119602-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-119602-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C93041C66355 for ; Tue, 26 Mar 2024 17:32:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E6901D554; Tue, 26 Mar 2024 17:32:42 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 530651CD2D for ; Tue, 26 Mar 2024 17:32:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711474361; cv=none; b=qU4NjwkC8MZr78IFOjfrewXvMPNDK0EIncu5z5Iiv/vu7ouG5evkWCNMcSVRGnTpzD/bXumBdvjjJb8184RuqsWraoMwQz4kJFpTmfkgDGHr8ElPBQQZL2USKjarDm324+Kk64bwQyBby8MzZGsguMqLeIjaxMa+60bcY/b6U88= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711474361; c=relaxed/simple; bh=vOF9mPa+/P1UOv/ObCzlRrx/mZT31F+P8zDSgXc7/IY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Pry2jBsW1ZLodjf4mRN4yFf/CGMCwe9SH2alXdHSi7dClNsjnincqam6PaT4FWDr660mO2H0Yd34udTmZlinEWy4t3NR9jLwwjj7MrFFyxbAuR7MQudJL8+5ohMIG4hQ/7Wj4wPU5Ul/kvmfCaDyyXhEqZGLCTtIjpzVz9FfhBs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 622C22F4; Tue, 26 Mar 2024 10:33:12 -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 B53323F64C; Tue, 26 Mar 2024 10:32:36 -0700 (PDT) Message-ID: Date: Tue, 26 Mar 2024 17:32:35 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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. > >> >> I think you could only do the optimization you describe if you required that >> pte_same_norecency() would only be given values returned by >> ptep_get_lockless_norecency() (or ptep_get_norecency()). Even then, its not >> quite the same; if a page is accessed between gets one will return true and the >> other false. > > Right. >