From patchwork Tue Feb 12 17:16:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 158166 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4089091jaa; Tue, 12 Feb 2019 09:16:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IYRa8BK5VUAVbB24lkSkzUdUaucKcG958tj0ohxMN9LsIUUTQTR1OD6qg9Yusl/G3Y2U2za X-Received: by 2002:a63:da14:: with SMTP id c20mr4371731pgh.233.1549991804578; Tue, 12 Feb 2019 09:16:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991804; cv=none; d=google.com; s=arc-20160816; b=fo396zfdns2QXHrfAA8D6GwGBbChM0A95kN+rUT55GWhQurffazUqp88l9mBzTktSV Zn2UJiLfHODURoedWIKnPHWnFewa250q3uLCVdRLjUbS+WK0vsg5dFVGREduDsUgB9IV f6qipmE9ML/3ju8vYcmYi5hdosdOVawHSGVI69KHi51AK2WsuGCGKgrtnq0zPiTYSTcH e7EsD77ZUSJ8Hw50TMTI3LhZ4afRTOvDSpVuN6T2dhwVqJDL7CBgX+AnbloY5iJniIEk ztq9jl7VW1bfCrFXe+Uf/4N8j6Iy96Dux2ukFW/YcUx+0JpoQGeoX0CRujE4GXkt63Kg RmHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=meZtkgH5cImMXR3ybdUTFzkYUQz8/L+H84Qg8MqCSA8=; b=MwMM9+oKndVpM1CMDtWbhIH+8fHBYFWjwnMTIijTEU8gaeHNgAlXYUHvukoQRvvS+p YLyE5dKWqVZ9BHfsbQm+Tis/cfvMqjeT9mQZEp4R0gSCW3Vbsr/0k3wJBXaFZPW9Guoc fkZllzIl2ICoNdGEk4LjwyrwPjadrmBFMUkRolpeP5XS1eM+C1Tssafh8YAyHiJ4Yfai rncoOFlm8StrYOt5Xm/edvD4hu2OlBWpfjBLwgNt0m3Pp3tDwjJhG5dW305fqjtS3Cdl 3CbLWr1tyBRlEqVYvVgE/UmamRh7xPoxN/ARuw8yjHwBThrhZfj3u3KzpHIFi0gltZi6 kglA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vZHvAcXJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y129si5007421pgy.175.2019.02.12.09.16.44; Tue, 12 Feb 2019 09:16:44 -0800 (PST) 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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vZHvAcXJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731816AbfBLRQe (ORCPT + 31 others); Tue, 12 Feb 2019 12:16:34 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36447 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731800AbfBLRQc (ORCPT ); Tue, 12 Feb 2019 12:16:32 -0500 Received: by mail-pg1-f194.google.com with SMTP id r124so1553181pgr.3 for ; Tue, 12 Feb 2019 09:16:32 -0800 (PST) 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=meZtkgH5cImMXR3ybdUTFzkYUQz8/L+H84Qg8MqCSA8=; b=vZHvAcXJnsp/c3UfnpJh7hvmSVO5hZHPN6EpPFaiOWcnOQmgxR7mLYnW75CQa53EnQ vuu6iE04ioKMlJDDQcYK3AZwSqRDDiSQBxxswQ1YhBLtQKa6lzArcVmEnm7VXHBmruwH nIvOg7cAj4baH4AcnnsLs6p8mKRRNUvhOlL8TIZJW+cFd/EZed0AxwURN1HmmOaQJatq rwmQGoqcjGQg5VwGmD2/T1PDnixaIBOtVs6pdg/BKgpnw0qMcPFdx5KSbXp9sYvSnCse GV2AQBr3RzU8ZsqSryLfKUs64aSYFXEVgKhb74xJkAebcBLbsKEdK+Dy9EvV2jl4dqHT /bgg== 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=meZtkgH5cImMXR3ybdUTFzkYUQz8/L+H84Qg8MqCSA8=; b=VFLrte2qcq4YwwJ/OqXbGaIsPayFFuhd1meZmyCTNGVY+jQtQe880XYGCKpqFUwquo k9mp5FqEe5LbMKkWB82h+qfXojHB3YNUom1yqu8SmO3B1iYU9jZ9UbXnlX+S76d6GroH fzP6FO4+1V7KxElQJ6vYxeXTv4DgFWBRyMpziaOPyQTaSdfMGzraU4iodiuc8VeqMHZ8 Jc5gelvY6gudv0nY5P6WEKRClHSmq/9hv7sEWKTjxShy/6ZsOitpuFDVRcSGo5/mCYqH AmR15K7NVZw+BZ9nIqS2LIWO2PW9Gk2ASFKFrxIx87AniqoujufioImhY2pbNWghTE1W cHrg== X-Gm-Message-State: AHQUAubCvi/0+FM8s3FoovFYfo50VVzp/+1lpinj+XygqJuaFlAOItPI W2wCeZVc2bOXcwgla/KA/Yj4ZA== X-Received: by 2002:a63:4611:: with SMTP id t17mr4526538pga.119.1549991791818; Tue, 12 Feb 2019 09:16:31 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:31 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org Cc: suzuki.poulose@arm.com, mingo@redhat.com, peterz@infradead.org, jolsa@redhat.com, leo.yan@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/13] perf tools: Make cs_etm__run_decoder() queue independent Date: Tue, 12 Feb 2019 10:16:15 -0700 Message-Id: <20190212171618.25355-11-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch makes decoding of auxtrace buffer centered around a struct cs_etm_queue. This eliminates surperflous variables and is a precursor for work that simplifies the main decoder loop. Signed-off-by: Mathieu Poirier --- .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 7 --- tools/perf/util/cs-etm.c | 52 +++++++++---------- 2 files changed, 26 insertions(+), 33 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h index 663309486784..3ab11dfa92ae 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -15,13 +15,6 @@ struct cs_etm_decoder; -struct cs_etm_buffer { - const unsigned char *buf; - size_t len; - u64 offset; - u64 ref_timestamp; -}; - enum cs_etm_sample_type { CS_ETM_EMPTY, CS_ETM_RANGE, diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 2d2de898ea68..d2c90b369e7c 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -76,6 +76,8 @@ struct cs_etm_queue { size_t last_branch_pos; struct cs_etm_packet *prev_packet; struct cs_etm_packet *packet; + const unsigned char *buf; + size_t buf_len, buf_used; }; static int cs_etm__update_queues(struct cs_etm_auxtrace *etm); @@ -683,7 +685,7 @@ static int cs_etm__inject_event(union perf_event *event, static int -cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq) +cs_etm__get_trace(struct cs_etm_queue *etmq) { struct auxtrace_buffer *aux_buffer = etmq->buffer; struct auxtrace_buffer *old_buffer = aux_buffer; @@ -697,7 +699,7 @@ cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq) if (!aux_buffer) { if (old_buffer) auxtrace_buffer__drop_data(old_buffer); - buff->len = 0; + etmq->buf_len = 0; return 0; } @@ -717,13 +719,11 @@ cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq) if (old_buffer) auxtrace_buffer__drop_data(old_buffer); - buff->offset = aux_buffer->offset; - buff->len = aux_buffer->size; - buff->buf = aux_buffer->data; + etmq->buf_used = 0; + etmq->buf_len = aux_buffer->size; + etmq->buf = aux_buffer->data; - buff->ref_timestamp = aux_buffer->reference; - - return buff->len; + return etmq->buf_len; } static void cs_etm__set_pid_tid_cpu(struct cs_etm_auxtrace *etm, @@ -1493,24 +1493,23 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq) static int cs_etm__run_decoder(struct cs_etm_queue *etmq) { - struct cs_etm_buffer buffer; - size_t buffer_used, processed; + size_t processed; int err = 0; /* Go through each buffer in the queue and decode them one by one */ while (1) { - buffer_used = 0; - memset(&buffer, 0, sizeof(buffer)); - err = cs_etm__get_trace(&buffer, etmq); - if (err <= 0) - return err; - /* - * We cannot assume consecutive blocks in the data file are - * contiguous, reset the decoder to force re-sync. - */ - err = cs_etm_decoder__reset(etmq->decoder); - if (err != 0) - return err; + if (!etmq->buf_len) { + err = cs_etm__get_trace(etmq); + if (err <= 0) + return err; + /* + * We cannot assume consecutive blocks in the data file + * are contiguous, reset the decoder to force re-sync. + */ + err = cs_etm_decoder__reset(etmq->decoder); + if (err != 0) + return err; + } /* Run trace decoder until buffer consumed or end of trace */ do { @@ -1518,14 +1517,15 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) err = cs_etm_decoder__process_data_block( etmq->decoder, etmq->offset, - &buffer.buf[buffer_used], - buffer.len - buffer_used, + &etmq->buf[etmq->buf_used], + etmq->buf_len, &processed); if (err) return err; etmq->offset += processed; - buffer_used += processed; + etmq->buf_used += processed; + etmq->buf_len -= processed; /* Process each packet in this chunk */ while (1) { @@ -1585,7 +1585,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) break; } } - } while (buffer.len > buffer_used); + } while (etmq->buf_len); if (err == 0) /* Flush any remaining branch stack entries */