Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3478140lqp; Tue, 26 Mar 2024 10:07:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVG/8QguMeMooX8Ubnvo7aX17QxXl3ELNxlfMkrgKWsmXhgb1o2KJcJu0g2xI30SKeaKFbkzlLZD8mHgCQHfHlUkILvvErtcTiF/sUW4A== X-Google-Smtp-Source: AGHT+IGSIgLR0HcN4yJxlhbBU9d0KJMim+2gqZ24UDMKmKaUKp4cJdv12NBk/KctqT0OpoCt4x3U X-Received: by 2002:a17:906:169a:b0:a4d:f406:259e with SMTP id s26-20020a170906169a00b00a4df406259emr1305079ejd.1.1711472835055; Tue, 26 Mar 2024 10:07:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711472835; cv=pass; d=google.com; s=arc-20160816; b=JXrD/pkhPiQ4zqk30nwmYB0KXFsP6fS94C+/y2Wu+hod3TXZ3k6h548P2mtvgRVWbf lNxqZKWmkn4lyHUwHNvwl1bmbKCL5ZIy7YsplXzfjWtG4GJtdNEKT2m9y+POE/qfgh4M S4AC4yKM/62MmJYQqNq+uhuuWttSn7V1mcHbmGAnHu1GFa4C9PpvHl1eFVH3IqkuKB7+ /+2VUm7SKsxm9Gff5By6GO7RKX6y5p5AvsOhZKKdaCH+uAIdrLfRw7r7Mv5XUKU2Eycl 8XTh5Z9/rivjCiBcgcLwj0GQ7r9hkwv1wYF0DXdwrRSGVvFhf7BOD5Zk3s2CARk7xyXu rFKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=03P2aTLfOU4JI8jvZfElyWjm8J8f3fb9SGZBFQXPDVg=; fh=CfN+NEvDmmv7vY7y+WaHsymKA14+fsgPbqu1ChDELXY=; b=z2LddCLowSo92aNhNmojq3EO2dDmlRhc777xwN2HJojjB7HiKCQTjP8rGEPrGM1Tlf mFPDIbG3iAk42Hmm4m8Z8wTu+zvZCvXGm39iKMn5NguGLynDyQkWHs3uKkZe7kwSpavD hRhy6tU6dncS5tQS6gufQihpM+0rhnR9Ed9ys3yH0aCCzDXGWLZpvLDmXbGCtUMrrare 8PW0cgPNZzigG9/Jl54+05q2q0okyloPe2Fgy7pS0FhHGcd3tWawVz3hdhFTZLa3lGTb zvzlJs+p8At/aZcJAm0kHTkNkcGwYH1O9X6q86sCqevL5bcp282ZMocqwyfjbeozxPZD edrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Zyc1dPoa; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-119545-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119545-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kh12-20020a170906f80c00b00a47155c49b9si3619549ejb.499.2024.03.26.10.07.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 10:07:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119545-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Zyc1dPoa; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-119545-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119545-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 55D4C1F81AAB for ; Tue, 26 Mar 2024 17:07:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B23913D61E; Tue, 26 Mar 2024 17:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zyc1dPoa" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA6751C697 for ; Tue, 26 Mar 2024 17:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711472693; cv=none; b=KZwLXOMpjOrSmJuZjj+R7qoRmohYTz8Vq2bgANZ7IixrSJSQzrkeJKj7a4GiDq5ztV9oC710cXmWFBs3mFg+wzAcFSpCf6oqCQwNKC28rPED30N/zNKk9zGyeR0W7LM06BQ0Cgs8IAlvc20DUospULG6hkTavuA8X3CWz8LZt40= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711472693; c=relaxed/simple; bh=kpsWRkeiV8YzMY2AI1vNmodJ9g81fNrq7YQw6sCWt+s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=P/xCNx8v5DDubDJms9tyCo02e3UYLfFmAuSCWPgiQIjL4OMzin4kDN5jCaOOkZXAsfNnBHCkP9gCAn05p+eq1DXHqu5/s+TJyRpALkbYdEWMDc8EdiFkbGeI9wmf3c/Vt161yPLMccP+73r2006RmTXWBFJ6dHfUNRZqju0WcJA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Zyc1dPoa; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711472690; 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=03P2aTLfOU4JI8jvZfElyWjm8J8f3fb9SGZBFQXPDVg=; b=Zyc1dPoaXVATyiWkbAd3P2hRqx2v6DOt6zh5TDrsJ6iy1D0EaeZpj2A0b2WrC+qOj6WoUx VtTMbOGNiqO2WAY5r79W1ziW79V28pAr6uMKaQrLuRu5SSXnABEJm1AXdaAgY3mg5zq24C NwxlTKh4XhWShDd4qK3QxR7uH2QzDX4= 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-244-avhHloy4MwiZ4yV8PlC9JA-1; Tue, 26 Mar 2024 13:04:49 -0400 X-MC-Unique: avhHloy4MwiZ4yV8PlC9JA-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2d48d13b3c9so51830571fa.1 for ; Tue, 26 Mar 2024 10:04:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711472687; x=1712077487; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=03P2aTLfOU4JI8jvZfElyWjm8J8f3fb9SGZBFQXPDVg=; b=NiZhgCGiJBUCxx+sRMiJnxC45XGccOAM1CDGD4UcxxtQImOZhbR9dBXL4TlM4xL+fi F3z4Xn4IIVNK2PdyCgAl7g3hI7rpH773aYYh2MvCleBWIICDq11yI/J/aaZiv6yrFYeV Xl+Wm78fL1goFhzwGZKrO38emaZfqeMsKkyUOjYy30I4BiDrEZqnyH3Sa9wcWJetJwaE fo2OmVcZkJzGwxRaEHRtb56TCnenvcD92atQUyjmm4irtUWqQ4oklOEHefF3L3222m5R EGM5HI6OfTJkLA2Ov4QOF21HrpuH5C0K1sDpO2VHKTYVlRGMFbFUYkbA2/fT8eHN3cp9 dsmg== X-Forwarded-Encrypted: i=1; AJvYcCVGaFafuDO46xR+bTlhf2gJc2CijWtXvrIYwY5wzgXXyXy9sY33XbAXiGE2duDtimoqDcrL5QOc7XbcOBfQC4dxMOAtxE9Grn/W7oYm X-Gm-Message-State: AOJu0YwVjynqTKEGZ8oj8UWuZp9LRqjOt9wMWZ/9Wjq8VukjUxA/qYH7 /xu3bTEudYXXUrXJDlKYKuZt9DfuUP6di0BMiNvzJF/5bPUTXbVVqaliFqw6qc6HiEjlhQ1azFm 2v6jrNx3RWU+1AbC3Abg3uU0BshN4l1Yf4cH5s+M0IAdsZj02Q981hI4FRiudncEGBYFyyg== X-Received: by 2002:a2e:824a:0:b0:2d4:5ce6:a98b with SMTP id j10-20020a2e824a000000b002d45ce6a98bmr1535685ljh.22.1711472687624; Tue, 26 Mar 2024 10:04:47 -0700 (PDT) X-Received: by 2002:a2e:824a:0:b0:2d4:5ce6:a98b with SMTP id j10-20020a2e824a000000b002d45ce6a98bmr1535665ljh.22.1711472687197; Tue, 26 Mar 2024 10:04:47 -0700 (PDT) Received: from ?IPV6:2003:cb:c741:c700:3db9:94c9:28b0:34f2? (p200300cbc741c7003db994c928b034f2.dip0.t-ipconnect.de. [2003:cb:c741:c700:3db9:94c9:28b0:34f2]) by smtp.gmail.com with ESMTPSA id n12-20020a056000170c00b00341ddd7db5csm192186wrc.75.2024.03.26.10.04.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Mar 2024 10:04:46 -0700 (PDT) Message-ID: Date: Tue, 26 Mar 2024 18:04:45 +0100 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-US To: Ryan Roberts , 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: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwu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6t1trDQmPx2iP5+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: <374d8500-4625-4bff-a934-77b5f34cf2ec@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit >>>> >>>> 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. 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 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. -- Cheers, David / dhildenb