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: 7219271 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9ED529F32B for ; Fri, 18 Sep 2015 16:47:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DEA4208CC for ; Fri, 18 Sep 2015 16:47:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9EA9208BB for ; Fri, 18 Sep 2015 16:47:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZcynH-0007XM-An; Fri, 18 Sep 2015 16:45:51 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zcyku-0002XH-3h for linux-arm-kernel@bombadil.infradead.org; Fri, 18 Sep 2015 16:43:24 +0000 Received: from mail-pa0-f45.google.com ([209.85.220.45]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZcyVd-0006x4-Rz for linux-arm-kernel@lists.infradead.org; Fri, 18 Sep 2015 16:27:38 +0000 Received: by pacfv12 with SMTP id fv12so56041055pac.2 for ; Fri, 18 Sep 2015 09:27:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b/4GwesJF20tLSO0RQZ2OEI6Ng/SN7aOJRxNnIu3crw=; b=Q7fhx6qQO17AzdoPCYhk3Dl8lqgLqitlqXUk5NJOw10USpqyjK07+k36vH04bPqJhe Bs6pca7io6It0gAWH89bST7ZFIiId0/L5USOBnUoo1uDbNzmCLIiCMHntA9/C5ztam9g T6TDs9aMSNHeWrD6wm7pK4skhI3pDnK/AsP6RLskHRc80og79uliWZEPKnPSNhpjuaBu FWFSqVOWDad+16baJyn++4djyJKfEhSWi6TDGlbw09XvJP8+GpFFsEz1naLStLj9cZbN WLXH8ExeRRXtquRTkZLlLaYEdkB0ba1mrHKNfUV7UGE9MdaWFwqDVfyS6an8iSIXcl/m zTFg== X-Gm-Message-State: ALoCoQkDd+WuED80LiKIXw1TKSKoiva++sn3wZDxfkM95V0fEq9/ytQFDgRIgNy9hr9aS4s/jyeG 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150918_172738_052125_0C4694CD X-CRM114-Status: GOOD ( 21.80 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: al.grant@arm.com, pawel.moll@arm.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, adrian.hunter@intel.com, tor@ti.com, mike.leach@arm.com, zhang.chunyan@linaro.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);