From patchwork Fri Sep 18 16:26:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 53936 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 831D3218E3 for ; Fri, 18 Sep 2015 16:30:22 +0000 (UTC) Received: by wicuu12 with SMTP id uu12sf10851352wic.2 for ; Fri, 18 Sep 2015 09:30:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=fkdJENz6z7v4bL8iaZiERGekXP3wAl72En5vxvQ2P74=; b=fI+NSMUS8GLzi2AD6vlh95+yRuajAUOJAmJuYWv+OVANFKTkIPQ3645VzcnKz59txP qFJCGaOuEk/xwTzGk6pYhwXNc+KMq4mYFiZs1JuOXuMovc53kHWtf8G5TA7tgGA7HFvL QLM79RFgVw/rqomREYi1SoxuYQZU42TIS5Uqku6ijUmgqNglY43I0O0b0QmB7NxCuFbJ na5kFJACqTBUu4l+yBFXGoFBLmCpuDhX5lwYVAhXqKNdKpXjwH08+sTM5nCG4ysk8sy+ 4J1z1O2rN20R6FHIgPOeotuPSh41niH5Dm2mhusoy1noz5XB3i6pHMWot11aNSPQypbN 1UCA== X-Gm-Message-State: ALoCoQl0ynRbG8k7vCarKtBcPL/7xV5GZvRyrwsuoDyWjNJHpjj1HjFMctLr+uGFF30d3wTe2KJp X-Received: by 10.194.240.230 with SMTP id wd6mr1080803wjc.0.1442593821798; Fri, 18 Sep 2015 09:30:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.11.162 with SMTP id ej2ls262766lad.101.gmail; Fri, 18 Sep 2015 09:30:21 -0700 (PDT) X-Received: by 10.112.135.9 with SMTP id po9mr3681125lbb.56.1442593821616; Fri, 18 Sep 2015 09:30:21 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id i8si6749496lam.54.2015.09.18.09.30.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Sep 2015 09:30:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbbmp1 with SMTP id mp1so27859789lbb.1 for ; Fri, 18 Sep 2015 09:30:21 -0700 (PDT) X-Received: by 10.152.5.170 with SMTP id t10mr3529850lat.112.1442593821490; Fri, 18 Sep 2015 09:30:21 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp402987lbq; Fri, 18 Sep 2015 09:30:20 -0700 (PDT) X-Received: by 10.68.200.40 with SMTP id jp8mr8452148pbc.16.1442593817444; Fri, 18 Sep 2015 09:30:17 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jq1si14688069pbc.254.2015.09.18.09.30.16; Fri, 18 Sep 2015 09:30:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932099AbbIRQ1U (ORCPT + 30 others); Fri, 18 Sep 2015 12:27:20 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:33546 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754632AbbIRQ1Q (ORCPT ); Fri, 18 Sep 2015 12:27:16 -0400 Received: by pacex6 with SMTP id ex6so55405117pac.0 for ; Fri, 18 Sep 2015 09:27:16 -0700 (PDT) X-Received: by 10.68.166.196 with SMTP id zi4mr8044660pbb.83.1442593635937; Fri, 18 Sep 2015 09:27:15 -0700 (PDT) Received: from t430.cg.shawcable.net ([184.64.168.246]) by smtp.gmail.com with ESMTPSA id la4sm9847027pbc.76.2015.09.18.09.27.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Sep 2015 09:27:15 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org, a.p.zijlstra@chello.nl, alexander.shishkin@linux.intel.com, acme@kernel.org, mingo@redhat.com, corbet@lwn.net Cc: adrian.hunter@intel.com, zhang.chunyan@linaro.org, mike.leach@arm.com, tor@ti.com, al.grant@arm.com, pawel.moll@arm.com, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 10/20] coresight: etb10: adding snapshot mode feature Date: Fri, 18 Sep 2015 10:26:24 -0600 Message-Id: <1442593594-10665-11-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442593594-10665-1-git-send-email-mathieu.poirier@linaro.org> References: <1442593594-10665-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mathieu.poirier@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Snapshot mode works by accumulating traces in the ring buffer until a user-space controlled event occurs. Traces are allowed to wrap around when the end of the ring buffer has been reached, providing the latest and greatest information at all time. This patch implements this feature by not checking for the end of the ring buffer and setting the 'head' of the buffer to the next available address. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etb10.c | 30 +++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 043e504837d3..b01861588243 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -341,9 +341,19 @@ static void etb_unset_buffer(struct coresight_device *csdev, { struct cs_buffers *buf = perf_get_aux(handle); - if (buf) + if (buf) { + /* + * In snapshot mode ->data_size holds the new address of the + * ring buffer's head. The size itself is the whole address + * range since we want the latest information. + */ + if (buf->snapshot) + handle->head = local_xchg(&buf->data_size, + buf->nr_pages << PAGE_SHIFT); + perf_aux_output_end(handle, local_xchg(&buf->data_size, 0), local_xchg(&buf->lost, 0)); + } } static void etb_update_buffer(struct coresight_device *csdev, @@ -406,10 +416,14 @@ static void etb_update_buffer(struct coresight_device *csdev, * ring buffer can currently handle. If so adjust the start address * to take only the last traces. * + * In snapshot mode we are looking to get the latest traces only and as + * such, we don't care about not overwriting data that hasn't been + * processed by user space. + * * Since metrics related to ETBs is in words, multiply by the * amount of byte per word to have the right units. */ - if (words * ETB_FRAME_SIZE_WORDS > handle->size) { + if (!buf->snapshot && words * ETB_FRAME_SIZE_WORDS > handle->size) { unsigned int capacity = drvdata->buffer_depth; /* make sure new sizes are still multiples the frame size */ @@ -449,8 +463,16 @@ static void etb_update_buffer(struct coresight_device *csdev, writel_relaxed(0x0, drvdata->base + ETB_RAM_READ_POINTER); writel_relaxed(0x0, drvdata->base + ETB_RAM_WRITE_POINTER); - /* update ring buffer information */ - local_add(words * ETB_FRAME_SIZE_WORDS, &buf->data_size); + /* + * In snapshot mode all we have to do is communicate to + * perf_aux_output_end() the address of the current head. In full + * trace mode the same function expects a size to move rb->aux_head + * forward. + */ + if (buf->snapshot) + local_set(&buf->data_size, (cur * PAGE_SIZE) + offset); + else + local_add(words * ETB_FRAME_SIZE_WORDS, &buf->data_size); CS_LOCK(drvdata->base); etb_enable_hw(drvdata);