From patchwork Sun Jul 4 07:16:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12357223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72CD9C07E95 for ; Sun, 4 Jul 2021 07:20:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2CDB561936 for ; Sun, 4 Jul 2021 07:20:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CDB561936 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Umq2exi3lbU77HMZf7Gh9xA6qWF7amTbsrGZKsJjwGQ=; b=j21CCOSAAhEBmC j4TSiUfqSqXeyfo6+iiOqpWo7AxVrryK2DVsyGEhUVZiXR7kTStjWDobF4MU2Ti+UWMV62yYJKJ5V MM+h/HLMIlW1BMeGTIK5FZXR7VMs3Wxahid4n0+YWvgGlpzj5o9mTnnA/hxVfibIz7/GBZ3M7GZyY 0jfD+RhD9WhRIbWp2PI0v+j1T3ISzk8Bj8HRFuTR0VifcCB3pWVdnnstlol33ENPe6sNCJSlhgwlD IyDqVsqAgWycWvz25xUOuaSdqTkN1npJrbOuCm95EVRo/lDv5z4gXqyvmZOBdLbxV/0QtotffvyLo 2qbNzuxXpzZYq/lWaCgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzwNX-005rOX-VT; Sun, 04 Jul 2021 07:17:24 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzwNK-005rJz-9W for linux-arm-kernel@lists.infradead.org; Sun, 04 Jul 2021 07:17:12 +0000 Received: by mail-pg1-x536.google.com with SMTP id m26so14909890pgb.8 for ; Sun, 04 Jul 2021 00:17:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mUfdU9WBYmi8/NBmndyLWLFFhQ6mqBUwjCh/GuP5qb8=; b=HF78Ns2KJ94lBFHkqHHYvCYHD4XrlhN8LrnvJOs4SzJEbXQLwLgpWDt0zU6kv9thCu gdLazU3mmrvpTorsHnLibdESJswhC7Ied5jYBfhzPiW58xbfw5eAPfe1mVMpniRzfofV +J+ihmTl+sjPqr720iwqV6ZqP6s0SpNdLr3sGr1iz5fVo1rh3ib+OWocNyxehHC6ZL8t oquO+TcF2/bdRIX+rLF/ytpAptqJ7/eBCGJxFrTa0XwsX4tLt95P1Xd2bg1/jOn2osH2 tSVXGkxAjKtOsk2uUj3BWHJt5y4nI42fVH36oP0b7Pnyt8+b+M5gqyaWIBA3vLVmE+30 aHmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mUfdU9WBYmi8/NBmndyLWLFFhQ6mqBUwjCh/GuP5qb8=; b=S4zkDjCjOCm8DD65BF6UN6zGRSLi1ZWJqf1Szgn4l06AjdCdRnutARXI0mXl9vOqhT 1pHkKifGlYRKSJf7/FomoGnkY9ajY2KnFF+hiWGhfjID/ECrQoqf+6FDuDpo7rroLgMe q2aeOL7rQIDGx0T78KstpLgYCLUY7OfXuZEYUcCjapRPXBtXLF3IAnjDUOsBoPkOmIs2 zvXBDuW49b6vCj1MYyAJ3hmYUkqLate6j/oMGbajChdhDJXT0K/jb3WMLkhwE2LHvyOI 37U0W6RB4m7ob/C9YX0mfDxDRE7TSr3TLqSBsBfeBVOI4ScYpQ5F2vxi9ZjkqGf+IeTu 4YJA== X-Gm-Message-State: AOAM531Y7MlZUZZcuhzvDygo61d5etEylNE4E3K0EQsyUo+zaKKoCkT4 1YGcD+6aGZWGnZ60WJiphxIUZQ== X-Google-Smtp-Source: ABdhPJxikogZ+NeiWmhynh68p62mZPKUnJOdPzdcYP2HqwkcqPAR8k719kBsv+JqyjlFHGxFOLDWGA== X-Received: by 2002:a63:f515:: with SMTP id w21mr9167878pgh.343.1625383029524; Sun, 04 Jul 2021 00:17:09 -0700 (PDT) Received: from localhost ([103.207.71.35]) by smtp.gmail.com with ESMTPSA id d2sm9657731pgh.59.2021.07.04.00.17.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jul 2021 00:17:09 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Peter Zijlstra , Adrian Hunter , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Mathieu Poirier , Suzuki K Poulose , Mike Leach , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v3 01/10] perf/ring_buffer: Add comment for barriers on AUX ring buffer Date: Sun, 4 Jul 2021 15:16:35 +0800 Message-Id: <20210704071644.107397-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210704071644.107397-1-leo.yan@linaro.org> References: <20210704071644.107397-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210704_001710_378705_E048ED4F X-CRM114-Status: GOOD ( 15.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org AUX ring buffer applies almost the same barriers as perf ring buffer, but there has an exception for ordering between writing the AUX trace data and updating user_page::aux_head. This patch adds comment for how to use the barriers on AUX ring buffer, and gives comment to ask the drivers to flush the trace data into AUX ring buffer prior to updating user_page::aux_head. Signed-off-by: Leo Yan Acked-by: Peter Zijlstra (Intel) --- kernel/events/ring_buffer.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 52868716ec35..5cf6579be05e 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -509,6 +509,15 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size) perf_event_aux_event(handle->event, aux_head, size, handle->aux_flags); + /* + * See perf_output_put_handle(), AUX ring buffer applies the same + * barrier pairing as the perf ring buffer; except for B, since + * AUX ring buffer is written by hardware trace, we cannot simply + * use the generic memory barrier (like smp_wmb()) prior to update + * user_page::aux_head, the hardware trace driver takes the + * responsibility to ensure the trace data has been flushed into + * the AUX buffer before calling perf_aux_output_end(). + */ WRITE_ONCE(rb->user_page->aux_head, rb->aux_head); if (rb_need_aux_wakeup(rb)) wakeup = true;