Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2218147imd; Sun, 28 Oct 2018 05:36:42 -0700 (PDT) X-Google-Smtp-Source: AJdET5fXAbHz1ODB2J2eM668Q4ubk0TuNLDF5Oln3hFFr6x9VA9os9KyikZlSdzReGSqjoI4alqD X-Received: by 2002:a65:45c9:: with SMTP id m9-v6mr9896906pgr.212.1540730202910; Sun, 28 Oct 2018 05:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540730202; cv=none; d=google.com; s=arc-20160816; b=InSXiHKV12L8GMFBcPxpHvq8vLy+S2PGQSNIjtlTNZmy0NwstS3h6+2+BHMw3EX0jv CckSKU1ulX2IoPnzIxTe8MAKEM6eYQGJnzanYrOFlo6YigCvVOzT73+ptF+RC2C9nVOJ vvloutcNhzWTnUNsdP1KbBQTOkZklop0pZwzmfTpIYXxrrXxDdSxZwx4K5xK1tT5b/5M ZnI3mcOKIDFNdibEE4QQUpZ6+e0icE4Hj8zrL+c9A+akYfAYrPdpWRh7x8TWSYOpr29r IQPePgwkYUPONYI51CldCCmvDg5/bqgu9KY37+zA1h80MmQPtEniMvQdxU047C1YzFHB 4Z4A== 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=U7cmISxeRZ1YwLrjSKN+D2EuVL5W5QQOYfw6cRMxHkY=; b=ntbv64pMTEnz45IABNI/5GujVPHFSI0C145JAjC+YXkmnbIEpS7m+6e8K/44FEWjul UmGalM/QtRv81GU6PwLZrZnW+IkltlrHP+qKfelPABgx1CqS/kZbUJOtLva1VKeF1vaZ vh/RGFSS0jK0lXHivsFSa+sMlt2loiwknY52Ee08PJY4PSC0b+ipGwB0+oV0WGp8hp+w BHOJAvou0HKRVIIpmMoruQ9Y0qXJrqRRIurprI4TPOPaqUbrkfojn0sMVkThR4w9dOqw KY+HDXHq7Xm/yGvnk8jhvd31X1xfYcOWoyWdr27RBXrjsEadQx1DjVm3I1cWnMtKOHog N3cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PXV2PMnM; 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 f19-v6si17293278pgj.334.2018.10.28.05.36.08; Sun, 28 Oct 2018 05:36:42 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PXV2PMnM; 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 S1727606AbeJ1VT5 (ORCPT + 99 others); Sun, 28 Oct 2018 17:19:57 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52102 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726379AbeJ1VT5 (ORCPT ); Sun, 28 Oct 2018 17:19:57 -0400 Received: by mail-wm1-f68.google.com with SMTP id 143-v6so5493448wmf.1 for ; Sun, 28 Oct 2018 05:35:24 -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=U7cmISxeRZ1YwLrjSKN+D2EuVL5W5QQOYfw6cRMxHkY=; b=PXV2PMnMXWkkrw884OjFKnkkvnIqbKgFYlt9+5+3lrbb4vqDFR57bxltFMDRDDoIve tZ0Y4LydxU0z6ifAd1ZnyYgHWopiNMWFj+OwSf7hfACPkspB9qXdPq674pafwmWFYGh3 9XuzQZleiQM4sKwXrFTNqXlyaYrD7kgPBcLuY= 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=U7cmISxeRZ1YwLrjSKN+D2EuVL5W5QQOYfw6cRMxHkY=; b=VEU5+jnsvC1/TZeKfs+CA4dErbbNfH0gPpWztj4hgTe8JK4YMGNgW4wprEjG1LyZMb KG8f6n0WcwVSRJAO4pLbfTo+R/axI5TJDeRFqsiGhF2EfmJPh0cOvR4MHBEGodMG+VIP r6veoW1tn9Kpq1gs+f7Ol8SlvB7PgBuZRNgmck05rfmvGhKxhrSyupJBi6VoY4Ut6B2F CFTd143rta6hqcsFE6jUEO+48+Q4I3nQwdnrQx/mwZm1tn+UcBQrOEGF0noGvOWnBB3O BtsIkUFYL+lePjIsdqyc/r453CW++Eqsbf/aKlvusMQ7clBXSkrq7VsbwoeBLETgxa6U SuRw== X-Gm-Message-State: AGRZ1gKmzgR5RcwDZnl0f8YAYmwiBlqp7Z+odpk0NS8n0xycoCG2EsHC +lrc5V1ne3imOI9K9uTk49LnOg== X-Received: by 2002:a1c:dcc:: with SMTP id 195-v6mr10665965wmn.117.1540730123521; Sun, 28 Oct 2018 05:35:23 -0700 (PDT) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id v30-v6sm18926830wra.67.2018.10.28.05.35.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 28 Oct 2018 05:35:22 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Coresight ML , Mike Leach , Robert Walker , Al Grant Cc: Leo Yan Subject: [PATCH v1 2/4] perf cs-etm: Track exception number Date: Sun, 28 Oct 2018 20:34:53 +0800 Message-Id: <1540730095-6732-3-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540730095-6732-1-git-send-email-leo.yan@linaro.org> References: <1540730095-6732-1-git-send-email-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When an exception packet comes, it contains the info for exception number; the exception number indicates the exception types, so from it we can know if the exception is taken for interrupt, system call or other traps, etc. But because the exception return packet cannot delivery exception number correctly by decoder thus when prepare sample flags we cannot know what's type for exception return. This patch adds a new 'exc_num' array in decoder structure to record exception number per CPU, the exception number is recorded in the array when the exception packet comes and this exception number can be used by exception return packet. If detect there have discontinuous trace with TRACE_ON packet, the exception number is set to invalid value. Signed-off-by: Leo Yan --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 51 ++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index 0f29534..efc4332 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -43,6 +43,7 @@ struct cs_etm_decoder { u32 packet_count; u32 head; u32 tail; + u32 *exc_num; struct cs_etm_packet packet_buffer[MAX_BUFFER]; }; @@ -368,16 +369,44 @@ static ocsd_datapath_resp_t cs_etm_decoder__buffer_trace_on(struct cs_etm_decoder *decoder, const uint8_t trace_chan_id) { - return cs_etm_decoder__buffer_packet(decoder, trace_chan_id, - CS_ETM_TRACE_ON); + int ret; + struct cs_etm_packet *packet; + + ret = cs_etm_decoder__buffer_packet(decoder, trace_chan_id, + CS_ETM_TRACE_ON); + if (ret != OCSD_RESP_CONT && ret != OCSD_RESP_WAIT) + return ret; + + packet = &decoder->packet_buffer[decoder->tail]; + + /* Clear execption number for discontinuous trace */ + decoder->exc_num[packet->cpu] = UINT32_MAX; + + return ret; } static ocsd_datapath_resp_t cs_etm_decoder__buffer_exception(struct cs_etm_decoder *decoder, + const ocsd_generic_trace_elem *elem, const uint8_t trace_chan_id) { - return cs_etm_decoder__buffer_packet(decoder, trace_chan_id, - CS_ETM_EXCEPTION); + int ret; + struct cs_etm_packet *packet; + + ret = cs_etm_decoder__buffer_packet(decoder, trace_chan_id, + CS_ETM_EXCEPTION); + if (ret != OCSD_RESP_CONT && ret != OCSD_RESP_WAIT) + return ret; + + packet = &decoder->packet_buffer[decoder->tail]; + + /* + * Exception number is recorded per CPU and later can be used + * for exception return instruction analysis. + */ + decoder->exc_num[packet->cpu] = elem->exception_number; + + return ret; } static ocsd_datapath_resp_t @@ -413,7 +442,7 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( trace_chan_id); break; case OCSD_GEN_TRC_ELEM_EXCEPTION: - resp = cs_etm_decoder__buffer_exception(decoder, + resp = cs_etm_decoder__buffer_exception(decoder, elem, trace_chan_id); break; case OCSD_GEN_TRC_ELEM_EXCEPTION_RET: @@ -501,6 +530,10 @@ cs_etm_decoder__new(int num_cpu, struct cs_etm_decoder_params *d_params, if (!decoder) return NULL; + decoder->exc_num = zalloc(sizeof(*decoder->exc_num) * num_cpu); + if (!decoder->exc_num) + goto err_free_decoder; + decoder->data = d_params->data; decoder->prev_return = OCSD_RESP_CONT; cs_etm_decoder__clear_buffer(decoder); @@ -521,7 +554,7 @@ cs_etm_decoder__new(int num_cpu, struct cs_etm_decoder_params *d_params, decoder->dcd_tree = ocsd_create_dcd_tree(format, flags); if (decoder->dcd_tree == 0) - goto err_free_decoder; + goto err_free_decoder_exc_num; /* init library print logging support */ ret = cs_etm_decoder__init_def_logger_printing(d_params, decoder); @@ -532,6 +565,9 @@ cs_etm_decoder__new(int num_cpu, struct cs_etm_decoder_params *d_params, cs_etm_decoder__init_raw_frame_logging(d_params, decoder); for (i = 0; i < num_cpu; i++) { + /* init expcetion number to an invalid value */ + decoder->exc_num[i] = UINT32_MAX; + ret = cs_etm_decoder__create_etm_decoder(d_params, &t_params[i], decoder); @@ -543,6 +579,8 @@ cs_etm_decoder__new(int num_cpu, struct cs_etm_decoder_params *d_params, err_free_decoder_tree: ocsd_destroy_dcd_tree(decoder->dcd_tree); +err_free_decoder_exc_num: + free(decoder->exc_num); err_free_decoder: free(decoder); return NULL; @@ -603,5 +641,6 @@ void cs_etm_decoder__free(struct cs_etm_decoder *decoder) ocsd_destroy_dcd_tree(decoder->dcd_tree); decoder->dcd_tree = NULL; + free(decoder->exc_num); free(decoder); } -- 2.7.4