From patchwork Sun Nov 11 04:59:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 150759 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1706143ljp; Sat, 10 Nov 2018 21:00:34 -0800 (PST) X-Google-Smtp-Source: AJdET5fsxZyUbNTFjCCUf34oq8wFNAz1FEpBdYvEI37dEJAMQYL3B/sUqaXqiXJzFlY/cRumnhsg X-Received: by 2002:a17:902:bf49:: with SMTP id u9-v6mr15372289pls.10.1541912434535; Sat, 10 Nov 2018 21:00:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541912434; cv=none; d=google.com; s=arc-20160816; b=p5nWCWL1tf6soyNbZwbQlIU6ffN0K/RoqnwxZGFTSLIdaRRBpxJvRfbnUpvz51rzw1 ZmFb2BvUYBf6qo5w/T7cOhii21I76XjgI3Q7KDXUGM7Jm8aR2zz2y212UkM465zNFVFM kyhyob9ZYRfzxFxRapUnqkdSzNdFtmp1Wkzt/PWV0jUpNLuv8GM4Qp6dl8yUxZz1Bbtq 9rbtKRfD6GtV9UfilTrVhKFEv9x/QQfJCbIPqH/nnqZgQ8tp3WVhqg6lfUJTwBMRuse6 rCNCP9xzggutync1i3p2yZNTJRNLZx3NFx/Qla749pIM0z4uVV5YhhqfSFpfe9ghjzZx LWfQ== 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=jZ25mbwgDMiV9nnmDqIiPF/+ngrYDveBFk4YG++0cIY=; b=K1sbBZpFc/b5u6BksBPfG45SR7iC8znqETRPzfLlEx1DffVpok7cgSRzpOc0GxEVsl 00BvxEHZTa7Me+AtH4UJ9PKlP2jBvAb3qgSJx1CKbFBGcA71KiNCpeUfSZT+dIi+grrs /5f3HyDHz3H69izsA3vMemDxcbYt1Z0xnaqh3OIXsSrJT7cPfMHU6SDgYjZgInyxdtya vnOtEvr2CnED8ydD8R3OsK13c7vPEBD3nQtFvN5MyG/N2Xomf/yzH2gYBM//Pwy4/7r/ BbDEeXYfVudTfxUWtotk9kCEOqjF2ToQarEGprDFglVYDq2CfnMHPVgGtUs1ggSY3AN4 HLzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Uro2G0dQ; 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 k8-v6si13208369pll.241.2018.11.10.21.00.34; Sat, 10 Nov 2018 21:00:34 -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=Uro2G0dQ; 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 S1727655AbeKKOsA (ORCPT + 32 others); Sun, 11 Nov 2018 09:48:00 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:52907 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727184AbeKKOr7 (ORCPT ); Sun, 11 Nov 2018 09:47:59 -0500 Received: by mail-wm1-f67.google.com with SMTP id r11-v6so5384144wmb.2 for ; Sat, 10 Nov 2018 21:00:30 -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=jZ25mbwgDMiV9nnmDqIiPF/+ngrYDveBFk4YG++0cIY=; b=Uro2G0dQHwvBrnMO0YlyZHQuZdz4eHov8QSnTHeJXpXHZE4EslFv4WZa/aa0BWvr5P /P+v6ux/xQWLYb+MXHaEmdAhp902+Pnz5FFAhZoGdDtW3TOJpyvXfNOt+1YuKYM2PYRQ GeTIXm0slFqj9EKsR3koIfPELL0Ly8Mb4B3wE= 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=jZ25mbwgDMiV9nnmDqIiPF/+ngrYDveBFk4YG++0cIY=; b=oSnI8fCcgY7JNf5TzXEVBFYqXciY+SxzUY1ndjxxtZUm7W31PdFpOmD/qieZaL/s/Z FNYhy27PGn0NBkrx2kN4il6v1mXKKRQd1TsO9jVVT0VSXqn/1d8AwqHgjLysEd8+LjH/ yn6QtA00SiZde2Ev862SelwWbDgFA7GYClPp9oP8glmSGYi66TTD0ImeJe+/lsRixRBZ /sUwfsTzCadvrXETn6rzua2TLVdY74GKnaL7uQ4c9Gr4B0kOfnUI/bMQ+zx2L5Sc7Kx6 NHGrWXCgUKo1WXRIoLtUw8hWK4/zI8SMvtdiSHDcLjmQTBae1dpQrerYqQ1vvq/sl/9U SuAA== X-Gm-Message-State: AGRZ1gJ2k7z+ELIRYP3Tp8vY7UyHycK8bnk2xoQxWA3E1+KJTvBSXzKg UTSjV1l953PPyCURoGcESE3ZJw== X-Received: by 2002:a1c:af47:: with SMTP id y68-v6mr412603wme.33.1541912429566; Sat, 10 Nov 2018 21:00:29 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id t187-v6sm4463802wmt.45.2018.11.10.21.00.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Nov 2018 21:00:28 -0800 (PST) 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, Mike Leach , Robert Walker , Al Grant , Coresight ML Cc: Leo Yan Subject: [PATCH v1 5/5] perf cs-etm: Track exception number Date: Sun, 11 Nov 2018 12:59:43 +0800 Message-Id: <1541912383-19915-6-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541912383-19915-1-git-send-email-leo.yan@linaro.org> References: <1541912383-19915-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 or TRACE_OFF packet, the exception number is set to invalid value. Signed-off-by: Leo Yan --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 67 ++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 8 deletions(-) -- 2.7.4 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 b8cb7a3e..d1a6cbc 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,24 +369,64 @@ static ocsd_datapath_resp_t cs_etm_decoder__buffer_trace_off(struct cs_etm_decoder *decoder, const uint8_t trace_chan_id) { - return cs_etm_decoder__buffer_packet(decoder, trace_chan_id, - CS_ETM_TRACE_OFF); + int ret; + struct cs_etm_packet *packet; + + ret = cs_etm_decoder__buffer_packet(decoder, trace_chan_id, + CS_ETM_TRACE_OFF); + 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_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 @@ -423,7 +464,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: @@ -511,6 +552,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); @@ -531,7 +576,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); @@ -542,6 +587,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); @@ -553,6 +601,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; @@ -613,5 +663,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); }