From patchwork Mon May 14 12:23:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 135737 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1699030lji; Mon, 14 May 2018 05:24:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqY1uI5RL34FGHtILanKnEAHQih7M7V8wltpqCH59lIdq91ne7mb2xJtPKEWAFebVXyOPno X-Received: by 2002:a17:902:6bc7:: with SMTP id m7-v6mr9470864plt.162.1526300667798; Mon, 14 May 2018 05:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526300667; cv=none; d=google.com; s=arc-20160816; b=iymDI9PTh9b6Zx+PwSOKcWwWMShr0wac7xjQzBZcHq//FUzf+xc2LlG1HMRZGI4zhf aRJBE9bNxGAcf4ifKtz4V6OeifV+rrE9lTyMfVyi6CGkEkWI2brGZIXziuvqFLj7q67S t2KyDGvgjvz3wP2TLQqG0XyuwsXRO8iIP8AIkLBc7bilgjx/Gt5pjz8WeNh5I4V6T6Pa SI6iwEBzzPW7KCuYKw6XbQCew51JTBtTx+r+IKWpNEVZR1D/dH98s6teeNsES9RpCc8R ib4m9Hk809G9gixvK1nygelTKlyZMM7oJYBIhVIRm9cjHeHy87vAkvjR8ycqh4Pj7t/+ eLFg== 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:arc-authentication-results; bh=iVEut5u5rpLPu3196XeSLPvWTUyXUdkCKj6ZE+SkkY0=; b=RUFgfvNKgbdW2S/6nc0kSEGsO5HkPSq6XquOSJXIDlSoWKbe80yBXtkfI/yrYn/xQG OQ+812RltbPXZ1nWixEHwDkFV4+U0v4ScXoFAxcjtxysMZ9Q8/H+Vcpt8IOnVUCGBSJq vswN3T6JvhHNczQuCsr2fiOpNo0yU7ipQsQHcHN3fYA2MLHYtAo490SGUPHr59HE0BMi Rq9zt6at82FhH3ZHp/19Z7sUrotvlTpc2aFWeI7NqG3gDRjLSp9PdJt6deLezIH9ItvP +AFFGq8t1h8KXqIB4tcgDSCf0aPzoBJGge5MfF/h9hlqRsKHyELBELDnZbkZrrva6+tX xTcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SoaCm6f5; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n129-v6si3358529pga.434.2018.05.14.05.24.27; Mon, 14 May 2018 05:24:27 -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=@kernel.org header.s=default header.b=SoaCm6f5; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753338AbeENMYY (ORCPT + 29 others); Mon, 14 May 2018 08:24:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:52504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752539AbeENMXl (ORCPT ); Mon, 14 May 2018 08:23:41 -0400 Received: from jouet.infradead.org (177.207.143.132.dynamic.adsl.gvt.net.br [177.207.143.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EF9FC21739; Mon, 14 May 2018 12:23:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526300621; bh=gVXHBHeMXJElIhTPBMme6F/NlCrkBPqNg/pr7A6XFuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SoaCm6f5EwK1zy1d8NOTOCKnB0T2R/pt8O3ZFOHSvYvjIVz2apb3fzW7NQoLfDNvM NXpizhWQ/rSmiTFKFa2LryoosgvbovmVViKgK25rDQvH+B7YE9RE3T3xjXY4xJ2dD6 xeS8tLjkt5FG7AMSPLNmhHQdCr8F4KZR5EKKJKZg= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Leo Yan , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Peter Zijlstra , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 3/5] perf cs-etm: Support unknown_thread in cs_etm_auxtrace Date: Mon, 14 May 2018 09:23:19 -0300 Message-Id: <20180514122321.27304-4-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180514122321.27304-1-acme@kernel.org> References: <20180514122321.27304-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan 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 a segmentation fault when thread__find_addr_map() accesses the thread handler. This commit creates a 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. Signed-off-by: Leo Yan Acked-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1525924920-4381-1-git-send-email-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) -- 2.14.3 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 40020b1ca54f..2bf28b5acc08 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); } @@ -1357,6 +1358,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; @@ -1371,16 +1389,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; From patchwork Mon May 14 12:23:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 135736 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1698345lji; Mon, 14 May 2018 05:23:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrrcmHyKEC/SSi+OgXM3SdvbBghix/ySDW2Bp8JWZlcq8sLf2sRxBQ0f/EPYj731NC2vYVn X-Received: by 2002:a17:902:c5:: with SMTP id a63-v6mr9700299pla.149.1526300633109; Mon, 14 May 2018 05:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526300633; cv=none; d=google.com; s=arc-20160816; b=N1hqXbuOF35nVJSIgh3q6z1DMa+Ad8TJ+f5UJ2ZEyIllst0tUovVVJJNhGDB+BFrnP yA+w0Fg+k3xm8tNu3bjWgZpwnsBgcvRag5phhKD8slBG1HmgEJ/9Zy8TRRAoZNOPEPLo dB2147YJgSZugbTutVN5QWphn58WEnKB0M/3LUeQw5KOxeL7dU83Or9yYTO0zLPmo8aW jiOehb/7oZD1Dz2lyW0+ZknV9YQYZ/WDRcgLZD9wm5rjv0gnnk+MIfSjFp9KwSwWZH3r dmO87TM6tc0hWEuFzNqX0ude49ZZQaVb1ctVgdMu5a10zVqG1IZXUxCUGThje707Z/m1 7gdQ== 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:arc-authentication-results; bh=cLBrYvDcCSQfSLvZA/ESjyNqd0VLqrMVOGZKJ0aHcMk=; b=Po2kyIoKXCb9jUn7QcTF5BeSznBqnE2XGKtzf+nIbr6gbJUXUY1T4XVSQHOEf+hFxa nhFTqZVvY1RIU/HGRVhSTo6lgIgBi1OLEzIa7gF6sQVvZtIlGXHR8jZhwsTnV/FCW5jW Xk5sa5MtNKSrtyCjWcVeAT2VWBf1SiizYe2zdfzztoDwNomi0f6VZzoIAU6ErYuzE4Q+ v68/Lf1bwv2F8Qi0ueDh2e4kR0f5aIkuGtG/AIJETZYX8IJ139fRIXeSxznmNh736a6D umPBMLsVE+UkQfw7Fn/XJORrsMawB60hH/FWYvR9ECXfUT7cB1B/FZq6J4q5/ExWtTAd uOfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n7Waq59e; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9-v6si6798294pgq.131.2018.05.14.05.23.52; Mon, 14 May 2018 05:23:53 -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=@kernel.org header.s=default header.b=n7Waq59e; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753315AbeENMXr (ORCPT + 29 others); Mon, 14 May 2018 08:23:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:52534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753270AbeENMXo (ORCPT ); Mon, 14 May 2018 08:23:44 -0400 Received: from jouet.infradead.org (177.207.143.132.dynamic.adsl.gvt.net.br [177.207.143.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9969D21738; Mon, 14 May 2018 12:23:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526300624; bh=c0xA6D4tNXwUDfYLRMj734RO8OyTlSi7IaXQJiQWpFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n7Waq59eLd8S7vRa+1/hf/+4YzEqzxdAYJlYhUZuB4OCJEP6c1bx+vK6JTBz7Sgh7 4HXdJC3lm2Cw3EJI0z+pUFhsfAteZBwAjXdWO1mXBtwgeY4eT9566po9g3jRAO4CNZ 5L8Dy20BOxidV9ZmP8RqH7Sw/EMURPDelETjHw1I= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Leo Yan , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Peter Zijlstra , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 4/5] perf cs-etm: Remove redundant space Date: Mon, 14 May 2018 09:23:20 -0300 Message-Id: <20180514122321.27304-5-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180514122321.27304-1-acme@kernel.org> References: <20180514122321.27304-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan There have two spaces ahead function name cs_etm__set_pid_tid_cpu(), so remove one space and correct indentation. Signed-off-by: Leo Yan Acked-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1525924920-4381-2-git-send-email-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.14.3 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 2bf28b5acc08..bf16dc9ee507 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -613,8 +613,8 @@ cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq) return buff->len; } -static void cs_etm__set_pid_tid_cpu(struct cs_etm_auxtrace *etm, - struct auxtrace_queue *queue) +static void cs_etm__set_pid_tid_cpu(struct cs_etm_auxtrace *etm, + struct auxtrace_queue *queue) { struct cs_etm_queue *etmq = queue->priv;