From patchwork Wed Jun 2 10:30:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12293691 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=-17.1 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 A1190C47083 for ; Wed, 2 Jun 2021 10:32:35 +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 6630961001 for ; Wed, 2 Jun 2021 10:32:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6630961001 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=IgpzJmYeLuWVe3AegScmkGgicDNNqTVdrQUXNmUG/xk=; b=A3GhjcDWHusyV6 yUuOqeUr6lNwBZXjHtWb6Y+Rj2agbG/JDLe+FzFDyqxZmdQjzOh9ehYgYxTE0YKvQgD74iKOh9QAM OXKsIIVwaNoegdvj0m3C9CgMvTEVlCdjmaQ6j25j+9EKr4BGQSWVznLypL/pBHZxwp9b3BarsyCtY NMqW7M4vux9524+dMyGoJvEiyF6ulALWtyqZhxVLOJ/VVjmcnlOWivgWz6U1IfkXmt4mVBpe6InAz x2Q3oMtidJvALoLd1OakXUzQDABZ7vhB1JyVaF7pZ8EOWvw8P38+vrdg72el+b3zfHQGH/bD/0DGI gI0narhPs2XSQdDOvtyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loO91-003L4z-2Q; Wed, 02 Jun 2021 10:30:39 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loO8i-003Kvo-F2 for linux-arm-kernel@lists.infradead.org; Wed, 02 Jun 2021 10:30:26 +0000 Received: by mail-pj1-x102d.google.com with SMTP id l23-20020a17090a0717b029016ae774f973so854331pjl.1 for ; Wed, 02 Jun 2021 03:30:19 -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=E6SPovOHBtUbXkJg7El86KoYgfeSSGvNOlrRgDOrmu4=; b=uIYsbANVkfRPocwkidwIxFsUj4EELWKStycxreDCqHyqcYzc/3Z/om6cNf2/yKEgIh K2NUGZyriiSZlXC5UjCpsTpkMoH3lxhSA7dE6vybOMJhLGwKTmNGh4WJOX7oUBdX6Iss wkMxNAUQrNkzWre9PDi4XWqKX/aNc1MAKwh9YSBCdIKkVSTky9doZWo3946iLDSows2A t65O+KTLicVJsh/jS676OAyHzsDB3CBKg1v0Wls3gzqnGClhBfrvDauo7Qve2N6b0+kF JZZpg/B/dRWFyII48ydPFLjPK59g3+S8dpyO07o3rOYo8xR6MyGVnMsQTt4tPQcuoyhs 19PQ== 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=E6SPovOHBtUbXkJg7El86KoYgfeSSGvNOlrRgDOrmu4=; b=GzKmWCjQ7EaNpBbOB/9WTV7S6xtEI5h4wlM+UYnOJiop2sCZvuxDsNluBOnkKK6ceP hfvDATKowEcRUDyHlTmir02v9ZwYDVCINlDhvBV1nLiUH0GZwvFG8iS2JZl2mldcJMZl 2VFHiqc4wSU/zr/69q1jGuRbGd00GIdNvsO6npvAXwpy8RuI+uj22Ueg0lJk2iifEUpc 7lxuYBbO1wPyDkeOpNkLEdiXudVuOrDSqbuHgCibJeowdLy0B5duuwfFrdsoH4S54fmk 2kROcScKAsdrhq6WAztwhisBJ/+x41Y6wboccxYKo2Jg1NhBwV0T2VPYWo9zNYhhZKYd ZPAg== X-Gm-Message-State: AOAM530JGi3ebRRwdevJKZMCw6q8SfChsM02sAfLuwtCJzW5WElLnUPU LxaOeey+vX5EunVYJklcua6qyA== X-Google-Smtp-Source: ABdhPJypMAbuBZG8MpOxNAfRGmm0a0kTxcE/hJEHUnjt0C6+DenxeNnqX5nLl8TpcnU94jpwrTSMfQ== X-Received: by 2002:a17:902:b713:b029:ef:b031:2a9c with SMTP id d19-20020a170902b713b02900efb0312a9cmr30196100pls.22.1622629819320; Wed, 02 Jun 2021 03:30:19 -0700 (PDT) Received: from localhost (ec2-18-167-84-74.ap-east-1.compute.amazonaws.com. [18.167.84.74]) by smtp.gmail.com with ESMTPSA id o24sm16696451pgl.55.2021.06.02.03.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 03:30:18 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , x86@kernel.org, "H. Peter Anvin" , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Adrian Hunter , Andi Kleen , 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 v2 1/8] perf/ring_buffer: Add comment for barriers on AUX ring buffer Date: Wed, 2 Jun 2021 18:30:00 +0800 Message-Id: <20210602103007.184993-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210602103007.184993-1-leo.yan@linaro.org> References: <20210602103007.184993-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-20210602_033020_518736_423BEC80 X-CRM114-Status: GOOD ( 15.78 ) 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;