Received: by 10.192.165.148 with SMTP id m20csp65057imm; Wed, 9 May 2018 08:52:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpI1UogX/hJjFyJQ0T+OhIOBI2gKWfG0ijwBEVBZRIB9pFJ4x4pcL9lTXtO11UEAY+xZBea X-Received: by 2002:a17:902:5304:: with SMTP id b4-v6mr44791305pli.231.1525881140687; Wed, 09 May 2018 08:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525881140; cv=none; d=google.com; s=arc-20160816; b=0tIrWGLavWJeLi0WfJ3praQqL5sA3Fq1A1LcKhT8GI7lmkuQ5XHgcHMZI55FztFZgK KszGLEE3BsOmxFU8BiK6W0rlU3Bzrrc74QczWSFFraTpnM9ILRNqFL9vz/7wLHF6S+bu +79JMyw+517G6AqRyBsqCVZpyI05rRlKyFgugPPUw+OC/63fLv+XfiLs+wsv+Ke/tbXO 2t0PvhEdtKKhGadE3XloE3JsXgQ/m2QRy8G/PhpqffOigigFobB5Qk3OD3UGWM78areU +5scALMfCm1sMEvsfAt9S8tY/M4mrmssE67drWjevrau7Oc/MEhVkpBlxcgP8fzl0uph Wx7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=XsZ4xpX7ZZEPvDoRAmwtFTmoTgdpxNdLQdWi8yBEMJE=; b=HOty9pn+7VJkWkEbAM//aj8Ga3A3vcKyURCj9tgiNDAbbF2hkKo6U/oyWwv3X9Fe/G tHNm88E75EtVI8fM0mkeZuukApofmonXzk+AZDe2VMIFbN18qe0YhD7cGtoAId9rBdIj V35Ac0C4JnAfJGZEEiIR8wI3oELH4iEyQNNEYuc/4Jrlgjs04RDkdWO4ePix1Nq7FU89 taYGe/MdJvpeTkhlLmoNHrz+bM4mrva5X03GITs73TL17QPBUZJa7cDQBCN0upfwwy3F hHJOCXNL1B+/Pf13x1AZUO5TDDF9KvySxR4gFtnq+gXSYCw24ooLtWxABX2JQ+6MmIkx M8+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aj4SqiqM; 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 f2-v6si5590902pgq.207.2018.05.09.08.52.03; Wed, 09 May 2018 08:52:20 -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=aj4SqiqM; 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 S965129AbeEIPvz (ORCPT + 99 others); Wed, 9 May 2018 11:51:55 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:40351 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935402AbeEIPvy (ORCPT ); Wed, 9 May 2018 11:51:54 -0400 Received: by mail-pl0-f67.google.com with SMTP id t22-v6so4544081plo.7 for ; Wed, 09 May 2018 08:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XsZ4xpX7ZZEPvDoRAmwtFTmoTgdpxNdLQdWi8yBEMJE=; b=aj4SqiqMAF5WezkzFwnjMwePgfxDfiu/fkvSLUmRmmILO/mrbYaHDxWRME+Q86HtvN taehn0Z7dRXOTpzYdT7dE6SHYSUw3spv/+9bCGPSJYlRw9ahsKECeh4FblF6GR6ltcG3 NncRjxt2134HGtEdjH2ERA34xTj27R0roZDJo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XsZ4xpX7ZZEPvDoRAmwtFTmoTgdpxNdLQdWi8yBEMJE=; b=Glxl6t+xwiVj8Z7w82EarWC8SbGw6KQ9siAYRfjOtTFUdJNhzgDtOT9SURepTKDZWR 8+ZW3s59VqyI8UukdgDqeg4pmMCBdxsHTue0cYfvKPLj4zS7AlE7lrfG3GPlBZ1siRYI wTzX5trED69SrfOSSt3iGUOdq+1vmBWEopotfUqfZPz6FXjTdADHD+Buybq5DmhDOpPg BW8TI/f/OYriyg+KjxZBU0rHA1CSeGP2OmcqYuGC++e/bubxNKvozoEhC41pftO++WJD cagHIP67NSFQcKW4U/AXiGG8LogCG6gKMPbVEL/xcylMtKwhhHBr9L04gP9e57KMAbs2 XVqQ== X-Gm-Message-State: ALQs6tAq8oNbYtndPKGr7OcnOLGilGCX8+wV/FNC3g+i8akE6IebwEEj TxfYAxDRAodChx11YshIG04ywQ== X-Received: by 2002:a17:902:b189:: with SMTP id s9-v6mr18172554plr.352.1525881113980; Wed, 09 May 2018 08:51:53 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k24sm26213350pff.118.2018.05.09.08.51.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 08:51:53 -0700 (PDT) Date: Wed, 9 May 2018 09:51:50 -0600 From: Mathieu Poirier To: Leo Yan Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org Subject: Re: [PATCH v2 1/2] perf cs-etm: Support unknown_thread in cs_etm_auxtrace Message-ID: <20180509155150.GC25559@xps15> References: <1525839312-20544-1-git-send-email-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1525839312-20544-1-git-send-email-leo.yan@linaro.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 09, 2018 at 12:15:11PM +0800, Leo Yan wrote: > CoreSight doesn't allocate thread structure for unknown_thread in etm > auxtrace, so unknown_thread is NULL pointer. If the perf data doesn't > contain valid tid and then cs_etm__mem_access() uses unknown_thread > instead as thread handler, this results in segmentation fault when > thread__find_addr_map() accesses thread handler. > > This commit creates new thread data which is used by unknown_thread, so > CoreSight tracing can roll back to use unknown_thread if perf data > doesn't include valid thread info. This commit also releases thread > data for initialization failure case and for normal auxtrace free flow. Hi Leo, Arnaldo maintains the perf tools and he receives dozens of patches every day. If his name is not the first one to appear on the "To:" list, it is unlikely that his email filters will catch your patches. Mathieu > > Signed-off-by: Leo Yan > Acked-by: Mathieu Poirier > --- > tools/perf/util/cs-etm.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > index 6533b1a..69f21de 100644 > --- a/tools/perf/util/cs-etm.c > +++ b/tools/perf/util/cs-etm.c > @@ -239,6 +239,7 @@ static void cs_etm__free(struct perf_session *session) > for (i = 0; i < aux->num_cpu; i++) > zfree(&aux->metadata[i]); > > + thread__zput(aux->unknown_thread); > zfree(&aux->metadata); > zfree(&aux); > } > @@ -1355,6 +1356,23 @@ int cs_etm__process_auxtrace_info(union perf_event *event, > etm->auxtrace.free = cs_etm__free; > session->auxtrace = &etm->auxtrace; > > + etm->unknown_thread = thread__new(999999999, 999999999); > + if (!etm->unknown_thread) > + goto err_free_queues; > + > + /* > + * Initialize list node so that at thread__zput() we can avoid > + * segmentation fault at list_del_init(). > + */ > + INIT_LIST_HEAD(&etm->unknown_thread->node); > + > + err = thread__set_comm(etm->unknown_thread, "unknown", 0); > + if (err) > + goto err_delete_thread; > + > + if (thread__init_map_groups(etm->unknown_thread, etm->machine)) > + goto err_delete_thread; > + > if (dump_trace) { > cs_etm__print_auxtrace_info(auxtrace_info->priv, num_cpu); > return 0; > @@ -1369,16 +1387,18 @@ int cs_etm__process_auxtrace_info(union perf_event *event, > > err = cs_etm__synth_events(etm, session); > if (err) > - goto err_free_queues; > + goto err_delete_thread; > > err = auxtrace_queues__process_index(&etm->queues, session); > if (err) > - goto err_free_queues; > + goto err_delete_thread; > > etm->data_queued = etm->queues.populated; > > return 0; > > +err_delete_thread: > + thread__zput(etm->unknown_thread); > err_free_queues: > auxtrace_queues__free(&etm->queues); > session->auxtrace = NULL; > -- > 2.7.4 >