From patchwork Thu May 10 04:01:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 135385 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp523639lji; Wed, 9 May 2018 21:02:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr3oL0K9A0FLvqe5m2FoWKvyoFOuEeWehNtFywbH1hduDI9fd8VsZt6Uk7mCF7bqMChd0OJ X-Received: by 2002:a17:902:8d85:: with SMTP id v5-v6mr33059814plo.93.1525924949301; Wed, 09 May 2018 21:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525924949; cv=none; d=google.com; s=arc-20160816; b=vzmNvqyE7t9BBx9ox5NGWjoNo4nnn22xzb2K4iIxOBNT3K3pdQqPcDkgapDNpLkT9f 9gYPhGpZWiZhBYCc8mhUt1x/4wXPSIs6oFCgH/TIM+sXdyYORzkDIm7SikJflEA6oBwn AFRkD4Y8bIELUS84cZCPceCcD1iAWpJGQX1rttjeCbRPNkQVbPr9JmImmhyB/OdUkUZ7 C6znS74QuWGY7jgRoLT24AkqNs8itvdGSELtbjgi6JpEp231n3CScWtXpdSL8sbS24BY UVubAgcIkh51f5PYkVD2PdX7yEXMciW9VOQvW7sjosCTOsVwEHAHXk4jeQZQWAI69N9i fhag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Wum+rzdoXN+FHN2IKXvcJz2kTVf930y5axBnIVXgUj4=; b=H8U36QV72kxL+Uopuryc6d7RdHWtGiCfNKE5bJ3v8NaU1J+tMAe2RM6YkSxnboqLzt XNZ2LCBnMyR8XZwjmaXddmvu6WdgdjC4RiOgi+ac+gIrWfBa4KBjXNkE6FMiK1ywaKJ6 wOxWIiQOWOoF9a41zcIAUJEj3h52QnYDqGp8cWtb32onc2OQ/tn38YfjCh1la1l72fU6 TcgdmKdjp7x6WaIHMaOxJdrrgQJp2IBu1Z4oMXwswuX3j6Rf4pnh+fTeyr6/OGyi7VNt fzVsvv2dIVshj7DDCmpkTzY/yaVpFcL/eJGcsXlPKD1OScnNRkY3jZu7b910I+X9sVws 8KHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CiQZuxn0; 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 z86si28612961pfa.120.2018.05.09.21.02.28; Wed, 09 May 2018 21:02:29 -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=CiQZuxn0; 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 S1751219AbeEJECW (ORCPT + 29 others); Thu, 10 May 2018 00:02:22 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:40654 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbeEJECV (ORCPT ); Thu, 10 May 2018 00:02:21 -0400 Received: by mail-pg0-f68.google.com with SMTP id l2-v6so364918pgc.7 for ; Wed, 09 May 2018 21:02:21 -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; bh=Wum+rzdoXN+FHN2IKXvcJz2kTVf930y5axBnIVXgUj4=; b=CiQZuxn0nN1gDbh9BxeZzDrV2Ksna/f1hsgknWaWv6TQ0DT4fk3pXcAxfaW8C6mV2f o4MmIBxPfQFr98YZSaH2bcV3QxGyhKLcDtEk623y133hTmr+Er3DTcSQlV/d+RD1DklJ WIbxgdlxRxLiaWOmC8G/2pYAfKXK3ibrASLbA= 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; bh=Wum+rzdoXN+FHN2IKXvcJz2kTVf930y5axBnIVXgUj4=; b=Chwsk51HH9Ternjh7cBI9AjOYWT/I2ZVoJT6P14mjAdljFd28mMdLRDv2cCfY3Xlds Okdlb+7oxECn7FpjOFR9esHNRPSlxp4UI5d2sb3fORDkRd+8+l+v3JnGxTX/OW0KatU/ kxCJ/XyIR7bzP7y+r8NdqDLK3G9ejTiUJox59RXM+k3E0p+INQ+6aHdroiE2i/KfSKUE v2axtoc+7n12qGGhpWu0otNw8dEln5O0SIMddMtqAHjKKncFW+Nefi8K5IY47X0wHGvK 3RVBLz8Kl0+B/j2bnVfD5w/zELvDfUzz9qU6Te2VVRamCUE41kVtb0BtZQ5Rd2i2/f4E faWA== X-Gm-Message-State: ALQs6tD31zlfC36dMGS/GwlYm5bKNSycz+JNpm3XYBixh4s44Q4xWbuX MnY3WeziR3SysBg7/FGJv1MXE/KVtZw= X-Received: by 10.98.236.24 with SMTP id k24mr46264844pfh.204.1525924941023; Wed, 09 May 2018 21:02:21 -0700 (PDT) Received: from localhost.localdomain (li1168-94.members.linode.com. [45.79.69.94]) by smtp.gmail.com with ESMTPSA id p71sm65694877pfl.170.2018.05.09.21.02.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 May 2018 21:02:19 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH RESEND v2 1/2] perf cs-etm: Support unknown_thread in cs_etm_auxtrace Date: Thu, 10 May 2018 12:01:59 +0800 Message-Id: <1525924920-4381-1-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Leo Yan Acked-by: Mathieu Poirier --- tools/perf/util/cs-etm.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) -- 2.7.4 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; From patchwork Thu May 10 04:02:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 135386 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp523712lji; Wed, 9 May 2018 21:02:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpDo7k6xZSMzWK6ZKHjo72NrkK4aQKuvA0No2WzzT1uRCQALAifD6UBDQ0TFsGIOScZD8YC X-Received: by 2002:a17:902:5948:: with SMTP id e8-v6mr48815632plj.121.1525924955118; Wed, 09 May 2018 21:02:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525924955; cv=none; d=google.com; s=arc-20160816; b=Dn5sJ9udjNRDjeV2RKtbHy7yppEEU87IbRI4PKPfnz5XPiXuzX88YOYpxfWzkcoZrx /SJar9BS+sJefPTsC2pJ1yK7Fr726nwCX7D5RK1DG0Bie46t1IGhrKIgG+cBlAjjBdAy Vqyl6VUw5jTzH3o5bhrYXGBrs7i+mWL2Wy2p7TZW2vvknzvvA9LOFj0k/LT5NmQq9NCS tiD+nXXdC0BamkWi02qCH6CMrADwKwj/rrDGI0KWKWuSWNeThHK8s/NJwYP6Qgds1P5V JHQaoNOyk6aNgjvEmoBrrEXOZECmeyRV8qj0b0zfdL1RP90lTfhSjvVwKT/yVlyDCWVW 1JjQ== 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=Ig5oF+B5UpgqxT8qsgIKhHIB5YsLTbShoMIGDsuk7kA=; b=fZ4VZG9KNde76GH2ZYoCptcCXneRA8njl5ReEhJ2/872OILNCuah/pnha5DDjbCfal GcYPSq/sHfqfp+Sqf+rdTI/b5it4EM+QGrd/R3wnTT3yss2P0KuhI3EDMD/976SKDNJB gQLR7qg82OySYR+56ydkgJTarHkbVY3jgxkCH7ze0KkDyqWj9YxMQcjgkUHK3EqtQG7a dz2lv2JcSN3Nf86uj76dUzbrpL3GcHhPGPX3D02961W+ZDhzp09B+HY2ig9c+hCU2iiH 4aF6u2t4tWcoiurjf3FpnUdYN8sbNSrc5JuuT/4xfGEvPYSyXOWDzcxoZWjn9Lju4/+o ULYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aYtXhU5K; 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 d24-v6si27581338plr.302.2018.05.09.21.02.34; Wed, 09 May 2018 21:02:35 -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=aYtXhU5K; 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 S1753516AbeEJECa (ORCPT + 29 others); Thu, 10 May 2018 00:02:30 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:45769 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbeEJEC0 (ORCPT ); Thu, 10 May 2018 00:02:26 -0400 Received: by mail-pf0-f195.google.com with SMTP id c10-v6so403329pfi.12 for ; Wed, 09 May 2018 21:02:26 -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=Ig5oF+B5UpgqxT8qsgIKhHIB5YsLTbShoMIGDsuk7kA=; b=aYtXhU5KethPb3ujSupgoxvKm6CW+fOuGPRZMTQ9zihqKjx26ZjCQDYxSEuhKcrykk aSQgMMriEVkp5SsywZjiaOarMOVptm3OO1wMcMpIFsb0dA23kusTO5fTYMjCUikBVU3t Q4M0YBY7x00Bt1fv4HxLn7+C6pleBiQpWGvqo= 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=Ig5oF+B5UpgqxT8qsgIKhHIB5YsLTbShoMIGDsuk7kA=; b=CQym83PMKf6aC1L3qRor1MtyOLFonhyA45ohHJdMUvQcH2/k7VWWK7esi8ssfrYUVr LVxbdEGfxxL3QbXDCpXghrcmrrDViQ1muAOpbr9mW83wKhFXDvSYscTmMsq02EzoFhBs DO0IwffemruGo/CAO7ZE8d8pRT38lqZdutWQVwDrlDM+GBeYrRRc+ppsPM772QuwNJQV +fIVAiwoBL5TMZnq9jn8eRBM/vENTwcu0L8mGxBBAB8o/HUx0IbiKoRtG7BiuIrY4Q4N 3yZ+llJ0JMT98zdAUmicsJdFrBWWdqCh0TAqmKQrqETcml9vumsY+vQcvHGtAt7uU40J iH9w== X-Gm-Message-State: ALQs6tDSiNp75EjCGryYcZVzCtujnFK3T4B6PUHnWr58NdytHAGw0vSw PyZkz9Rh/9V2rH6tHugBFxEtYA== X-Received: by 2002:a63:7f58:: with SMTP id p24-v6mr37562034pgn.290.1525924945878; Wed, 09 May 2018 21:02:25 -0700 (PDT) Received: from localhost.localdomain (li1168-94.members.linode.com. [45.79.69.94]) by smtp.gmail.com with ESMTPSA id p71sm65694877pfl.170.2018.05.09.21.02.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 May 2018 21:02:24 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH RESEND v2 2/2] perf cs-etm: Remove redundant space Date: Thu, 10 May 2018 12:02:00 +0800 Message-Id: <1525924920-4381-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525924920-4381-1-git-send-email-leo.yan@linaro.org> References: <1525924920-4381-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 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 --- tools/perf/util/cs-etm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 69f21de..822ba91 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -611,8 +611,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;