Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2775085pxj; Mon, 31 May 2021 10:25:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQHYalTXiwAx6jMqS8dwQq5fISMRdxfmaKcG/6+40tVHPpk3CFsERceM7AaPnuyg3mlPtS X-Received: by 2002:a17:906:1185:: with SMTP id n5mr24109771eja.342.1622481927944; Mon, 31 May 2021 10:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622481927; cv=none; d=google.com; s=arc-20160816; b=wjzhy94uNnWgCQjZbJuVkszPOUi3yzD2JIaJ9nglbb7/VU4Sj6yAdg5gh50uaXL4mz ZLPT+mK1FKltFoVa/Z6t2WdhoZiL5DgrUThmCROFQmtqdlnpxy/SLwmOOsjKtl6oOopO jCFJYO8pWZkV3F/HNe0J2uU7r97n3V2qB5d5WMnbULUdxKFX4SXeyyJmjNoMtXZ6YDr5 StUYsHSzwL/1fo5lDFv66zMawaZ/1tpEkqXo0d+NRf8LNstDa4O8eO+S0nHDF1wqcclo OLmtnm+aEINb8430hKw9iOqb7wtxLFGdi/xeM4k7B9/1J+VaJK+hpZLE2TAEQynJbUXT SrZw== 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=fLx9o42NgDmYQ9T0R4vm13NnGiIWmnmmUmKH29M1lgE=; b=zKzXWZcOQJ2iv5eAvFBuoveaUu/4PZS2AR1SvQhdb3jl6R9tV7cPSJY3uV/aFCPOtC SrceEm69AqRUl7GLBMzOZ2/YopFSXd3RWXX0E5Y7JgYiExrSV8iRb0hEB0l3OVw8orTk pSuX4N9QdZ3Yhr8VqydwZ1jDvifGvD0ijYlZh/j9cpzzkg4xhg7L7cZyi/2HpPSZTpfb vlS954EWsAySkxrRc1S9M6lNzAoApJZG/HIbdwpVnU53OHrtb3O1u+C3g/Ekp9l8BjU0 20WrY/PHWnAjWoLR0ADVNiqmu10Lm48PFAjgjcEhOYyvEhoL0u77lrTmtWbUJgKAv0Rm XW/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uQUmUueC; 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 l18si1409606ejr.283.2021.05.31.10.25.04; Mon, 31 May 2021 10:25:27 -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=uQUmUueC; 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 S233059AbhEaRZj (ORCPT + 99 others); Mon, 31 May 2021 13:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232591AbhEaRZ1 (ORCPT ); Mon, 31 May 2021 13:25:27 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 469BFC0610EC; Mon, 31 May 2021 08:56:14 -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=fLx9o42NgDmYQ9T0R4vm13NnGiIWmnmmUmKH29M1lgE=; b=uQUmUueCLEMAe52ML3MgGtPMvJ MtUD3E2fFFeyXxBtpEMB3qZI2giE9fVtPHprgVt6AP7OfJ6efWrE0xP0BGqbEsKVEKruNpkILZ8+I ozj/EnPtdEVXoQoKFiadDs0TPrRNzXacDMsYwyQJTWFRQSnsJ5ma23GkePYUucrkbELWpa06zle40 5LhbrMMAnPy/X3dDnaa/w1TX/kWe7bbSmal27sMrJxiloJt9iuFkFkuxUL6xjBvdG1GYMuvMJRGQc KjYbLZ98ptBsEqgVI0O5OX09x4ZnUcBigfqCI8ZCCJZ2190k94XWgJOnsVeLg33T0HI3EkBQnoVlT y+p32p8A==; 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 1lnkGD-009Ak1-Tn; Mon, 31 May 2021 15:55:31 +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 57396300223; Mon, 31 May 2021 17:55:25 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 18A392011CA24; Mon, 31 May 2021 17:55:25 +0200 (CEST) Date: Mon, 31 May 2021 17:55:25 +0200 From: Peter Zijlstra To: Leo Yan Cc: Arnaldo Carvalho de Melo , Adrian Hunter , 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210531151049.GE9324@leoy-ThinkPad-X240s> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 31, 2021 at 11:10:49PM +0800, Leo Yan wrote: > Hi Peter, Adrian, > > On Wed, May 19, 2021 at 10:03:19PM +0800, Leo Yan wrote: > > Load-acquire and store-release are one-way permeable barriers, which can > > be used to guarantee the memory ordering between accessing the buffer > > data and the buffer's head / tail. > > > > This patch optimizes the memory ordering with the load-acquire and > > store-release barriers. > > Is this patch okay for you? Not without actual numbers; that's some terrible ifdef soup. > Besides this patch, I have an extra question. You could see for > accessing the AUX buffer's head and tail, it also support to use > compiler build-in functions for atomicity accessing: > > __sync_val_compare_and_swap() > __sync_bool_compare_and_swap() > > Since now we have READ_ONCE()/WRITE_ONCE(), do you think we still need > to support __sync_xxx_compare_and_swap() atomicity? > > I checked the code for updating head and tail for the perf ring buffer > (see ring_buffer_read_head() and ring_buffer_write_tail() in the file > tools/include/linux/ring_buffer.h), which doesn't support > __sync_xxx_compare_and_swap() anymore. This is why I wander if should > drop __sync_xxx_compare_and_swap() atomicity for AUX ring buffer as > well. I'm not sure wth that code is even trying to do, that's some seriously dodgy code.