Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3226036pxj; Tue, 1 Jun 2021 00:01:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5iClayC584nc+jZRXd3GqNPgIOTeXFG/CaHpEp8ELQ7SU5iuSCMynDC7DluqRh/hLF6eg X-Received: by 2002:a17:906:1185:: with SMTP id n5mr27481194eja.342.1622530877206; Tue, 01 Jun 2021 00:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622530877; cv=none; d=google.com; s=arc-20160816; b=T1CPTBbRz/XsG7SZYoDRQJIOzUWZe21LBe1QwQdk2Y0MbPeNW2L76drGbOMx6JC6kY Dh4uWrtfLSxCk/qGmP9CBNRrRXYO1y6AQsElkehzL8ZLKtCdeQIXbcjA4VhoD5Vgb8Uv wb9kISBd8ezZkFin5A8BWDPREunlf8K5NIJ8NSe5c1Tpvf6DtXuMQAS8mu0HGGJb/ia0 g3cPsk1DWU78I7ze3oDBkYviXgaAkYPJRpk888FMZwTMglZxLM/jcg8PzS2B6qZgtTgU S5M4WQT1wPFVL2XylqBL+sjjdcF/V1At3JYMyepJn6+8fcsAl0h0kl/zbuBB0GWqRNZg V+fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0l2yYQsJKshGfYOkmILgyUlyXhH0uHawPd3uvuaVdjM=; b=Jh/oCVpCr/sBI8EILhc9JBAGW3iPrqPuSY5/Gs1dzMMJ06Kfba0/ZMkJQLKLS0vBPS vQiyiJgq/q1ePnxw5BZqCcKIrP8bzPZ2sv2aNr1n1lMSsXm4R6xt7uo2Dl00gqPBkgg5 zZ2S0ZuLnlyTcMXzFYlMAhZ6pH5LUrXYEz8FmJaOOgXfRqrwcPPu94i92GqO02iKwLJi UcZGLa49d2JOZwGtL7WGeU4An44f0buf0YZQ2TfZO/5VRS+E8D506j2tNcr8VDX8o+yl P19AABWb0GQXrGo32sBN+LanBZWp6hJ5ePmeIpuppfHRtPuEHRaKuGkEIcfvDSvBXgqi axNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=k4IBvCxu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si7630901ejc.216.2021.06.01.00.00.54; Tue, 01 Jun 2021 00:01:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=k4IBvCxu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233054AbhFAHAj (ORCPT + 99 others); Tue, 1 Jun 2021 03:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233030AbhFAHAi (ORCPT ); Tue, 1 Jun 2021 03:00:38 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DD25C061574; Mon, 31 May 2021 23:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0l2yYQsJKshGfYOkmILgyUlyXhH0uHawPd3uvuaVdjM=; b=k4IBvCxuSl/cf3JYsEuCg30doH NVZXR6Yd2MqaEquUWs6A+cNso2m+KF0VSIW5qrLXOZdgEI28CMTG20Q3taB8n10nEuPAQSZaA6hmM vu2BZiUjBSHYqRVppoBpoB24mcTLdPkMWrcBhPhZso/aOEOwf6Y3zzECWNxenMV5tlsySEd1J0PP4 SLpO4668CFUvfVkW4veDHNiPG5oZhPNbZAIFixGXYXCSrF8l1SmIsVjkgkeoThtYg9NkN0hjrlRT3 5pB2zBJ470/tiOxr6Mq8/iiJF/9GbUIzblC4nuDrScPiMcxbokqu+mK6OsQURH6ia6VcLjavc1R9H /OUHZ/CA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lnyMG-009lrX-4B; Tue, 01 Jun 2021 06:58:38 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A9B0930019C; Tue, 1 Jun 2021 08:58:35 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 845732011CA24; Tue, 1 Jun 2021 08:58:35 +0200 (CEST) Date: Tue, 1 Jun 2021 08:58:35 +0200 From: Peter Zijlstra To: Leo Yan Cc: Adrian Hunter , Arnaldo Carvalho de Melo , Ingo Molnar , Mark Rutland , Alexander Shishkin , Namhyung Kim , Andi Kleen , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 2/2] perf auxtrace: Optimize barriers with load-acquire and store-release Message-ID: References: <20210519140319.1673043-1-leo.yan@linaro.org> <20210519140319.1673043-2-leo.yan@linaro.org> <20210531151049.GE9324@leoy-ThinkPad-X240s> <20210601063342.GB10026@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210601063342.GB10026@leoy-ThinkPad-X240s> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 01, 2021 at 02:33:42PM +0800, Leo Yan wrote: > > 32-bit perf wants to access 64-bit value atomically, I think it tries to > avoid the issue caused by scenario: > > CPU0 (64-bit kernel) CPU1 (32-bit user) > > read head_lo > WRITE_ONCE(head) > read head_hi Right; so I think Mark and me once spend a bunch of time on this for the regular ring buffer, but my memory is vague. It was supposed to be that the high word would always be zero on 32bit, but it turns out that that is not in fact the case and we get to have this race that's basically unfixable :/ Or maybe that was only the compat case.. Ah yes, so see the kernel uses unsigned long, so on 32bit the high word is empty and we always read/write 0s, unless you're explicitly doing daft things. But on compat, the high word can be non-zero and we get to have 'fun'.