Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp376298pxv; Thu, 24 Jun 2021 09:47:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXj96Vm+9QHPFYoMAN7NBR2/aEcjFf8Otj8NStweOllWCaP73XQtzCuR5JNBdp8iEJENrC X-Received: by 2002:a17:907:9711:: with SMTP id jg17mr6357125ejc.106.1624553272472; Thu, 24 Jun 2021 09:47:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624553272; cv=none; d=google.com; s=arc-20160816; b=dXzU+NxSQyZygs18b85lSezeDiCc5rU6sofFF9dmgn65F+nImGQQ44kDsAzDSSx5fU bIdbnbnkZmNVaBdq3kkiOIgZkUZWSd/V+oLJfoRTFghmIu/A1ZpNrcOVkpHB/qK0TiQt yEBAogCqHJ9Cj8xsluo5I+0hW/OuVlEbZOuO8lGZ68FUgNjifLeCs3U6DCaIeC0OMR5/ 8v3O0+xKpeG1tQ+B2pZBUXtkheZCz5xhgfA6eZmxHF9ZismyrJkY9hItROL3sIJOR8/r CuZ9V6JBCbfw1iVxmIoO6AmMXyB/jBD2Jadyby5it2/2Ewg8lI2Y24ivG98h+CcHuVtM 7B4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3RA6PEaLaBYclbHYIBDg/26R0dMVQzFqmn8+4qV+rVU=; b=Dx7QzyBulBG9dF9c+Pb2hNPpWaiWdDNnLEGBDBcDg3I13BvRG/qbMhZpz0PpbHCj5X FikFNGJWgxnt4H90Ne4de873YqcXX/iCWQOe4eoBlkrEHOWBAf8yWaURL/6pmI/+ajJd 1CNc+j2qRBYd9XJ5mt7V0JcqsOwk1S4z+97CGnDiDugX/sxXkHtWvzdvT3JQjT5q4nu7 CDlU0K+/tlRcKMgL6HxpqkTfMTJLM+1hdsfmf2DYMyfK7jFoYYO0HnuyOtsF41CUua7r pzSmeSVYfXxASq+sLQrKdhTcw5EOHxAK62EqO3XAd8jtir16ZYbpZkq4dASQYlqs1sjw cPSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si3819300edi.123.2021.06.24.09.47.28; Thu, 24 Jun 2021 09:47:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232260AbhFXQpk (ORCPT + 99 others); Thu, 24 Jun 2021 12:45:40 -0400 Received: from foss.arm.com ([217.140.110.172]:33994 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232248AbhFXQpi (ORCPT ); Thu, 24 Jun 2021 12:45:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EA32AED1; Thu, 24 Jun 2021 09:43:18 -0700 (PDT) Received: from e121896.arm.com (unknown [10.57.13.86]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1C41E3F719; Thu, 24 Jun 2021 09:43:15 -0700 (PDT) From: James Clark To: acme@kernel.org, mathieu.poirier@linaro.org, coresight@lists.linaro.org, leo.yan@linaro.org Cc: al.grant@arm.com, branislav.rankov@arm.com, denik@chromium.org, suzuki.poulose@arm.com, anshuman.khandual@arm.com, James Clark , John Garry , Will Deacon , Mike Leach , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 2/2] perf cs-etm: Split --dump-raw-trace by AUX records Date: Thu, 24 Jun 2021 17:43:03 +0100 Message-Id: <20210624164303.28632-3-james.clark@arm.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210624164303.28632-1-james.clark@arm.com> References: <20210624164303.28632-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently --dump-raw-trace skips queueing and splitting buffers because of an early exit condition in cs_etm__process_auxtrace_info(). Once that is removed we can print the split data by using the queues and searching for split buffers with the same reference as the one that is currently being processed. This keeps the same behaviour of dumping in file order when an AUXTRACE event appears, rather than moving trace dump to where AUX records are in the file. There will be a newline and size printout for each fragment. For example this buffer is comprised of two AUX records, but was printed as one: 0 0 0x8098 [0x30]: PERF_RECORD_AUXTRACE size: 0xa0 offset: 0 ref: 0x491a4dfc52fc0e6e idx: 0 t . ... CoreSight ETM Trace data: size 160 bytes Idx:0; ID:10; I_ASYNC : Alignment Synchronisation. Idx:12; ID:10; I_TRACE_INFO : Trace Info.; INFO=0x0 { CC.0 } Idx:17; ID:10; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0x0000000000000000; Idx:80; ID:10; I_ASYNC : Alignment Synchronisation. Idx:92; ID:10; I_TRACE_INFO : Trace Info.; INFO=0x0 { CC.0 } Idx:97; ID:10; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0xFFFFDE2AD3FD76D4; But is now printed as two fragments: 0 0 0x8098 [0x30]: PERF_RECORD_AUXTRACE size: 0xa0 offset: 0 ref: 0x491a4dfc52fc0e6e idx: 0 t . ... CoreSight ETM Trace data: size 80 bytes Idx:0; ID:10; I_ASYNC : Alignment Synchronisation. Idx:12; ID:10; I_TRACE_INFO : Trace Info.; INFO=0x0 { CC.0 } Idx:17; ID:10; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0x0000000000000000; . ... CoreSight ETM Trace data: size 80 bytes Idx:80; ID:10; I_ASYNC : Alignment Synchronisation. Idx:92; ID:10; I_TRACE_INFO : Trace Info.; INFO=0x0 { CC.0 } Idx:97; ID:10; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0xFFFFDE2AD3FD76D4; Decoding errors that appeared in problematic files are now not present, for example: Idx:808; ID:1c; I_BAD_SEQUENCE : Invalid Sequence in packet.[I_ASYNC] ... PKTP_ETMV4I_0016 : 0x0014 (OCSD_ERR_INVALID_PCKT_HDR) [Invalid packet header]; TrcIdx=822 Signed-off-by: James Clark --- tools/perf/util/cs-etm.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 88e8122f73c9..ad777c2a342f 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -2430,6 +2430,22 @@ static int cs_etm__process_event(struct perf_session *session, return 0; } +static void dump_queued_data(struct cs_etm_auxtrace *etm, + struct perf_record_auxtrace *event) +{ + struct auxtrace_buffer *buf; + unsigned int i; + /* + * Find all buffers with same reference in the queues and dump them. + * This is because the queues can contain multiple entries of the same + * buffer that were split on aux records. + */ + for (i = 0; i < etm->queues.nr_queues; ++i) + list_for_each_entry(buf, &etm->queues.queue_array[i].head, list) + if (buf->reference == event->reference) + cs_etm__dump_event(etm, buf); +} + static int cs_etm__process_auxtrace_event(struct perf_session *session, union perf_event *event, struct perf_tool *tool __maybe_unused) @@ -2462,7 +2478,8 @@ static int cs_etm__process_auxtrace_event(struct perf_session *session, cs_etm__dump_event(etm, buffer); auxtrace_buffer__put_data(buffer); } - } + } else if (dump_trace) + dump_queued_data(etm, &event->auxtrace); return 0; } @@ -3038,7 +3055,6 @@ int cs_etm__process_auxtrace_info(union perf_event *event, if (dump_trace) { cs_etm__print_auxtrace_info(auxtrace_info->priv, num_cpu); - return 0; } err = cs_etm__synth_events(etm, session); -- 2.28.0