From patchwork Wed May 1 17:50:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10925457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4E381398 for ; Wed, 1 May 2019 17:51:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B535028F44 for ; Wed, 1 May 2019 17:51:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A995528EF6; Wed, 1 May 2019 17:51:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 259F228F2E for ; Wed, 1 May 2019 17:51:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=p7MEl4KdoPB8QPYXZUck+5uCRxXnHNoF7x/kg6ucybA=; b=b3JA+qLxMNnACz8hjuIJIWb4Go uDMA/V0AeTyXze+8KogXIR6kzSJ7q9J3qh0BK5APou8KGOLJd3YsBlAqsdhr3AsD+QV1kt0ueYGxZ i+iPn+VKqSrWKqpG8/zDIRFrXjAo8oO+6YggmJKdCFnorMsw7GI71IW+kbq4n8WBYcWbn0aq3bRDp A5Ys/FBFyQ4Tqq54Hb84YbH+OJx2WXuxyqIwkJUm5fWkGV+BSQud6F56WnqOtHxB9l8qeMCsrrNCz kQ5I2qcdTrfK40NShhAjwrn5Bcd2lVzI4dk1fblZNC/OrTk7t/nG95r9ar6eQe5duc0hH3mbqzm2d 8xuT2i8Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLtNq-0004mX-9x; Wed, 01 May 2019 17:51:06 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLtNg-0004dM-VC for linux-arm-kernel@lists.infradead.org; Wed, 01 May 2019 17:50:59 +0000 Received: by mail-pf1-x442.google.com with SMTP id e24so8911249pfi.12 for ; Wed, 01 May 2019 10:50:56 -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; bh=LY62M99zAzqSXCRirzpPXw/lRdNFS0ct7uspQVWkTaA=; b=h7+OifeNwrUAelMopBO38az9mLQTlTmyZOo9lRphQ3uHEgS2vAPRP7QT3u+9V/yn8Q svUGUzZD7ztBHoox25Z1PGErEuyzPNnC/GjprnxyRB8A/kGJpoEhAnoaQpJUV3uEoUrB fZhVK1V+OGTKTcQMvomjugDMY8maLUbog2cPRzcCyLiXq5EMTLhs4uIe4i6TOPxi5Wsy aUsPj1brdIiTmp/QngxOx20azueHZt9qtJKSYPpIGYkkixWXcWcs7UYNN8gH3d+MXeLR TmExHbhCW0PTY5Nisrg1o24pXNy351UFd07KsbS56mp/nqgTiEl38Xqpw+cLWQBhgJbe iprQ== 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; bh=LY62M99zAzqSXCRirzpPXw/lRdNFS0ct7uspQVWkTaA=; b=qHXjnwDAagv+eNDpNdulVVK9UlD+2QM8ymjteyV0WGHRZKQ8nmL+Wx5kjoKSq6tY9+ nvwS6OyWSHX9vxu37Ld/XIcnzSk+z73/0scL2nJXPQeJ/XKNTKZsBLE21D7k1geqc2af K+L8/rhy8YeEKyOeBDF/BZfemBSqVOfVveQHueCNgaQKHnaaZ3L54++3hxW1e7JWRe1i viDOVWV455GdYLmg6ffthkO9BgbVddqQVIxDmijIH6R4BEVUive+JmhED7+eFZPsaoQ3 Xeqj8KR20qhg9USp1AYKdTLkoqMqg4sjyIbY6Ew/0Ty2mg/vok/J8BdvrlicvWemPT2b o48g== X-Gm-Message-State: APjAAAVFcncbWKoAX807QrA56RCol67cgOjJotrCWjJ+7lTogKegqhNY 3utKMwLsh16ls8sPBGbteexYyJFq2UM= X-Google-Smtp-Source: APXvYqxLE4fYvGCctomIFSpKPbeKr7s3AvEJ9rY2FbqpZw6VG8yO92Bp2wAbJ6e3LZUPx0vNUsYnZQ== X-Received: by 2002:a63:6b08:: with SMTP id g8mr75049037pgc.211.1556733056177; Wed, 01 May 2019 10:50:56 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h189sm84126158pfc.125.2019.05.01.10.50.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 May 2019 10:50:55 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/5] coresight: Fix buffer size in snapshot mode Date: Wed, 1 May 2019 11:50:48 -0600 Message-Id: <20190501175052.29667-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501175052.29667-1-mathieu.poirier@linaro.org> References: <20190501175052.29667-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190501_105057_000585_80A41AB1 X-CRM114-Status: GOOD ( 16.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: corbet@lwn.net, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, suzuki.poulose@arm.com, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, mike.leach@arm.com, leo.yan@linaro.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-Virus-Scanned: ClamAV using ClamSMTP In snapshot mode the buffer used by the sink devices need to be equal to the ring buffer size in order for the user space mechanic to work properly. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etb10.c | 23 +++++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etf.c | 20 ++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 8 +++++-- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 4ee4c80a4354..0764647b92bc 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -374,7 +374,30 @@ static void *etb_alloc_buffer(struct coresight_device *csdev, int nr_pages, bool overwrite) { int node, cpu = event->cpu; + u32 capacity; struct cs_buffers *buf; + struct etb_drvdata *drvdata; + + /* + * In snapsot mode the size of the perf ring buffer needs to be equal + * to the size of the device's internal memory if we want to reuse the + * generic AUX buffer management mechanic. + * + * For example (assuming 4096 byte page size): + * + * # cat /sys/bus/coresight/devices/20010000.etb/mgmt/rdp + * 0x2000 + * # perf record -e cs_etm/@20010000.etf/ -S -m,8 --per-thread $APP + * + */ + drvdata = dev_get_drvdata(csdev->dev.parent); + capacity = drvdata->buffer_depth * ETB_FRAME_SIZE_WORDS; + + if (overwrite && + ((nr_pages << PAGE_SHIFT) != capacity)) { + dev_err(&csdev->dev, "Ring buffer not equal to device buffer"); + return NULL; + } if (cpu == -1) cpu = smp_processor_id(); diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 2527b5d3b65e..7694833b13cb 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -380,6 +380,26 @@ static void *tmc_alloc_etf_buffer(struct coresight_device *csdev, { int node, cpu = event->cpu; struct cs_buffers *buf; + struct tmc_drvdata *drvdata; + + /* + * In snapsot mode the size of the perf ring buffer needs to be equal + * to the size of the device's internal memory if we want to reuse the + * generic AUX buffer management mechanic. + * + * For example (assuming 4096 byte page size): + * + * # cat /sys/bus/coresight/devices/20010000.etf/buffer_size + * 0x10000 + * # perf record -e cs_etm/@20010000.etf/ -S -m,16 --per-thread $APP + * + */ + drvdata = dev_get_drvdata(csdev->dev.parent); + if (overwrite && + ((nr_pages << PAGE_SHIFT) != drvdata->size)) { + dev_err(&csdev->dev, "Ring buffer not equal to device buffer"); + return NULL; + } if (cpu == -1) cpu = smp_processor_id(); diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index df6e4b0b84e9..b9881d6d41ba 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1188,9 +1188,13 @@ alloc_etr_buf(struct tmc_drvdata *drvdata, struct perf_event *event, /* * Try to match the perf ring buffer size if it is larger - * than the size requested via sysfs. + * than the size requested via sysfs. In snapsot mode the size + * of the perf ring buffer needs to be equal to the allocated + * size if we want to reuse the generic AUX buffer management + * mechanic. */ - if ((nr_pages << PAGE_SHIFT) > drvdata->size) { + if (snapshot || + (nr_pages << PAGE_SHIFT) > drvdata->size) { etr_buf = tmc_alloc_etr_buf(drvdata, (nr_pages << PAGE_SHIFT), 0, node, NULL); if (!IS_ERR(etr_buf)) From patchwork Wed May 1 17:50:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10925459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC99417E6 for ; Wed, 1 May 2019 17:51:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BE6628F31 for ; Wed, 1 May 2019 17:51:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99C4428F2E; Wed, 1 May 2019 17:51:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 497C128F3E for ; Wed, 1 May 2019 17:51:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=E1PtMfje7KYzmkCoIno/ecmfVXaVDFuBveSDT/U0sE4=; b=BAXGcakCw23su3X6vYCuWsR1ua eRtdO10zgUhHKP/yiMGe9NBJkZk+lGTMnDqwMFpo8gaURHvMpDDKk5FI9nTRopNcNfImU+Tz4g5G1 Rah25HvXDRNmOLDUradHsXIh9qgmZodkx+yxmmlplfIBkRwxDQossMnlsY6TRtFmfy89vwl/V2G/B 4URksgYfrV8dItegjaXnactwDot96hxHV4ufYuVVQCXakncVsrlnLAUh5gPkZS0dWGVwoDcLtdLLw aHFdXWn+LwMn4q2AEBeTIVt/7M5f+8GZEQTmCx4MSnVXZONvG/dCNlqIwhn0k4IiohrReSS41kk7y 7has5qvg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLtNz-00050N-Q3; Wed, 01 May 2019 17:51:15 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLtNi-0004eI-A1 for linux-arm-kernel@lists.infradead.org; Wed, 01 May 2019 17:50:59 +0000 Received: by mail-pg1-x542.google.com with SMTP id h1so8608514pgs.2 for ; Wed, 01 May 2019 10:50:58 -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; bh=kd687xUfwu2tTznDRHQYY7AXXvI5mbA8Lm//P4XllGs=; b=TdQLrpAxbsn7JSIJqhHxxBvYgGNzuUXavpKLvm1grU4ZRRhw7JWRRMbWIoiTF3fP1O c+I1WSvaw4TkPLsnZRB/v10bmDIV1NjgQSyglyaZXbyFo3W9URSDuxec4lu1JyhkehZf YtowvaMMisC5FNl+UchX0C1bLwrZtNhz3BE5L/5d0xyMzFrtS7vGqULHs7ryrGnqIeY7 0ONmVoyslv6x9nYY+UwDbxJ5X2iQ1F6siObRGNP3YhikO27TDketjkOKMZxQkAqBtbRK 0++Z5PHj6Sg2EEDPii2B89ve9JHvVYFfdNPtrTUGNea2nXRZ+oZq1ui7ED2KUsK+5b0c pN1g== 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; bh=kd687xUfwu2tTznDRHQYY7AXXvI5mbA8Lm//P4XllGs=; b=hri7VdmRcbfBCHMA6FN5o4iK6+aY6/hLvNVydQ+38VbRWm62bQwmVgYBaIdfHdT8he PhTAG+Rja3HRmoiknHxz6gZ3c/fMS2kxxs3XHgAEv/3AjHrjkJi7ZXOa9nXujIjB9WvH E/GUfm/PYBDD6aC5bfH11SUCK1Mudr6ah02mVSOEXOgbCYslOuHk9kUSe9QRWBA3gb2R sDp8IfLmsZurKmArDDbb9PaMp59MT5NMTP+mnWNebGEX2Iuv8iRSLlzq6zALuh/gq8LK i/2RQiUvhdhQFtuIezfMjbBrKciJ9QdahrTbp4foj91viVp33lOnArPil4sEou1wLp9o GGlw== X-Gm-Message-State: APjAAAVq5n/kIUSs0rrWoOaPFaBQXYqS/2fMZLGpzX7rEDtjHRhmBlaw B+Z2BkNILlkX+YMeiHQ6pQBHrGGuX3I= X-Google-Smtp-Source: APXvYqx3YWQtgjwkex5mg+Droum0Eqo+dOHJSDMk6e2/4G89/M8qZ7uI5GfHKW27Ymk6/7UiBg0DeQ== X-Received: by 2002:a65:5106:: with SMTP id f6mr75725834pgq.253.1556733057477; Wed, 01 May 2019 10:50:57 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h189sm84126158pfc.125.2019.05.01.10.50.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 May 2019 10:50:56 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/5] coresight: tmc-etf: Fix snapshot mode update function Date: Wed, 1 May 2019 11:50:49 -0600 Message-Id: <20190501175052.29667-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501175052.29667-1-mathieu.poirier@linaro.org> References: <20190501175052.29667-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190501_105058_414518_1624D748 X-CRM114-Status: GOOD ( 13.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: corbet@lwn.net, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, suzuki.poulose@arm.com, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, mike.leach@arm.com, leo.yan@linaro.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-Virus-Scanned: ClamAV using ClamSMTP When working in snapshot mode function perf_aux_output_begin() does not set the handle->size because the size is expected to be deduced by the placement of the "head" and "old" pointers in user space. As such there is no point in trying to adjust the amount of data to copy to the ring buffer. Signed-off-by: Mathieu Poirier Reviewed-by: Leo Yan Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 7694833b13cb..d3025634f5e6 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -497,9 +497,11 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, /* * The TMC RAM buffer may be bigger than the space available in the * perf ring buffer (handle->size). If so advance the RRP so that we - * get the latest trace data. + * get the latest trace data. In snapshot mode none of that matters + * since we are expected to clobber stale data in favour of the latest + * traces. */ - if (to_read > handle->size) { + if (!buf->snapshot && to_read > handle->size) { u32 mask = 0; /* From patchwork Wed May 1 17:50:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10925461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2ACC17E6 for ; Wed, 1 May 2019 17:51:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2A4A28F19 for ; Wed, 1 May 2019 17:51:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E101E28F23; Wed, 1 May 2019 17:51:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7259F28F33 for ; Wed, 1 May 2019 17:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ypBR/AZkTUtu999s4NTujBQNUHKHuu2Cgxj91d2VkOI=; b=J+05+rQybb24VAxWGDdygAY4wk K8KfguYSeryf/H1b/4DiDfYJ8dt8p/qZnXpjgwvs1A5oJclH9CBnW8X1D3EqI0nxavUkXSyEay+0t YbxYkj3cS1GKvaRtAZXvmH8R0GrIZd/cs/JBLVHuL2VGXxBiCg/1HiGQdm8A6UClLUFnubIC5GpLk 9yZfqNhwyL+jsAFh/9w8/24NHiwggXjmhZ2XQ1q+5qaEgiTZ6q1IcvR6UFFNsslLK/vjcR9By9+iJ kmHKtLZWBhvgD7fPb7mlSPotfdSmnqQZMUg10/mMFBLWA3n1AyYUcPOgAiVzLEsS99eBFAqK0ae+o jSEfEAlw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLtOA-0005CP-0h; Wed, 01 May 2019 17:51:26 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLtNk-0004fq-AX for linux-arm-kernel@lists.infradead.org; Wed, 01 May 2019 17:51:04 +0000 Received: by mail-pl1-x644.google.com with SMTP id x15so8491458pln.9 for ; Wed, 01 May 2019 10:50:59 -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; bh=GsY2ki4OBIaGx9MWfy2kyzvHrmNKu79KOYeMJ98kbRo=; b=BkynFBxUmeswyRgkryl9Jp3ACLOBIQaauG2RH1XSRhcvuen/g/EQxPjI3iS8Fz8WZW OdVCNPxIMTOGtohX09joNna3sIqnhzRXr1grNqISY1vd9DCjNNUqGEIRkhehbuyzfNpr 5i0ADrSeJT0MpEgrpSGZq1Oge44uohQmYWdF+3xOkLZJbdqtaSgjWEvPi4bhvPJRIKf2 LqPB1O/U0w3omCH8AP72KD56kafdutL30ufipMBfxY6xWeEKj9sDZYqPj1Nze/sIwc0N ylahbXHEeG4o0ovI+RCb2tRHhCGuF7iBnChTU3WCwd7LZVJ3Ei6/ej1Foh0WtGkGuqom SBTA== 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; bh=GsY2ki4OBIaGx9MWfy2kyzvHrmNKu79KOYeMJ98kbRo=; b=rdW4AvJ7A9pEQe8zL3RFutQFmfM3FCo46FT681rMRgyZ3NYUbDMKmo20n5TBeBcxAR NSIIMS3eaP4pdzd8FymTytUgp50T9ZwlhV1MIXY6qQczgTlauimd4nh08vEU3TJpm17W c4mSneYXOr2pNZw+3LWvCaeiODY3FSesRo2oVXTO+XBOaiAHRGgRBFu9y20TjeN5uQFl KUJLbA846VQ8DZ7CrbGghpRFiThgRGYqIW5+fR12vuUYpypVFdGvyO+rSTVZRTWPs7mQ CN6rg9L2lcHqwO7jwaEprk+ofsXMwSjS6JAIauIixX9vgySDcSN5IEKUnWkpJ9QleDc8 26fw== X-Gm-Message-State: APjAAAXyzwA/6bOEpnMKQP1XBxCLUX7Lpk9VCZD+50bGKoP8ylgdlPU9 X+o4dMWxHW3MJPMz4U6kKQc1fgGKdtc= X-Google-Smtp-Source: APXvYqx8H37R23MSXv3SvmmMdhyx13zfKNUUyEkGwf8oUW9Ie3NZmVSqK1y8Oqgo4RvVgN7AlByBlQ== X-Received: by 2002:a17:902:6b47:: with SMTP id g7mr31834843plt.227.1556733058816; Wed, 01 May 2019 10:50:58 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h189sm84126158pfc.125.2019.05.01.10.50.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 May 2019 10:50:58 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/5] coresight: perf: Don't set the truncated flag in snapshot mode Date: Wed, 1 May 2019 11:50:50 -0600 Message-Id: <20190501175052.29667-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501175052.29667-1-mathieu.poirier@linaro.org> References: <20190501175052.29667-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190501_105100_659574_86C42A75 X-CRM114-Status: GOOD ( 12.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: corbet@lwn.net, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, suzuki.poulose@arm.com, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, mike.leach@arm.com, leo.yan@linaro.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-Virus-Scanned: ClamAV using ClamSMTP This patch avoids setting the truncated flag when operaring in snapshot mode since the trace buffer is expected to be truncated and discontinuous from one snapshot to another. Moreover when the truncated flag is set the perf core stops enabling the event, waiting for user space to consume the data. In snapshot mode this is clearly not what we want since it results in stale data. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etb10.c | 8 +++++++- drivers/hwtracing/coresight/coresight-tmc-etf.c | 8 +++++++- drivers/hwtracing/coresight/coresight-tmc-etr.c | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 0764647b92bc..6ff48be91f61 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -535,7 +535,13 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev, lost = true; } - if (lost) + /* + * Don't set the TRUNCATED flag in snapshot mode because 1) the + * captured buffer is expected to be truncated and 2) a full buffer + * prevents the event from being re-enabled by the perf core, + * resulting in stale data being send to user space. + */ + if (!buf->snapshot && lost) perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED); /* finally tell HW where we want to start reading from */ diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index d3025634f5e6..8039bd389034 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -538,7 +538,13 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, lost = true; } - if (lost) + /* + * Don't set the TRUNCATED flag in snapshot mode because 1) the + * captured buffer is expected to be truncated and 2) a full buffer + * prevents the event from being re-enabled by the perf core, + * resulting in stale data being send to user space. + */ + if (!buf->snapshot && lost) perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED); cur = buf->cur; diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index b9881d6d41ba..718586a083af 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1516,7 +1516,13 @@ tmc_update_etr_buffer(struct coresight_device *csdev, lost |= etr_buf->full; out: - if (lost) + /* + * Don't set the TRUNCATED flag in snapshot mode because 1) the + * captured buffer is expected to be truncated and 2) a full buffer + * prevents the event from being re-enabled by the perf core, + * resulting in stale data being send to user space. + */ + if (!etr_perf->snapshot && lost) perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED); return size; } From patchwork Wed May 1 17:50:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10925463 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4510917E6 for ; Wed, 1 May 2019 17:51:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35B3528F23 for ; Wed, 1 May 2019 17:51:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3416328F4F; Wed, 1 May 2019 17:51:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E0D6A28F3A for ; Wed, 1 May 2019 17:51:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=XF4+mDuO86mb3wY40mNU6uQgLv0ynaTSR99eIxiCuZo=; b=BVGaGZG5O2yCygY9EeocZ2Taf7 Ki5VwMaeayxAfyCgeqwNmWMMcZV6jZltd0IoAPA+SetQ4mlwIWx8IIi8F6Ia1ryVtId1RmEYZot6s WvC5p93FdsTaVDeKuUepanQ+rxv4f8Jpf/j1Aznr/oYnM8t1UbLiJQ+1avfE8CCKynbDuCJ7BGNDJ q/1iWerEeMMI+efT14goh6vmeFJRBlT70oNsy+e+K9FUULFoUT2cCpFjXAAc2u/p+22Mi3EyNE5dG K29ERsfgeSR8T8a4UDCg++U8FRdyi0U+1g/pjzmbRH4AR/jWyx6O6Vl1bKByJ+umrje3M7xpotnom 08IxDTPA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLtOM-0005SY-F6; Wed, 01 May 2019 17:51:38 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLtNl-0004hz-Vj for linux-arm-kernel@lists.infradead.org; Wed, 01 May 2019 17:51:07 +0000 Received: by mail-pf1-x444.google.com with SMTP id b3so8934862pfd.1 for ; Wed, 01 May 2019 10:51:01 -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; bh=GN4+0p/L3u2M+HZm8tAOQv4Zavm+OMyyNRfyf0dzvkc=; b=HG2RZ5WtsrGHNFuixMjTIy/E9G+nJ4rhlf2m91uxf6UXeb/JQWpiDXRhlVGj1dqYDw oSGrHNuZoIWzUnMrjXakrVzZSRWWJ56ezNC3FucdOpBMFe5DZL003CyjELfXS68dc6Nx z3isFZzEMdfZd48ozIkQn61RjIaFJ/TTEqjVQ1bKs/XdExjjHnzypV98/DoEaOzkUhGi OWBlDXaRCKOuOyWBYS989WahbU6GKJM4sRwE2voaZffpPmd6qGPj+LfGrMNW/84/4gMN dWFLmNc7GEMyeUJtFgVF/bEG0gjj6uIU7JofYTAp68TdAj+litdZyhGSaWiR0ZU8UiDF gLpQ== 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; bh=GN4+0p/L3u2M+HZm8tAOQv4Zavm+OMyyNRfyf0dzvkc=; b=Gqt0v9dXcU3MOmXhJ5gtcTOMf6yy6GotsJJ7uHqt3DB+Hsa9n7UYi+NgHh6w+qwZo3 rAyjYF4uIZtpshfD0hfYLeMi+Ql3W4lGKqbp76miEg2jQ6Urd6fV3v+67UhXASA01XID BetdyfaPs9mqwMqRZx0bKUGYPR7EYPD4j7qjZ4loWe2Ry14sZCsZuKjGnyRxcuk5FRuf zXQRfH4sdENf2U5rjrheLtx3Oc3oseZCxrYbDloiaSyw5B+cdq2joVoNV+b/etE3qK17 lEEra4US9PytbtEp9RyJx05L3e2AvHunD8jlpVuQdjZQC0y//I+wFuo9XIsh8qI/tUEf IboA== X-Gm-Message-State: APjAAAVp6BpJhEOHfYxP9/3E8+pp+a1I32ULWMBjrt5FaqPL5tnSLmVn 7yhzbGp8j2i5XhuwUwS7gxFkblfoJrE= X-Google-Smtp-Source: APXvYqxZs/xTBlSjNg6yMNakfp8siAz7y2deSsjuERET4y1PUiynLfo5PfM5ZTTXd1ddkaUwFyw+SQ== X-Received: by 2002:a63:8f49:: with SMTP id r9mr68233116pgn.306.1556733060968; Wed, 01 May 2019 10:51:00 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h189sm84126158pfc.125.2019.05.01.10.50.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 May 2019 10:50:59 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/5] perf tools: Properly set the value of 'old' in snapshot mode Date: Wed, 1 May 2019 11:50:51 -0600 Message-Id: <20190501175052.29667-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501175052.29667-1-mathieu.poirier@linaro.org> References: <20190501175052.29667-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190501_105102_535536_DCB79126 X-CRM114-Status: GOOD ( 14.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: corbet@lwn.net, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, suzuki.poulose@arm.com, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, mike.leach@arm.com, leo.yan@linaro.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-Virus-Scanned: ClamAV using ClamSMTP In snapshot mode the value of the 'old' pointer needs to be adjusted when 'head' has wrapped around in order to get the latest information in the buffer and be compatible with the generic AUX ring buffer mechanic. Signed-off-by: Mathieu Poirier --- tools/perf/arch/arm/util/cs-etm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 911426721170..4e73fe1a6978 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -541,11 +541,19 @@ static int cs_etm_find_snapshot(struct auxtrace_record *itr __maybe_unused, unsigned char *data __maybe_unused, u64 *head, u64 *old) { + bool wrapped; + pr_debug3("%s: mmap index %d old head %zu new head %zu size %zu\n", __func__, idx, (size_t)*old, (size_t)*head, mm->len); - *old = *head; - *head += mm->len; + /* + * If the last byte in the ring buffer isn't zero, the head has + * wrapped around. + */ + wrapped = !!(data[mm->len - 1]); + + if (wrapped) + *old = *head - mm->len; return 0; } From patchwork Wed May 1 17:50:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10925465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B08217E6 for ; Wed, 1 May 2019 17:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BA3228F2E for ; Wed, 1 May 2019 17:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FAA228F43; Wed, 1 May 2019 17:51:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A7F4A28F2F for ; Wed, 1 May 2019 17:51:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=lQMuK0NKcS8RpuXIFT8pnS1sIS3mkZcCJ+trNCRhQA4=; b=moleT3PiIPVLJAfWclhs3Dps1U r6dg6C2vBzNo09y9GnLMZ+ftgL971WLxelpR+U0osZ8VeX84CEsB2jX0ARmsgDVqgtRpoMzgluqns 7rfDGqOclbW6T1GvnnrFlODDhoqN8oJWX+KlX93Ffb0NE5RUL/Ry7yJfRUZpYTCvZd9PUmS62WAYy qZ8kcH/plj/HvLx6XHlvE3e3FsyHV1maJrj1jv/vPjPEPSlLhwqM9gdLgFyXiJyPVTCeaiYxxJYoS 4WcAnlKkIxkKvKoZhpQKGjLd4tbic9+jKzpf87GiqJiByTfPpUD4hnh+fdc8yI5rkCNJumCSCkZ+x 7Qi6qgHg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLtOU-0005hO-SW; Wed, 01 May 2019 17:51:46 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLtNn-0004ju-63 for linux-arm-kernel@lists.infradead.org; Wed, 01 May 2019 17:51:10 +0000 Received: by mail-pl1-x644.google.com with SMTP id z8so8499898pln.4 for ; Wed, 01 May 2019 10:51:03 -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; bh=56W4mPOO8bxoxn0RBc8QFf/fiRyB1wZjHVTSBB48m5Q=; b=pMtWRq0s7iCI9HNypq9dMX4yxUBCmR87+ZL0Y2dMdADme05KJWpQNpHRUS5mFUq7fl 95ac52OPTJvKVdAlg/GUrR+zaLJrsh7TaWmeo2UOtTj3LNC2bvVkbBvrnXpUK3Yz5h5t rX/9YW3fJIbEKpE6MAArUIhiQZFXDaRQWBfYPz4Vp9QdeFMYItS61b1LY4wKj0PgEuvT H56TCnVIkWMfFG3hjv8khXp9OIWrndBovHkrDkJrOr0QLybffUt4dwNTLrYzgUty+MXS o+ekQRgRvP45MeQSsrFJYHJRawcp3kZlicX+y0cBA5jZ/peeJV6UOyMtrP9BWA715RkP 5d5w== 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; bh=56W4mPOO8bxoxn0RBc8QFf/fiRyB1wZjHVTSBB48m5Q=; b=pp9A5esirQrF/By6CvN/c5GV0ccnk5EEF78CLzKW0dILLenYo3im3Xd/lPxXmbGrJq 0zUVAxRxOAK5/vS7DihRPj295b5dd5uY9NssLdXg5sUOnTrG6pUnfjJcxY8jjJ41anVH 1L740fKTL6+ImG5jY3gmrfho7VTPVRAtU60sgSWnMOg6r1phw6DP2YcgkPCRs7vjrrEV nd6TkLgYNbJM6M/zGfUl09GdehvN+ytXCDnZGLJedeYHebRYMjwJqmRObcnSR98N3bfE NHaZv9y3trAxY6ztka4ZSI3AudX0fIeR0LrUaA0dQQzIxVPIRnN5XYF17OMzmOM1uPpN SPEg== X-Gm-Message-State: APjAAAUXG+5kMqFeAW3jhtljHS1bv+yijfNoImqZnkDZ/e+AOYATYnIm J6yE754Hq+AoNQq1z8+04ei5kNA30J4= X-Google-Smtp-Source: APXvYqw9KAn+Wr81do9FHvR3XHFrCAF+277J+NvKW7CDjzyxCAaOmOwqej4zBa6Hcvr5HBTt53ByAA== X-Received: by 2002:a17:902:2702:: with SMTP id c2mr8428334plb.277.1556733062403; Wed, 01 May 2019 10:51:02 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h189sm84126158pfc.125.2019.05.01.10.51.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 May 2019 10:51:01 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/5] docs: coresight: Document snapshot mode Date: Wed, 1 May 2019 11:50:52 -0600 Message-Id: <20190501175052.29667-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501175052.29667-1-mathieu.poirier@linaro.org> References: <20190501175052.29667-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190501_105103_621973_CF2EEC89 X-CRM114-Status: GOOD ( 13.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: corbet@lwn.net, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, suzuki.poulose@arm.com, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, mike.leach@arm.com, leo.yan@linaro.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-Virus-Scanned: ClamAV using ClamSMTP Because of the resctriction imposed by the internal memory buffer of some CoreSight sink, using the framework in snapshot mode can be a little trickly. As such document the process to make user experience more enjoyable. Signed-off-by: Mathieu Poirier --- Documentation/trace/coresight.txt | 41 ++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/Documentation/trace/coresight.txt b/Documentation/trace/coresight.txt index efbc832146e7..6c602ae379e2 100644 --- a/Documentation/trace/coresight.txt +++ b/Documentation/trace/coresight.txt @@ -363,7 +363,6 @@ The --itrace option controls the type and frequency of synthesized events Note that only 64-bit programs are currently supported - further work is required to support instruction decode of 32-bit Arm programs. - Generating coverage files for Feedback Directed Optimization: AutoFDO --------------------------------------------------------------------- @@ -394,6 +393,46 @@ sort example is from the AutoFDO tutorial (https://gcc.gnu.org/wiki/AutoFDO/Tuto Bubble sorting array of 30000 elements 5806 ms +2.2) Snapshot mode: + +Using perf's built-in snapshot mode with CoreSight tracers is supported - to +do so the '-S' command line option needs to be specified. Since current sink +devices are used in double-buffer mode when operated from the perf interface, +the size of the perf ring buffer needs to be adjusted to match the size of the +buffer used by the CoreSight sinks. From the perf command line it is possible +to specify the number of pages to use for a session using the '-m,X' option, +where X is the amount of pages. + +The system memory buffer used by ETR devices is automatically adjusted +to match the size of the perf ring buffer and as such does not need to be +modified on the perf command line. For ETB and ETF devices the perf ring +buffer size need to be adjusted to match the size of the internal buffer. + +The following examples assume a system page size of 4096 byte: + + # cat /sys/bus/coresight/devices/20010000.etb/mgmt/rdp + 0x2000 + # perf record -e cs_etm/@20010000.etf/ -S -m,8 --per-thread $APP + + # cat /sys/bus/coresight/devices/20010000.etf/buffer_size + 0x10000 + # perf record -e cs_etm/@20010000.etf/ -S -m,16 --per-thread $APP + + # perf record -e cs_etm/@20070000.etr/ -S --per-thread $APP + +Once an application is launched trace snapshot are collected by sending the +USR2 message to the process being monitored: + + # perf record -e cs_etm/@20070000.etr/ -S --per-thread $APP & + [1] 14808 + # kill -USR2 14808 + ... + ... + # kill -USR2 14808 + ... + ... + # kill 14808 + How to use the STM module -------------------------