From patchwork Fri Feb 15 00:44:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 158454 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp102487jaa; Thu, 14 Feb 2019 16:46:10 -0800 (PST) X-Google-Smtp-Source: AHgI3IaKpBWSdpan6E00N06gCaH/iu8EJq4L4BgWOpWr5GaTg5AGj+BoQKwzRZtLLlRJJKWKefJC X-Received: by 2002:a17:902:c05:: with SMTP id 5mr7226836pls.155.1550191570222; Thu, 14 Feb 2019 16:46:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191570; cv=none; d=google.com; s=arc-20160816; b=DlJPzEhwgcKJwP/KRGlmmex0ICG9OptVkacX+tYkgw9/SeTXXqj47+eIRF0Kh0gQV7 q/e3yx6+dpHoiVdktF5bbRfUgATEGMbYSwt9kMjxHLG+4Zsysw6Y25j+BK3/DdzmQuxg rAfNgiQFR0VmXIYpoaZiyvX8OKWicVcnNajZcI6pCaJ8IgaMkIkiF8+/USayEiXVS6UI a2Bm//tXWOObHWGmLHFAcdBE3u99VKH20QzO5o0rrIiSWbK2BkPnjJJMP0CfZIHzVhm+ 9Rfxl5tpNr8DOdPslhqzV8/wN1s9z/SuCBD4j2LO95x5NxU9/MYCrcRkFHrCS3Gzoh4J 8v2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y7ySSCCo1u9XQWYjbds3sZ9THJRtkR7dmbueltsXLA4=; b=OIymgiJfPM0VUBtxMR4vDq41CcAERvC1ZVwZiGrXbeRYxQGyflUPvKZIaBl0gV6/fi fUDfEeY76ToyvHCUWy4yXp6nymFLR9MNQCohWv8TyrZD3x+TtnppDLOjZUgmpwDyBJIa n/mXgoJ+hpxhTmhydKxNYCR8f1Z0qr4hG82VgHIqtWUJ3GuQ8f36Kkd+IQlVzO3pZ9y9 /uQs8yRV2JJwyF7CiBEonUgNr7k4C5iY2/NosnqhmCqdjYML6wbJvl/3VdS8ZIqWU1xs 96I6dycOLe2fHn/mPwa3kCcO1htPuySVOfiZHj+CcxHpeRqbnLw2sPFvZ8LlhsVjewje 7TCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="d3VbzEm/"; 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 s12si3765571pgm.586.2019.02.14.16.46.09; Thu, 14 Feb 2019 16:46:10 -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=@kernel.org header.s=default header.b="d3VbzEm/"; 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 S1730335AbfBOAqD (ORCPT + 31 others); Thu, 14 Feb 2019 19:46:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:44052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730296AbfBOAp7 (ORCPT ); Thu, 14 Feb 2019 19:45:59 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 7DB8B21B68; Fri, 15 Feb 2019 00:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191559; bh=sAIxCpdE/fBclKe7EWnnZg+XMA9lo5WpgqS/a7OlR64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d3VbzEm/tcLeMndtEOzHImtxIngHZIrxnNcVL0ePWBE27wTZnYELfoB/0jNGkMxnG v57O53PjE2I1m9EE7NMwOzLxCO1yz/E0Z+JM06lytqmJXyR5JHovIJsQSbbnEHARfo UFSpt2SG7f1hr0OZ4LGv0cW3WzO2HRAR3ieRpl3o= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 02/43] perf cs-etm: Add proper header file for symbols Date: Thu, 14 Feb 2019 21:44:58 -0300 Message-Id: <20190215004539.23571-3-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier After 'commit e22c1c751140 ("perf thread: Don't include symbol.h, symbol_conf.h is enough")' Compilation of the perf tools is broken when using the functionality provided by the openCSD library: [...] ... timerfd: [ on ] ... sched_getcpu: [ on ] ... sdt: [ OFF ] ... setns: [ on ] ... libopencsd: [ on ] [...] CC util/arm-spe.o CC util/arm-spe-pkt-decoder.o CC util/s390-cpumsf.o CC util/cs-etm.o CC util/parse-branch-options.o util/cs-etm.c: In function ‘cs_etm__mem_access’: util/cs-etm.c:297:24: error: storage size of ‘al’ isn’t known struct addr_location al; And rightly so since file cs-etm.c doesn't include symbol.h, something that is rectified in this patch. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190208223543.31836-1-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 1 + 1 file changed, 1 insertion(+) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 8b3f882d6e2f..0b11d653cfbe 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -25,6 +25,7 @@ #include "machine.h" #include "map.h" #include "perf.h" +#include "symbol.h" #include "thread.h" #include "thread_map.h" #include "thread-stack.h" From patchwork Fri Feb 15 00:45:19 2019 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: 158455 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103446jaa; Thu, 14 Feb 2019 16:47:31 -0800 (PST) X-Google-Smtp-Source: AHgI3IY9Wn3XBH9pDj/os1qlkisDKRN8E9eMisWP9fyI2viPDOunbErWwRr9OAciGc8Io//qdMAF X-Received: by 2002:a17:902:29c9:: with SMTP id h67mr7237895plb.111.1550191651710; Thu, 14 Feb 2019 16:47:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191651; cv=none; d=google.com; s=arc-20160816; b=R/uKgQa2e1g7oXVh3zotH3FwPIGOXmAMSo1s5khJi7fSbI4Y2GycXlRTx2DGY31oQw JiQFxvZiRR1Bb+O3vSkCULh/kc3Of/D3eQwjVC3DqAzN/zbVv32y/AjHYSFRBpOzXcVX zh5pgDUrP1+v0zA10pYXIwz5wtkhL6VarA9VN2u7omAMRSdjImpM2L4m+wVnG2CV9BPP qvYuOIH7iMJGuV1h2dXVhH9XASwO8LuJDsqnzdtN6aPgyIz5YCKlMv4TUz7TPioWIcbJ zuwq5RQEA2uETeIFNDsx93Hubw1fvesNwh0ZUPHdpxZeEl8kKbMvsY2FESF0+ul10Iuz cNKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8J9zpXzWFAV6cgsojXsh6Wo/qcKLQtjLP1jgY0m+0xI=; b=NpJ8Zc/bqXN27LnTcLfQPt884Q/VzA4ytyWRyg5A5JjbA85jC9OcD0OTG5sVBNgbf4 nJfEk88eIRjm/2uqHHL3U14zJV6wwROWKOkYjpBRwR9jOtYX0qehNaC1MbuXHIQu3gIv sHrmxhvDjoga5EOIuaDrm+cvwuQfwtJyXMTDMs/10evWaf19RhlET1JyAdBzMf/Og1kU GYCm8zWbmWhWM53nYEIEnpyPKl+C+azyOLIWHkeLGfsp6GwVJ6dm6TaL2jwauAWItwKo VFeV2X6hFPFeH2768ef/fYXqZ4wsd8MYw0Yav6v4IteMPr0PG6/8S0A5AvlMzdzoyiij uGiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BiCpHYCB; 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 f1si3558033pgs.104.2019.02.14.16.47.31; Thu, 14 Feb 2019 16:47:31 -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=@kernel.org header.s=default header.b=BiCpHYCB; 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 S2389220AbfBOAra (ORCPT + 31 others); Thu, 14 Feb 2019 19:47:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:46238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388994AbfBOAr2 (ORCPT ); Thu, 14 Feb 2019 19:47:28 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 914B7222D4; Fri, 15 Feb 2019 00:47:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191648; bh=8E0J6WYbqK8hyOb5yfIGW1B4b4NAEZhT5uBJBnFrung=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BiCpHYCBI+dGT1OUrQAp+9iHgFyf42R7b1WS/afWWL5zqyYYgK5kJnrSJBi3FT+4L dXykeIN5pYqJfw/JP7UznbMIOH8/BwxPt8xuK08pOOxYZhv4TSvAz48WfbxATtx86Z 8nDP9KfcJs7/Ko/1rH85qmGdv/dUMERo+wum9uyA= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 23/43] perf cs-etm: Remove unused structure field "state" Date: Thu, 14 Feb 2019 21:45:19 -0300 Message-Id: <20190215004539.23571-24-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Field "state" in structure cs_etm_queue is no longer used and needs to be removed. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-2-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 1 - 1 file changed, 1 deletion(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 0b11d653cfbe..ebd68eb43da9 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -65,7 +65,6 @@ struct cs_etm_queue { struct thread *thread; struct cs_etm_decoder *decoder; struct auxtrace_buffer *buffer; - const struct cs_etm_state *state; union perf_event *event_buf; unsigned int queue_nr; pid_t pid, tid; From patchwork Fri Feb 15 00:45:20 2019 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: 158456 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103505jaa; Thu, 14 Feb 2019 16:47:38 -0800 (PST) X-Google-Smtp-Source: AHgI3IaHQKkqUX+35tRBqoMbvTerOO1xsqRivOaZmu1TnsvQt7/ZNTMSGVZP7zoUXJA8YPNuqMHu X-Received: by 2002:a63:65c7:: with SMTP id z190mr2669817pgb.249.1550191657973; Thu, 14 Feb 2019 16:47:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191657; cv=none; d=google.com; s=arc-20160816; b=A5PhM1dGLC4CFnDamKI+w6Qeutp9f0DECMmTjjnHnMlnCVLpikIVOEOTaoh/VHUgYa MW94Glzo/XYxa47UE5NRvE/2Qj5gHfsDXWEvVVZADoXCYplsEOVevsS2zn8SFeJdcd1D vcMaSRqm29kKvJA4meU2xJpkXDUFHke/5VxTMcHC09fn3+vpiZp67uE9A3OtrOMqrltr RNI8wvEJ2VslK/JtQlX1RASe2a0uvVHNErB9R2S7wcydZ7KGwbuYjVCo2W9hvkZSH5Pe Ifnlprk7XTT8X+8Gf3gacl5BSeeQb3kbpCpoPXp6Cgtdvol8RQAa+qGzqMBtXpDljjx1 RTUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jSw6OI/zZoZ+NzsTz6t9Op2c3MBdPbqW9pNQ7VdfO34=; b=wzC6xPrtgbSUpkpGDfgCGxnnsTp4AI7qGEE9WIibwNx9TQyz/Qa9y9a/zIpNjsychp s/7kIdjlnzsCgIhLuLDnjK75VlOE/lamUqa+RVVubMLoKBO8unoUih95o3MMHNSgcTdj 9hygDWEoZE9Sf763PQx8Kv/Whg+Tywq+e1eGE2Ubl9PuGVvifEoeqbk0AoOGZJaNhkod u6o0uU7gmvjBlGn3q7nF/TH8i5iAQ6m3ZuBZqlQASPEnmoZKWSuYl2tMC+otkwiHj04w KbFSB3+6xB556AyP/4GXKyyF+MqTE9Lqqdzpkv81RgvJRfTxaqZtmh2qPO3RAt2iuWf7 oQfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HuGtlp3O; 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 gn11si3859151plb.94.2019.02.14.16.47.37; Thu, 14 Feb 2019 16:47:37 -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=@kernel.org header.s=default header.b=HuGtlp3O; 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 S2389278AbfBOArg (ORCPT + 31 others); Thu, 14 Feb 2019 19:47:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:46338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389224AbfBOAre (ORCPT ); Thu, 14 Feb 2019 19:47:34 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 E1EC82229F; Fri, 15 Feb 2019 00:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191652; bh=QIatHaw3Pd5ihg58PDRuNTKAZDK95EbTjHOpkdkaj0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HuGtlp3Ob8IeHmdrInDSqwbqnbmKQj/a+Ozr7S3TYLPKshbt/ejIT23YvK0meAVnd 8EcpsglRAqdRDOlCl4D8vrlKy++0eoBNK6XR9NGV7Xp8Gg/pnF+hk3a6TKu1FuPjZd 5gpO/G6apyG1HWqnt6ZFFlsmI3L+z4ohDwibTGjE= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 24/43] perf cs-etm: Remove unused structure field "time" and "timestamp" Date: Thu, 14 Feb 2019 21:45:20 -0300 Message-Id: <20190215004539.23571-25-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Field "time" and "timestamp" in structure cs_etm_queue are no longer used and need to be removed. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-3-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index ebd68eb43da9..1d9419a0cf0c 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -69,8 +69,6 @@ struct cs_etm_queue { unsigned int queue_nr; pid_t pid, tid; int cpu; - u64 time; - u64 timestamp; u64 offset; u64 period_instructions; struct branch_stack *last_branch; @@ -82,7 +80,7 @@ struct cs_etm_queue { static int cs_etm__update_queues(struct cs_etm_auxtrace *etm); static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, - pid_t tid, u64 time_); + pid_t tid); /* PTMs ETMIDR [11:8] set to b0011 */ #define ETMIDR_PTM_VERSION 0x00000300 @@ -234,7 +232,7 @@ static int cs_etm__flush_events(struct perf_session *session, if (ret < 0) return ret; - return cs_etm__process_timeless_queues(etm, -1, MAX_TIMESTAMP - 1); + return cs_etm__process_timeless_queues(etm, -1); } static void cs_etm__free_queue(void *priv) @@ -1583,7 +1581,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) } static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, - pid_t tid, u64 time_) + pid_t tid) { unsigned int i; struct auxtrace_queues *queues = &etm->queues; @@ -1593,7 +1591,6 @@ static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, struct cs_etm_queue *etmq = queue->priv; if (etmq && ((tid == -1) || (etmq->tid == tid))) { - etmq->time = time_; cs_etm__set_pid_tid_cpu(etm, queue); cs_etm__run_decoder(etmq); } @@ -1637,8 +1634,7 @@ static int cs_etm__process_event(struct perf_session *session, if (event->header.type == PERF_RECORD_EXIT) return cs_etm__process_timeless_queues(etm, - event->fork.tid, - sample->time); + event->fork.tid); return 0; } From patchwork Fri Feb 15 00:45:21 2019 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: 158457 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103582jaa; Thu, 14 Feb 2019 16:47:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IYI0cyskvxl0TPKlc7llmAkqC+u1Q1tvCCVzB9wsjQyZCW3wcdal+9II0HS16NJMjFq9u5B X-Received: by 2002:a65:4904:: with SMTP id p4mr2698249pgs.384.1550191664527; Thu, 14 Feb 2019 16:47:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191664; cv=none; d=google.com; s=arc-20160816; b=XStkhFS0iCK0sct2lj1l1Ic+GD1cqynY5wi7MMFdNcAjJDV6yP+ZkZFqNEFnmTp3eM +znWxZ6oCVyiPHXNmHEYSAHxiDIhHojGJH6EpGpZGuAQVL9P4rh+Es7g6W0Rh1rCkKQx cIaoKZJ81xn/t+5ia/P1WcSciO/ogM1CWNkIR2j7cLYO6SS5f9an4Qv6MKJaysfFeXBq lENF5BtBY24UTuk7F1MJvMsIbnChCqsU2lT9OnzHceYIn4C8mfTH2JRLr4BtKrCQpWO0 6eRWnjWK5ZY92IGe2OBS/QSdWpkT5hN93t3jmLAyop0hu3RJLMkPE9iOw78Krj3KTvOr e6UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CCha0YWke1GELkFxdmpnUqq9HNpWT3n3UqXNlCrht1I=; b=tH3l5fPIiSAKhkEOvP0S3mcCJf2xEUaiU+xwWhyMSSXltBx/fW8GISwpLSRDpK6jrc VLx3UFlcp3L5JhNH3dNJC5rkNxf/mXnV09Zmo3nNwlSkhE9n3GLDHyjC5NX6gb0U7eHo vH8/cFcGdK3WhLxRj5r9AQwoVl9yuY4Vk7DeXeqYLLOAvaqg00Rd41XfIjS57X/kWBKR xL5fVn5eHLjj4QzLOQ535T5xH9RKSMlLO8aIUhRimRqwVzbKBRxUM3Zy87NM+8K3vJDO 3eYTLKjISwm/P/oKJUvQWh29B+ScOWJy2pJbtBoIWuB/UvMEqfC8KzYE87/7rH3+9mXu 8XCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="zK/XHAsa"; 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 gn11si3859151plb.94.2019.02.14.16.47.44; Thu, 14 Feb 2019 16:47:44 -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=@kernel.org header.s=default header.b="zK/XHAsa"; 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 S1730478AbfBOArl (ORCPT + 31 others); Thu, 14 Feb 2019 19:47:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:46424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389281AbfBOArh (ORCPT ); Thu, 14 Feb 2019 19:47:37 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 36E24222C9; Fri, 15 Feb 2019 00:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191656; bh=pOeRP4uZkpi3aMp0MnlfEAGPtSqz5e2gzJj/+OoQsRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zK/XHAsa7izj1acW4Xdbe4LufcCrIPpSweD0YK9HyzDdXApiNPYLADXrXA5TQX+lG cY35qBPjAPhKg32/hdEYNrM964tJbLiViFca/qAJ68pSkP9DrbC5zMLavg36Zt97Bo 1ILSiltBJKnQdTYcLjNq/G1q6jVZ/eC4w5wyK1Pc= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 25/43] perf cs-etm: Fix wrong return values in error path Date: Thu, 14 Feb 2019 21:45:21 -0300 Message-Id: <20190215004539.23571-26-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Function cs_etm__mem_access() is supposed to return a u32 but the error path returns negative values at a couple of places, something that really throws off the clients using it. Fix the situation by return '0'. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-4-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 1d9419a0cf0c..f396fee9bb95 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -324,7 +324,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u64 address, struct addr_location al; if (!etmq) - return -1; + return 0; machine = etmq->etm->machine; cpumode = cs_etm__cpu_mode(etmq, address); @@ -332,7 +332,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u64 address, thread = etmq->thread; if (!thread) { if (cpumode != PERF_RECORD_MISC_KERNEL) - return -EINVAL; + return 0; thread = etmq->etm->unknown_thread; } From patchwork Fri Feb 15 00:45:22 2019 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: 158458 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103647jaa; Thu, 14 Feb 2019 16:47:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IalH/MA5TXFkTFyD4r/y8cYZQDQkIrla0sYHmTK9Gndi0bipQ+4lzh6PNj3ndELO9IZ9fgn X-Received: by 2002:a63:fb15:: with SMTP id o21mr2672655pgh.211.1550191669892; Thu, 14 Feb 2019 16:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191669; cv=none; d=google.com; s=arc-20160816; b=pgKVbd2dO0oIIbpXkj/BpqQ4LpbR6GYAbSGpGoKmTY9H7ozeYJ+WSFksh2XnoJrFYe 3YemGHnjcwXYd/wYtM+dOk1UmcGcNzs6LZniwALN0okpLNEb+Z3CD/hqIlXewyOqy0Wr 57hZyDM6m3rWjSEffpm3DCBHUsU5pd9cknJ3qTGisLtd59ZsB4tbVdy4LQUSR5BNv4WF wybhIzOQ3FqLqoOY41QKamkMx/w5etSlCcD+U/5YbMvFcSUC3o+1pfbjKXeRCNH2im4N a+UJdPtzRWNvw3fv6KrzANJR4Up09yzPKdDOQTeK4BZCtumPmdfWnrzIebxQn37L+qlO BPSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3KvJJb0HlwLfNNhTMsWwoN99m4vniUO50ipUCX9yPeY=; b=0JPkK6/Hzy6+ftF/jlw4fNtT0OBduXm80B0ovOjvh0gD2ODUW3UkTzRR6miRTbWliJ TQpQebA7i8+PWstEaNvG7wMNZRz/5+8jvEdN1Rww2gTrrCvaNOlwDRd/gHWZ0Nwmc2pZ SWFyRuFt8Ha2HyHvRPVfLFHHpEQPyOT7kmU+rtBYOps0LeGp9X81qLnmANJRWmPgt+GQ avtL9sUwhE6xsPKYLLhAHS1MGABXjrHzpaIy+1iYgtA54KsoM7ZiW49Dc77fsIOLfj7W eMuKynk5/Rm6lBYiMBlLD1cDZkWuLWA8C71hR5DbqShp1kaZMGMVaiTz+gO9DFB+6VHy +JZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e8H1QGzG; 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 z9si4031375pgf.54.2019.02.14.16.47.49; Thu, 14 Feb 2019 16:47:49 -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=@kernel.org header.s=default header.b=e8H1QGzG; 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 S2389412AbfBOArr (ORCPT + 31 others); Thu, 14 Feb 2019 19:47:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:46518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730479AbfBOArm (ORCPT ); Thu, 14 Feb 2019 19:47:42 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 8039F2229F; Fri, 15 Feb 2019 00:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191661; bh=fbyBVb3RzYOoCKxaDHT5y2hX46bmgahi6LOZy34ChAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e8H1QGzGRd25kFXby/MbzT65rJrqOkxLv4j3lJaJ6FkqtGWi+BicdKJogzrmHIs2F 6whSfFhd0YHSt2FJPU5LSX0664waxpwPAoPSehhyAxSDLB62Ld0uebSy97uJ6BPGsT 76uatpJge5ylizx7yRvdplFK7As6PVOXBXoQFtV0= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 26/43] perf cs-etm: Introducing function cs_etm_decoder__init_dparams() Date: Thu, 14 Feb 2019 21:45:22 -0300 Message-Id: <20190215004539.23571-27-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Introducing function cs_etm_decoder__init_dparams() to avoid repeating code at two different places. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-5-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 3 +- tools/perf/util/cs-etm.c | 41 +++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h index 7e6a8850be4a..663309486784 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -105,9 +105,10 @@ enum { CS_ETM_PROTO_PTM, }; -enum { +enum cs_etm_decoder_operation { CS_ETM_OPERATION_PRINT = 1, CS_ETM_OPERATION_DECODE, + CS_ETM_OPERATION_MAX, }; int cs_etm_decoder__process_data_block(struct cs_etm_decoder *decoder, diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index f396fee9bb95..3011c6cae531 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -136,6 +136,28 @@ static void cs_etm__packet_dump(const char *pkt_string) fflush(stdout); } +static int cs_etm__init_decoder_params(struct cs_etm_decoder_params *d_params, + struct cs_etm_queue *etmq, + enum cs_etm_decoder_operation mode) +{ + int ret = -EINVAL; + + if (!(mode < CS_ETM_OPERATION_MAX)) + goto out; + + d_params->packet_printer = cs_etm__packet_dump; + d_params->operation = mode; + d_params->data = etmq; + d_params->formatted = true; + d_params->fsyncs = false; + d_params->hsyncs = false; + d_params->frame_aligned = true; + + ret = 0; +out: + return ret; +} + static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, struct auxtrace_buffer *buffer) { @@ -182,12 +204,9 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, } /* Set decoder parameters to simply print the trace packets */ - d_params.packet_printer = cs_etm__packet_dump; - d_params.operation = CS_ETM_OPERATION_PRINT; - d_params.formatted = true; - d_params.fsyncs = false; - d_params.hsyncs = false; - d_params.frame_aligned = true; + if (cs_etm__init_decoder_params(&d_params, NULL, + CS_ETM_OPERATION_PRINT)) + return; decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); @@ -436,13 +455,9 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, } /* Set decoder parameters to simply print the trace packets */ - d_params.packet_printer = cs_etm__packet_dump; - d_params.operation = CS_ETM_OPERATION_DECODE; - d_params.formatted = true; - d_params.fsyncs = false; - d_params.hsyncs = false; - d_params.frame_aligned = true; - d_params.data = etmq; + if (cs_etm__init_decoder_params(&d_params, etmq, + CS_ETM_OPERATION_DECODE)) + goto out_free; etmq->decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); From patchwork Fri Feb 15 00:45:23 2019 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: 158459 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103680jaa; Thu, 14 Feb 2019 16:47:53 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia2A6Dw6h9ZQ6WVrq0ZBG7BvskKb9K6Y9XgObBeze2Lbz70dPmKK+Nlre9NMqf5U5tHqPaa X-Received: by 2002:a62:60c7:: with SMTP id u190mr1950890pfb.180.1550191673838; Thu, 14 Feb 2019 16:47:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191673; cv=none; d=google.com; s=arc-20160816; b=aGyCDvY1HPFmT1u7RVikzMLp8fDdwfi6ueCbwA0GDx4uqhkqG3UUE7/lMTmo7UUWs+ 1+TLYXxiLpc83kfE4kYuGLSG07VmMVFg4CRcrCLFBJqB4ZO6m6ambWfr0ONVLzCaNoC1 2LNQ/5RL8nbqcJoYJOslJ4R0Iq7yAE1fnR9pb7gUPrpfO5kywkHGA3jypCK2j+Pl7FXc qF2SPeohTkWWPkOcleYiVCz+IxjIATiyP9br9q0STz8GhY1zUWA0BkTwk1W7VrfkgHbS sXBH3bTf54vdHn0IqqvZcUYqSu7oyV2/QQ+dmrg5K2QVzlKWZg3Aflp3yF+MKXhzLRjA m9rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i6OkLRdtAldLsIpdJN8Vv5mrhz56uZ3mV2R6jqLJXXE=; b=f7Ejlm05rMqxqEQJLaTPv++SmoyUr+OrOJg+xkWKlFXqTaBMjIgqgNLyIeF3pxhnaY dDqtGRdxWpesZNTBWehZ9Jvr3RyM4DYFfmKOyq+SJBbD5rBYbL/rDXdeDNq+msq67Nku kycFBvy1CGKfzJLJ7BN3nqa1PYfDUOXtrDa00wP34RZ3rR7aNs3/fQqaWM7txzcG/lUn 2xVcnWRhVsrkyQfjx+IjEqnk5jMGrcm1TeBzVAG1gBag0Z9gG68IQjn29BcfH9vIEaY+ kw1gWfesit37H7pOKaz1JQUKtk8xGAuXcGsblXVnWhRZmDSrEnBvyxt16DxNbJ7gNABM xosA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FvhgmoLi; 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 z9si4031375pgf.54.2019.02.14.16.47.53; Thu, 14 Feb 2019 16:47:53 -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=@kernel.org header.s=default header.b=FvhgmoLi; 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 S2389344AbfBOArw (ORCPT + 31 others); Thu, 14 Feb 2019 19:47:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:46596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389377AbfBOArq (ORCPT ); Thu, 14 Feb 2019 19:47:46 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 CBF36222D0; Fri, 15 Feb 2019 00:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191665; bh=59/Jn+pGlKT7JzKEMbIhX3CYYQrWCvYqFcJL9XeciIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FvhgmoLipdaH5yxlQDP9ynnnPY0u5qu5F3dhw/fttZ6B/bnoTDQcOyXeBsgKQY/+T j2kK7SlFj6CJDvVgYGrHLPBaPfCr8axPhuxoBe9wIGgDmmp9kn/qhc6lfU6Wbwe6yK A4yfOZakYbHAn1Ag7SA1DjExUIhCZWi+ZS7lrl88= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 27/43] perf cs-etm: Fix memory leak in error path Date: Thu, 14 Feb 2019 21:45:23 -0300 Message-Id: <20190215004539.23571-28-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Memory allocated for variable 't_params' isn't released properly in the error path of function cs_etm_queue *cs_etm__alloc_queue() and cs_etm__dump_event(), something this patch addresses. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-6-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 3011c6cae531..aac07f950074 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -175,6 +175,10 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, /* Use metadata to fill in trace parameters for trace decoder */ t_params = zalloc(sizeof(*t_params) * etm->num_cpu); + + if (!t_params) + return; + for (i = 0; i < etm->num_cpu; i++) { if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR]; @@ -206,14 +210,12 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, /* Set decoder parameters to simply print the trace packets */ if (cs_etm__init_decoder_params(&d_params, NULL, CS_ETM_OPERATION_PRINT)) - return; + goto out_free; decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); - zfree(&t_params); - if (!decoder) - return; + goto out_free; do { size_t consumed; @@ -228,6 +230,9 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, } while (buffer_used < buffer->size); cs_etm_decoder__free(decoder); + +out_free: + zfree(&t_params); } static int cs_etm__flush_events(struct perf_session *session, @@ -379,7 +384,7 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, { int i; struct cs_etm_decoder_params d_params; - struct cs_etm_trace_params *t_params; + struct cs_etm_trace_params *t_params = NULL; struct cs_etm_queue *etmq; size_t szp = sizeof(struct cs_etm_packet); @@ -461,8 +466,6 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, etmq->decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); - zfree(&t_params); - if (!etmq->decoder) goto out_free; @@ -475,6 +478,8 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, cs_etm__mem_access)) goto out_free_decoder; + zfree(&t_params); + etmq->offset = 0; etmq->period_instructions = 0; @@ -483,6 +488,7 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, out_free_decoder: cs_etm_decoder__free(etmq->decoder); out_free: + zfree(&t_params); zfree(&etmq->event_buf); zfree(&etmq->last_branch); zfree(&etmq->last_branch_rb); From patchwork Fri Feb 15 00:45:24 2019 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: 158467 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp104830jaa; Thu, 14 Feb 2019 16:49:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IYCcI9E5mrjDmAk9gYatZrqETPI8zjCLxGhQKvuq83GC7bQq+cSdk8UyBiC0PACzgptOvxa X-Received: by 2002:a65:468f:: with SMTP id h15mr2915715pgr.391.1550191773527; Thu, 14 Feb 2019 16:49:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191773; cv=none; d=google.com; s=arc-20160816; b=EY4Lxgmd/xE6l9jkAJPmK4eA4At6xDSGjcP6cRhXDafJBu5PfI7o3wLTQkdn/0RuKs uIxEGXKY9u9+NDiKhmCwBFp7zxiT9Lb2ZhnWMudBBJdHiTVzFLmPautGUbGi1Po2JpL7 8sVkHMCR9Oqcx8Twv4Y8ttL9Meqb16ud9K88hUitaNC64HU1XZgc6SPejhEx87VvqA2L C6cTitA1THJFvLXIKQXWFHLmRGRm3nt911h0MD4uscRRm4ryGbIPnIC5BOy4JNes1YDY RtVOi4siUyrwLlPJ33FmktbAz7OnPwDhCu7HP4q2wUuz6XwihpE5pAyLLdFl+fu98K3D djMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7sA5ojJAT0IWcth65NY7VoxtLi5n6WsiHDq2ImmbOvw=; b=BEiecFwbdoK4SifrqKZUKq2rP7QkU0ybV9zHMCEO4V2ay+WKfxCVh8KwRiY1xhQmN7 t1pagt1cDLfk1Zgp37AN5D7ZUEEEXIjiAUN5pExjceMdJM+jkf/q3QDF5nu1FjPsIqXS ChJhu2pjUchwBoQBrlYZAsnYbAKyVrjKSOU27PmQR0dzGmtQXAjTXm7lDalIXt1eG85y MDq/o/oD87knQIJ/KL57gk8TG5dlDUfmOsn8R6Z+oTco1WPsI0lPzSquhj8Aun3ZxOMe PFuhTr6qitXj+TlPER1qOFXkf+6NMw9oXN/4mNeyT1kS4NKQQofgWat/zQeyMPT2QHFX WxZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dZh3fjwP; 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 e10si2200835pgm.503.2019.02.14.16.49.33; Thu, 14 Feb 2019 16:49:33 -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=@kernel.org header.s=default header.b=dZh3fjwP; 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 S1730562AbfBOAtb (ORCPT + 31 others); Thu, 14 Feb 2019 19:49:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:46710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730479AbfBOAru (ORCPT ); Thu, 14 Feb 2019 19:47:50 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 1E8A0222A1; Fri, 15 Feb 2019 00:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191669; bh=/f1RVlzt5D9FDbtr4L+5gYEmFOntVdiHPghg0jfpF/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dZh3fjwPGFGyWW5zTnZOskn26phaXLztbNWy9A7aZcSICakp/Ko6fV0hZfuRSAnbt SGcvbZm6PgNCwcxZJ5jMI6mZMSRNzPzIO6BtmYPoQhVvSXRDmIOYWV8a6j1O260V0C ZGat4s5J7/dTvS/NmWu49q1Wy96DolOTCHQhV7t0= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 28/43] perf cs-etm: Introducing function cs_etm__init_trace_params() Date: Thu, 14 Feb 2019 21:45:24 -0300 Message-Id: <20190215004539.23571-29-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier The trace parameter initialisation code is repeated in two different places, something that bloats the file and can lead to errors. This is fixed by introducing a helper function and calling the right protocol initialisation code when required. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-7-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 112 +++++++++++++++++++-------------------- tools/perf/util/cs-etm.h | 4 +- 2 files changed, 58 insertions(+), 58 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index aac07f950074..f3a6dfaf3026 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -136,6 +136,57 @@ static void cs_etm__packet_dump(const char *pkt_string) fflush(stdout); } +static void cs_etm__set_trace_param_etmv3(struct cs_etm_trace_params *t_params, + struct cs_etm_auxtrace *etm, int idx, + u32 etmidr) +{ + u64 **metadata = etm->metadata; + + t_params[idx].protocol = cs_etm__get_v7_protocol_version(etmidr); + t_params[idx].etmv3.reg_ctrl = metadata[idx][CS_ETM_ETMCR]; + t_params[idx].etmv3.reg_trc_id = metadata[idx][CS_ETM_ETMTRACEIDR]; +} + +static void cs_etm__set_trace_param_etmv4(struct cs_etm_trace_params *t_params, + struct cs_etm_auxtrace *etm, int idx) +{ + u64 **metadata = etm->metadata; + + t_params[idx].protocol = CS_ETM_PROTO_ETMV4i; + t_params[idx].etmv4.reg_idr0 = metadata[idx][CS_ETMV4_TRCIDR0]; + t_params[idx].etmv4.reg_idr1 = metadata[idx][CS_ETMV4_TRCIDR1]; + t_params[idx].etmv4.reg_idr2 = metadata[idx][CS_ETMV4_TRCIDR2]; + t_params[idx].etmv4.reg_idr8 = metadata[idx][CS_ETMV4_TRCIDR8]; + t_params[idx].etmv4.reg_configr = metadata[idx][CS_ETMV4_TRCCONFIGR]; + t_params[idx].etmv4.reg_traceidr = metadata[idx][CS_ETMV4_TRCTRACEIDR]; +} + +static int cs_etm__init_trace_params(struct cs_etm_trace_params *t_params, + struct cs_etm_auxtrace *etm) +{ + int i; + u32 etmidr; + u64 architecture; + + for (i = 0; i < etm->num_cpu; i++) { + architecture = etm->metadata[i][CS_ETM_MAGIC]; + + switch (architecture) { + case __perf_cs_etmv3_magic: + etmidr = etm->metadata[i][CS_ETM_ETMIDR]; + cs_etm__set_trace_param_etmv3(t_params, etm, i, etmidr); + break; + case __perf_cs_etmv4_magic: + cs_etm__set_trace_param_etmv4(t_params, etm, i); + break; + default: + return -EINVAL; + } + } + + return 0; +} + static int cs_etm__init_decoder_params(struct cs_etm_decoder_params *d_params, struct cs_etm_queue *etmq, enum cs_etm_decoder_operation mode) @@ -161,7 +212,7 @@ static int cs_etm__init_decoder_params(struct cs_etm_decoder_params *d_params, static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, struct auxtrace_buffer *buffer) { - int i, ret; + int ret; const char *color = PERF_COLOR_BLUE; struct cs_etm_decoder_params d_params; struct cs_etm_trace_params *t_params; @@ -179,33 +230,8 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, if (!t_params) return; - for (i = 0; i < etm->num_cpu; i++) { - if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { - u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR]; - - t_params[i].protocol = - cs_etm__get_v7_protocol_version(etmidr); - t_params[i].etmv3.reg_ctrl = - etm->metadata[i][CS_ETM_ETMCR]; - t_params[i].etmv3.reg_trc_id = - etm->metadata[i][CS_ETM_ETMTRACEIDR]; - } else if (etm->metadata[i][CS_ETM_MAGIC] == - __perf_cs_etmv4_magic) { - t_params[i].protocol = CS_ETM_PROTO_ETMV4i; - t_params[i].etmv4.reg_idr0 = - etm->metadata[i][CS_ETMV4_TRCIDR0]; - t_params[i].etmv4.reg_idr1 = - etm->metadata[i][CS_ETMV4_TRCIDR1]; - t_params[i].etmv4.reg_idr2 = - etm->metadata[i][CS_ETMV4_TRCIDR2]; - t_params[i].etmv4.reg_idr8 = - etm->metadata[i][CS_ETMV4_TRCIDR8]; - t_params[i].etmv4.reg_configr = - etm->metadata[i][CS_ETMV4_TRCCONFIGR]; - t_params[i].etmv4.reg_traceidr = - etm->metadata[i][CS_ETMV4_TRCTRACEIDR]; - } - } + if (cs_etm__init_trace_params(t_params, etm)) + goto out_free; /* Set decoder parameters to simply print the trace packets */ if (cs_etm__init_decoder_params(&d_params, NULL, @@ -382,7 +408,6 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u64 address, static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, unsigned int queue_nr) { - int i; struct cs_etm_decoder_params d_params; struct cs_etm_trace_params *t_params = NULL; struct cs_etm_queue *etmq; @@ -431,33 +456,8 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, if (!t_params) goto out_free; - for (i = 0; i < etm->num_cpu; i++) { - if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { - u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR]; - - t_params[i].protocol = - cs_etm__get_v7_protocol_version(etmidr); - t_params[i].etmv3.reg_ctrl = - etm->metadata[i][CS_ETM_ETMCR]; - t_params[i].etmv3.reg_trc_id = - etm->metadata[i][CS_ETM_ETMTRACEIDR]; - } else if (etm->metadata[i][CS_ETM_MAGIC] == - __perf_cs_etmv4_magic) { - t_params[i].protocol = CS_ETM_PROTO_ETMV4i; - t_params[i].etmv4.reg_idr0 = - etm->metadata[i][CS_ETMV4_TRCIDR0]; - t_params[i].etmv4.reg_idr1 = - etm->metadata[i][CS_ETMV4_TRCIDR1]; - t_params[i].etmv4.reg_idr2 = - etm->metadata[i][CS_ETMV4_TRCIDR2]; - t_params[i].etmv4.reg_idr8 = - etm->metadata[i][CS_ETMV4_TRCIDR8]; - t_params[i].etmv4.reg_configr = - etm->metadata[i][CS_ETMV4_TRCCONFIGR]; - t_params[i].etmv4.reg_traceidr = - etm->metadata[i][CS_ETMV4_TRCTRACEIDR]; - } - } + if (cs_etm__init_trace_params(t_params, etm)) + goto out_free; /* Set decoder parameters to simply print the trace packets */ if (cs_etm__init_decoder_params(&d_params, etmq, diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h index d76126e0e3d0..0e97c196147a 100644 --- a/tools/perf/util/cs-etm.h +++ b/tools/perf/util/cs-etm.h @@ -105,8 +105,8 @@ struct intlist *traceid_list; #define CS_ETM_HEADER_SIZE (CS_HEADER_VERSION_0_MAX * sizeof(u64)) -static const u64 __perf_cs_etmv3_magic = 0x3030303030303030ULL; -static const u64 __perf_cs_etmv4_magic = 0x4040404040404040ULL; +#define __perf_cs_etmv3_magic 0x3030303030303030ULL +#define __perf_cs_etmv4_magic 0x4040404040404040ULL #define CS_ETMV3_PRIV_SIZE (CS_ETM_PRIV_MAX * sizeof(u64)) #define CS_ETMV4_PRIV_SIZE (CS_ETMV4_PRIV_MAX * sizeof(u64)) From patchwork Fri Feb 15 00:45:25 2019 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: 158460 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103738jaa; Thu, 14 Feb 2019 16:47:59 -0800 (PST) X-Google-Smtp-Source: AHgI3IbIwbdUrdLz05tEsZqE5xNICZ9cEkS7Tx9ehlMMoWT+o6IUP4EBOTzF2ZxfL2+2SMiM16Bj X-Received: by 2002:a17:902:834b:: with SMTP id z11mr7390692pln.151.1550191679413; Thu, 14 Feb 2019 16:47:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191679; cv=none; d=google.com; s=arc-20160816; b=Yahaj5h1ks+aFwHVJpiTDrJetCMNmwetYgUl0dMz5Fv2t7n39VUYNNQ8djdEZmi0zK 9n8sSAHvmnpZXWQTmoPLaa7H4cvdeZEtCnSHHKSgjHZX+VXZzaedoHo5DXsuu/amuK1/ yAkGe0txgw2xm0jE2Ht4AmansnOZKPZ6kOK/pjRfhOfj3xXE5nuvPZPc4+a2c60nkUH9 +QM/fCYcZKzYcqgCZlOLI+GautNri3vJ+DMZ/75vZ0DubD4tUssosXduD7jEyrAUCTLK 8wGoA69GPRzeR23jCWvg6JWbv+9MPw8RgKnP0cza3aXNJKnqno7fpn+XSpv8E0Vdrsp/ mWNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lJht4p+PfXX6983vavsajvrMtgqctU7/Pul/pwHAuXU=; b=TyGWpuSVRfHaXb+oiVTvFuLyhvB8apVUY1pvJkC8Hm+V96uVH4O6JNMM/f2ZMPDBlV nnbTh2Xyj1pJ5zCxcZvH+zAygn5eYhTds5+MfEktJDuUgOfmyrAieq+JZ+Wx8R/naqfN 4+mms9wYKhfZrrqCS1zyhOP9j5tGqSfuu/P4JMJNtW9Jxsv0KSumofost9KgfjEq16FQ bwKyigRDEF/dRGuiT97DRwuZRT2s4xKr+C+01j9C3ieKMlUo4VSnS8jLxdEtusBS6nke USPX9KOWfk/l61hBntZN03w0v3Ex62MlixSPsqD27mIfFNyCQy3QMT0L90g5unu2FFWU tBqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Cw8O50MJ; 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 j10si3551428pgp.282.2019.02.14.16.47.58; Thu, 14 Feb 2019 16:47:59 -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=@kernel.org header.s=default header.b=Cw8O50MJ; 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 S2389439AbfBOAr5 (ORCPT + 31 others); Thu, 14 Feb 2019 19:47:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:46838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389360AbfBOArz (ORCPT ); Thu, 14 Feb 2019 19:47:55 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 606CC222D9; Fri, 15 Feb 2019 00:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191674; bh=yroGFyXr1DKQoOXBtBFkaB/GilLvU7Nfnt5EmXm6KWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cw8O50MJ7nTEMaq2mfUU8rgq5KbmIxMSFJWLvhiU2F8FjjwLkMH59h5RKWpb8a8Cf C3qPbl6xg6gV6ufLYZ9f0vTXFPwN/cziHy55/X8ikvh92l0NbrzFDv2Qjldj23PBpa ZH6Y5h6wb3fzdJD58bnzos3UUStWVdCq2vVTQAkk= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 29/43] perf cs-etm: Fix erroneous comment Date: Thu, 14 Feb 2019 21:45:25 -0300 Message-Id: <20190215004539.23571-30-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier The comment just before initialising the decoder is plane wrong since it is part of the decoding queue setup function and the operation code specifically mention that trace data is to be decoded rather than printed out. This patch simply fix the comment to prevent people from getting really confused. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-8-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index f3a6dfaf3026..4cc9fce97a86 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -459,7 +459,7 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, if (cs_etm__init_trace_params(t_params, etm)) goto out_free; - /* Set decoder parameters to simply print the trace packets */ + /* Set decoder parameters to decode trace packets */ if (cs_etm__init_decoder_params(&d_params, etmq, CS_ETM_OPERATION_DECODE)) goto out_free; From patchwork Fri Feb 15 00:45:26 2019 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: 158461 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103781jaa; Thu, 14 Feb 2019 16:48:02 -0800 (PST) X-Google-Smtp-Source: AHgI3IbwWHGpGHo3nSn+YCeLgHRyiL+mL/vVBy6b1SgIim9XnTcGtKIlEjfMncwDrNzakr2PJzS7 X-Received: by 2002:a62:c302:: with SMTP id v2mr7027975pfg.155.1550191682845; Thu, 14 Feb 2019 16:48:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191682; cv=none; d=google.com; s=arc-20160816; b=azd1R46zmDQGozhBeMXBNkiWyDiNOP28xIGh7SkRrW6rH8IGz78GElaGrDC2FkBM8X F3BR0OKQYMbby8vziammpDIqgydpI55C5SEsx6Nsh1fZIhBYo3kbz2qKk0kGVmBCJ807 e3NIxpiu7sNcRUN8IUSHF2q/76LYnCpMOS+l4ph4p8BCb/59pNWT92u5ZgBRFMN4n0C3 UnOfyVeaiterIFeJRit58rFlwDstX6g9sYr4hgJBfKjbvNNxIbEbCe48PVkTGy7Uovod 2ndutNDTB8WhZv25hFWL9j+iJDhIrBasAhnNeHa+IfECTFfgFLlq1lZ0+YtNtHyXt0qr +KfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ph6fdiVxcmW8XtXa5whDwKhP3LOHYplxekgagmVEN9k=; b=rB3CUPSBPTYk2hvHr0/w4jTGlv8UrkjJ2rEjP4687tdWQjBSL5Jt6xJxNtbZnQkRFY /cSKeUyNrN3RzaivbkLk9dtn0z1r6fEZgy2YhSAcF7Eg9oHCCBLbOF6FafG4rztD9aNg aPbcQjfOev4npB3TjLFc10rqby6wvcdmicfwkrbXp9y6PoiePta24bueGZ5hhzLxp30m mUNNiZ4ESLW8KqvU0jJmKCltlo7n8I8Sdi3PMFvDsa01on7CIPohNlpStWhA37Fy4xqw lkw1ZgqCxo48fQfkmMcwaJJjIAVQDOwVYPFwHAZ8kO48d4GQsJP66aj9VaU+j7bLsdMB SMxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LCnCLwLi; 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 j10si3551428pgp.282.2019.02.14.16.48.02; Thu, 14 Feb 2019 16:48:02 -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=@kernel.org header.s=default header.b=LCnCLwLi; 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 S2389491AbfBOAsB (ORCPT + 31 others); Thu, 14 Feb 2019 19:48:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:46950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389443AbfBOAsA (ORCPT ); Thu, 14 Feb 2019 19:48:00 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 86E172229F; Fri, 15 Feb 2019 00:47:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191679; bh=T354beYzSKX9jaLyEiLMxRWSCwNVNXXElIwYhxrdRy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LCnCLwLi4KMpA1TxI3aIASI4aE7Q2bPh3PLq1VM5GAH1Hgc0IDrMsE4aVdtVQNQw/ 1gpQBK6ykXxkVzCpuzxxcU3QkEaUrUDxtopneOK4wgEKjXYSueaUpdmV11gggPBYDF BPhkebYjCAiDVJlaIlYzMSCmW3T2ufey5py3gS9c= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 30/43] perf cs-etm: Cleaning up function cs_etm__alloc_queue() Date: Thu, 14 Feb 2019 21:45:26 -0300 Message-Id: <20190215004539.23571-31-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Function cs_etm__alloc_queue() should only be concerned with the allocation of memory for the etmq and accompanying decoder. Everything else should be done in the calling function. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-9-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 4cc9fce97a86..c9a5b4935209 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -405,8 +405,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u64 address, return len; } -static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, - unsigned int queue_nr) +static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm) { struct cs_etm_decoder_params d_params; struct cs_etm_trace_params *t_params = NULL; @@ -444,12 +443,6 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, if (!etmq->event_buf) goto out_free; - etmq->etm = etm; - etmq->queue_nr = queue_nr; - etmq->pid = -1; - etmq->tid = -1; - etmq->cpu = -1; - /* Use metadata to fill in trace parameters for trace decoder */ t_params = zalloc(sizeof(*t_params) * etm->num_cpu); @@ -479,10 +472,6 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, goto out_free_decoder; zfree(&t_params); - - etmq->offset = 0; - etmq->period_instructions = 0; - return etmq; out_free_decoder: @@ -503,24 +492,30 @@ static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm, struct auxtrace_queue *queue, unsigned int queue_nr) { + int ret = 0; struct cs_etm_queue *etmq = queue->priv; if (list_empty(&queue->head) || etmq) - return 0; + goto out; - etmq = cs_etm__alloc_queue(etm, queue_nr); + etmq = cs_etm__alloc_queue(etm); - if (!etmq) - return -ENOMEM; + if (!etmq) { + ret = -ENOMEM; + goto out; + } queue->priv = etmq; - - if (queue->cpu != -1) - etmq->cpu = queue->cpu; - + etmq->etm = etm; + etmq->queue_nr = queue_nr; + etmq->cpu = queue->cpu; etmq->tid = queue->tid; + etmq->pid = -1; + etmq->offset = 0; + etmq->period_instructions = 0; - return 0; +out: + return ret; } static int cs_etm__setup_queues(struct cs_etm_auxtrace *etm) From patchwork Fri Feb 15 00:45:27 2019 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: 158462 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103818jaa; Thu, 14 Feb 2019 16:48:07 -0800 (PST) X-Google-Smtp-Source: AHgI3Iara7m/ZnOvcuw7RkpbAjCLGPw6XM+RaL2gIw8pSF2Vw0cTxfu22EN0nHjWdtYw36TtRuz5 X-Received: by 2002:a63:5b48:: with SMTP id l8mr2681145pgm.80.1550191687834; Thu, 14 Feb 2019 16:48:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191687; cv=none; d=google.com; s=arc-20160816; b=EMj5mRHWGRYlm3wWwIZyd81hEGL544/s+P/IwDPy+T/Eqm0x7ZeRHuHDiUUhhYQj1Z ZAhVfdbwZ6iXLzZ/UxQRO0Rfa9Q8d+CMkEmYx4GKgRQwhcTwj50L749vwdU+aabJwjUk yqip7IabIPHTqvS2PjJKaoVTDON5HMxZ64J2i9SUQ0ycKgAtx1ZXPkLxPT6BqQvXFiNQ w/8pQGd+0UzSv3pj0iH7R7fYL+fXbLHPjeJiKa5wbSPJSf20kXyiz7sQQ5BGb108OkSa yW8YFQHBm0+hOQbAGvC/PeC7gNhdoo8+NJfz/zo+h97IrQ/e/jFAu1ZOHhuC9uKSnf76 R61w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VupPMCwk6g0mFa+c35jQOriHVJpLYYlPbtnZJCWEUzI=; b=z15S4HyLL3REaVVcRQHfyId3Vk2j2hyEXsig2gkdQ6j/XLKXYo9FrNF6qx7/IViy18 cXJ2pXw4s9MSOdFU1m9gPWnkf0Us0AWdPAqz+SzGJpDvIHIm1mtlLu5n93vZxi8JyjpY ASKCx//unZM1ENpGclJdjtiAwp+U5bRrez4Ce2lOuWf4BAn5hAUGPWISEnyIkoDkBvHB tFgZaAcHLfIPir5X8g5Rm8C/Td5AA+olF5wplBAwl9ArOuzPfbwo0ANsWp6xUvjKEdY2 FcTSxth+MIys/2zs4TIv9+icdca75uyymCbz/TU+R9bfHH2MlWmuvV93CYXTR9kDmOXR vcUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="AYL3kK/2"; 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 bb3si1377995plb.160.2019.02.14.16.48.07; Thu, 14 Feb 2019 16:48:07 -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=@kernel.org header.s=default header.b="AYL3kK/2"; 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 S1730344AbfBOAsF (ORCPT + 31 others); Thu, 14 Feb 2019 19:48:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:47078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389493AbfBOAsE (ORCPT ); Thu, 14 Feb 2019 19:48:04 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 62D97222D0; Fri, 15 Feb 2019 00:48:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191684; bh=AKvOAUDF1A6gHIdwLmTBGhV9WD7vf/DuM++OockH3WY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AYL3kK/27dviTrzAVZv0ZSys8F+e8m4Fz6myrjHj7RKCHT7vvsq3ktMpjOKja57KY 6lz+tYBZ0nSssyRFoWX2SWyb3dK8sxLsmh5eYboFZEBS4Xssa4ZGm4z+D/YPR1YQns zizGHQWIoRE1GnXsMWrjv0naKJYmuvWcXXrf+3J8= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 31/43] perf cs-etm: Rethink kernel address initialisation Date: Thu, 14 Feb 2019 21:45:27 -0300 Message-Id: <20190215004539.23571-32-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Moving initialisation of the kernel start address to function cs_etm__setup_queues(), considered to be the common denominator for queue initialisation. That way we don't have to repeat the same code at different places. No change of functionatlity is introduced by this patch. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-10-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index c9a5b4935209..2d2de898ea68 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -523,6 +523,9 @@ static int cs_etm__setup_queues(struct cs_etm_auxtrace *etm) unsigned int i; int ret; + if (!etm->kernel_start) + etm->kernel_start = machine__kernel_start(etm->machine); + for (i = 0; i < etm->queues.nr_queues; i++) { ret = cs_etm__setup_queue(etm, &etm->queues.queue_array[i], i); if (ret) @@ -1490,14 +1493,10 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq) static int cs_etm__run_decoder(struct cs_etm_queue *etmq) { - struct cs_etm_auxtrace *etm = etmq->etm; struct cs_etm_buffer buffer; size_t buffer_used, processed; int err = 0; - if (!etm->kernel_start) - etm->kernel_start = machine__kernel_start(etm->machine); - /* Go through each buffer in the queue and decode them one by one */ while (1) { buffer_used = 0; From patchwork Fri Feb 15 00:45:28 2019 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: 158463 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103890jaa; Thu, 14 Feb 2019 16:48:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IazmY8RfWbGmiKfuwEbf/75wlTEP1wjMfOUhhLSf1a46kUJUFr1M2zKJpTVLGre8uTNVEXY X-Received: by 2002:a63:a:: with SMTP id 10mr2660431pga.121.1550191693943; Thu, 14 Feb 2019 16:48:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191693; cv=none; d=google.com; s=arc-20160816; b=Q4eNl+rMOaNChmfbFhMKkI77SiRd0GFYt6TMWtJwILg95CloDMRGLyILgoAVrjNdmK KUpuObZWIxkMZYd1Yq5wsB5oNy32ytC/qqbReA/Fo7qX4Ok49jR0+vDmST04JTyUEw+r NdsK1TzAgY9dTSaArJpsK60zF1/Bi67Qy8AJQ+rfcZIdW940NHoz44ULImgkJIn7RW4b gFq3H3YahOeWiAn83pgI72XBVyjBReJt2ZGQKEFH/6cR6ekJpEBuo5Ek6eSzz3A8I5zU mOmp3Ox63K+lPon9NIUqGPU6G+pLxXJvP/+9wRHKtl8Np+DjhUNg43sECG6B18onByDR XJDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3IZsWLYud4MckC8EdZZltJlMTz5qg1tQZPFSINBNfpc=; b=MMEt3dhTGI/lAy8cu8z2QMNVDh1Ijbv/HPggsb4Bi/cLqcaVnKb+b2IkKZkSMnXS5l 0A0BrpRdVPFsq/PuHiON+PNA+sIvK7aHAmgMjD6FPUud2DkHXfaPDaXFrsaleTul5MQb CJ68JJsgqTDYiNwSzPH8y1rocLFba2613uGZpIC17kBLEpq88BubHx7AmicRoYDgJKpN gubMdp8cc6BzP4gv6yFVPUU2zhWFbzoSSM3+ndb4tqEyWfngdw+Y3sxGTInNeoZFZRpC vgpIRnfLIudZPgORj3fJaPf51Y0gESv9S5RggdYIseLvh8un6lmkvlPdzAzCra1LjmNN cYAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e72BZIGs; 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 bb3si1377995plb.160.2019.02.14.16.48.13; Thu, 14 Feb 2019 16:48:13 -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=@kernel.org header.s=default header.b=e72BZIGs; 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 S2389570AbfBOAsM (ORCPT + 31 others); Thu, 14 Feb 2019 19:48:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:47188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727591AbfBOAsK (ORCPT ); Thu, 14 Feb 2019 19:48:10 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 BAD992229F; Fri, 15 Feb 2019 00:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191689; bh=affK4b/PCwwi/0OzGgt/0BGbFx9bsHYZODJ1S0APJ6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e72BZIGsRw+tm7wPo8UVjIAc14G4puOItICNlfO+JBrIIKz+VYlvkheEHMLUGIRQJ Q40JPAGZP8psQSMM5BNmOIWAJPv7wH3oh8EFCg8vomKWTeeyWGYSMrRkNCRelGzSXZ yuY0Bv5UaKkDxcFwo/0sj1XQvG8dtGLpWk5d2/YE= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 32/43] perf cs-etm: Make cs_etm__run_decoder() queue independent Date: Thu, 14 Feb 2019 21:45:28 -0300 Message-Id: <20190215004539.23571-33-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier This patch makes decoding of auxtrace buffer centered around a struct cs_etm_queue. This eliminates surperflous variables and is a precursor for work that simplifies the main decoder loop. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-11-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 7 --- tools/perf/util/cs-etm.c | 52 +++++++++---------- 2 files changed, 26 insertions(+), 33 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h index 663309486784..3ab11dfa92ae 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -15,13 +15,6 @@ struct cs_etm_decoder; -struct cs_etm_buffer { - const unsigned char *buf; - size_t len; - u64 offset; - u64 ref_timestamp; -}; - enum cs_etm_sample_type { CS_ETM_EMPTY, CS_ETM_RANGE, diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 2d2de898ea68..d2c90b369e7c 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -76,6 +76,8 @@ struct cs_etm_queue { size_t last_branch_pos; struct cs_etm_packet *prev_packet; struct cs_etm_packet *packet; + const unsigned char *buf; + size_t buf_len, buf_used; }; static int cs_etm__update_queues(struct cs_etm_auxtrace *etm); @@ -683,7 +685,7 @@ static int cs_etm__inject_event(union perf_event *event, static int -cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq) +cs_etm__get_trace(struct cs_etm_queue *etmq) { struct auxtrace_buffer *aux_buffer = etmq->buffer; struct auxtrace_buffer *old_buffer = aux_buffer; @@ -697,7 +699,7 @@ cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq) if (!aux_buffer) { if (old_buffer) auxtrace_buffer__drop_data(old_buffer); - buff->len = 0; + etmq->buf_len = 0; return 0; } @@ -717,13 +719,11 @@ cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq) if (old_buffer) auxtrace_buffer__drop_data(old_buffer); - buff->offset = aux_buffer->offset; - buff->len = aux_buffer->size; - buff->buf = aux_buffer->data; + etmq->buf_used = 0; + etmq->buf_len = aux_buffer->size; + etmq->buf = aux_buffer->data; - buff->ref_timestamp = aux_buffer->reference; - - return buff->len; + return etmq->buf_len; } static void cs_etm__set_pid_tid_cpu(struct cs_etm_auxtrace *etm, @@ -1493,24 +1493,23 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq) static int cs_etm__run_decoder(struct cs_etm_queue *etmq) { - struct cs_etm_buffer buffer; - size_t buffer_used, processed; + size_t processed; int err = 0; /* Go through each buffer in the queue and decode them one by one */ while (1) { - buffer_used = 0; - memset(&buffer, 0, sizeof(buffer)); - err = cs_etm__get_trace(&buffer, etmq); - if (err <= 0) - return err; - /* - * We cannot assume consecutive blocks in the data file are - * contiguous, reset the decoder to force re-sync. - */ - err = cs_etm_decoder__reset(etmq->decoder); - if (err != 0) - return err; + if (!etmq->buf_len) { + err = cs_etm__get_trace(etmq); + if (err <= 0) + return err; + /* + * We cannot assume consecutive blocks in the data file + * are contiguous, reset the decoder to force re-sync. + */ + err = cs_etm_decoder__reset(etmq->decoder); + if (err != 0) + return err; + } /* Run trace decoder until buffer consumed or end of trace */ do { @@ -1518,14 +1517,15 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) err = cs_etm_decoder__process_data_block( etmq->decoder, etmq->offset, - &buffer.buf[buffer_used], - buffer.len - buffer_used, + &etmq->buf[etmq->buf_used], + etmq->buf_len, &processed); if (err) return err; etmq->offset += processed; - buffer_used += processed; + etmq->buf_used += processed; + etmq->buf_len -= processed; /* Process each packet in this chunk */ while (1) { @@ -1585,7 +1585,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) break; } } - } while (buffer.len > buffer_used); + } while (etmq->buf_len); if (err == 0) /* Flush any remaining branch stack entries */ From patchwork Fri Feb 15 00:45:29 2019 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: 158464 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103954jaa; Thu, 14 Feb 2019 16:48:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IbJPQgxznwlMSnGIWV5mYsMYBxSHSDrxVIs4UW0ex+VaDxv8AfJkJ7C+aHMKlePqXvGhs4U X-Received: by 2002:a63:ef50:: with SMTP id c16mr2726723pgk.3.1550191699337; Thu, 14 Feb 2019 16:48:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191699; cv=none; d=google.com; s=arc-20160816; b=NcKMoU4k8E48VBw1D2YSqtBVM3LH9sGsHbgwejuEXrRbnZxj0W6i1gJaJHNJ6kCWjz K0Mvbgxx0X8+A77SMb+jg3c+vdi0+YBv2HiL89lq6jRYjymQdZ2sHzp+bKfVJAdcaTy0 ErQFvZ1bUbDbqT6g76MHbp+IIPDO0nRiHTRBzrfl9L70aBjO3ZhX2TWWRgf26yWSy3NI qSscczM5pKjJ5D4XO8f7FBtqZdZ0JZ9EcJAD6XbD8lDGRrg78dOgxyXqgF2PvP/M1vMY k6od3NY7jXC5eEFnZ4q1z7TOM3au0/yzS7DC137xf/xiFQCJJ7OO5OZ/LQkCHI7Tf2x7 Q+SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oMIYQbUj7JEmltgX8qTX9q61qa3goDQdjeqkAL4du9c=; b=KwnT4v3a7FNi3prXeiV9+7WAlFFpuM1OqymgezyYGeb4UwdXreQ87LFq5PO9BN8iqq 2kL4S3emFxIpAfsb+NSxaiBg7TECAYWJZWJxdCYMMuV2JZ3SsaYFAdxyYLy/YgL90CEm 8r9z7tdKeXesH/njsPGqWCsM3zRXhxxzIkHJoLdlf6bJIGEgSeQiiLO1V3niutgwpNbI ghHP9Rlc+lIzmg3lc9v7L7qIdavx99FSmJBImEu0Sr1HSl7ytZwRLX90tkt8bnDVEa5g anNFnAaQ7H+/NDCkMCsu3br2C51IP99clXfMgzpg2BE15H3YEnlHHxSWqKF6i6i4DffV /Erw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l+kbDdZ8; 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 z8si3595040pgv.204.2019.02.14.16.48.18; Thu, 14 Feb 2019 16:48:19 -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=@kernel.org header.s=default header.b=l+kbDdZ8; 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 S1730539AbfBOAsR (ORCPT + 31 others); Thu, 14 Feb 2019 19:48:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:47294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389370AbfBOAsQ (ORCPT ); Thu, 14 Feb 2019 19:48:16 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 4D470222C9; Fri, 15 Feb 2019 00:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191695; bh=WFKhBGivstHsu/Fs+BfZ/htyrxFjYHkApYCCiKiHFX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l+kbDdZ8vnowMRYyDFsySlyuP4BTytgPEFwEzygpMOMgFhGMg/T2N6+bkwgMuElLg nTrhax+BqDCi5KcMrlQe9+SiTx2PWq0hSNTS0s/h4GiYlVACdFZqqbcSXNINJSUgfF FZGwZDE63wVn13Ka4S8Wrr4et7Kkwn8hbXARcCrg= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 33/43] perf cs-etm: Modularize main decoder function Date: Thu, 14 Feb 2019 21:45:29 -0300 Message-Id: <20190215004539.23571-34-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Making the main decoder block modular so that it can be called from different decoding context (timeless vs. non-timeless), avoiding to repeat code. No change in functionality is introduced by this patch. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-12-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 41 ++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index d2c90b369e7c..cfa686fe223e 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1491,9 +1491,36 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq) return 0; } +static int cs_etm__decode_data_block(struct cs_etm_queue *etmq) +{ + int ret = 0; + size_t processed = 0; + + /* + * Packets are decoded and added to the decoder's packet queue + * until the decoder packet processing callback has requested that + * processing stops or there is nothing left in the buffer. Normal + * operations that stop processing are a timestamp packet or a full + * decoder buffer queue. + */ + ret = cs_etm_decoder__process_data_block(etmq->decoder, + etmq->offset, + &etmq->buf[etmq->buf_used], + etmq->buf_len, + &processed); + if (ret) + goto out; + + etmq->offset += processed; + etmq->buf_used += processed; + etmq->buf_len -= processed; + +out: + return ret; +} + static int cs_etm__run_decoder(struct cs_etm_queue *etmq) { - size_t processed; int err = 0; /* Go through each buffer in the queue and decode them one by one */ @@ -1513,20 +1540,10 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) /* Run trace decoder until buffer consumed or end of trace */ do { - processed = 0; - err = cs_etm_decoder__process_data_block( - etmq->decoder, - etmq->offset, - &etmq->buf[etmq->buf_used], - etmq->buf_len, - &processed); + err = cs_etm__decode_data_block(etmq); if (err) return err; - etmq->offset += processed; - etmq->buf_used += processed; - etmq->buf_len -= processed; - /* Process each packet in this chunk */ while (1) { err = cs_etm_decoder__get_packet(etmq->decoder, From patchwork Fri Feb 15 00:45:30 2019 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: 158465 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp104016jaa; Thu, 14 Feb 2019 16:48:23 -0800 (PST) X-Google-Smtp-Source: AHgI3IZce/8MibGAGGnWVj/8z5VKcKhLTsF9pxForTconUlUgdKerj0PEFZzvWea8btXG7uvP3TF X-Received: by 2002:a17:902:e090:: with SMTP id cb16mr6989285plb.32.1550191703794; Thu, 14 Feb 2019 16:48:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191703; cv=none; d=google.com; s=arc-20160816; b=PSaKMk0kWspa81I/IB7LnEBiBS5aSU7/BRqpLsci2YMhUtCcgOm5h3jHO91ibRBHGR rbHx1Hq4of/yZjhuSLMWwAoNsRcpQ2/5QwQdmkW+4/fuMKMwLZ2mMlsq5DUQdjnpJj06 EO9TH/iKuoIGw0oTSpIEWF0wpKr7ADVooxtF0GRRJI4v8Rsa05Al9nSBn3ioaXcVSvSO WuSgsDjAyQyzcYV8zc9mSR6U0ml3bjWzCGF8BbCXAGr3h7OXi3laUdHbBW8zsUiHmO/q Pdgmgq1oGeP45iGd40WZDOkxTTk7+f8LgJ80o/oE/jNK0VUgmTdbUWO0eO0e6rx/jhEo uIwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mAKqKCdIedvBU5z58Bx1wa3QWnWNhA22kc7xmYj+kzQ=; b=Zkg3HGhobeI4Ckb0nZetVBEB1lWgNn81EA2tKiMsw8c0ncF1iOLYvoifBpKho1EOUM bxJ9le26AhCPfffpgdgBYVrrXbEv3JJmEzqA/S5YfUhpxvEZBRoiGv0w8d1JvCd8K/JB MAj8PV6qIvTnlqqTW4OTH7UwFKdJEhzOfx6t7TmMhO+h7C9pPb/zy524LDInEtJxSqtq 2Ey0gMsbfnnhpF/TsHTthjg7RX5HYDHLfyUW4Ii7v7eyuw+MpI7wqAHV9vXR1NFELdEP X5StytGw9o3sEUnU2qQy06RsJwhvIB7PNNub/vYLPs6gAgUsUYETJHq5W/f75B1MJwSj LZGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FDWsvz9f; 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 z8si3595040pgv.204.2019.02.14.16.48.23; Thu, 14 Feb 2019 16:48:23 -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=@kernel.org header.s=default header.b=FDWsvz9f; 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 S2389607AbfBOAsW (ORCPT + 31 others); Thu, 14 Feb 2019 19:48:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:47406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730541AbfBOAsU (ORCPT ); Thu, 14 Feb 2019 19:48:20 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 3BEDC21B68; Fri, 15 Feb 2019 00:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191699; bh=uluH9qSfxO6EQEq/VO78WgaeQTFAb4ZY5Ks+LwjnaMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FDWsvz9feKOzTn+FMPbyrODlbK8NOBPudaX396ldiJbDkBmE5QBGdHb4joUgl6YV7 1U6Ayk2cglka4/1CMgFR9I0m723lXzR5TQYEvxJrXWYsYPyrMhJE2vtHdvOuhRj+dr pmRMnWXYiTA0Lz4gmjs70maH0eC7NofU319p+t3I= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 34/43] perf cs-etm: Modularize main packet processing loop Date: Thu, 14 Feb 2019 21:45:30 -0300 Message-Id: <20190215004539.23571-35-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Making the main packet processing loop modular so that it can be called from different decoding context (timeless vs. non-timless), avoiding to repeat code. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-13-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 129 ++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 57 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index cfa686fe223e..f607bc58bd03 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1519,6 +1519,72 @@ static int cs_etm__decode_data_block(struct cs_etm_queue *etmq) return ret; } +static int cs_etm__process_decoder_queue(struct cs_etm_queue *etmq) +{ + int ret; + + /* Process each packet in this chunk */ + while (1) { + ret = cs_etm_decoder__get_packet(etmq->decoder, + etmq->packet); + if (ret <= 0) + /* + * Stop processing this chunk on + * end of data or error + */ + break; + + /* + * Since packet addresses are swapped in packet + * handling within below switch() statements, + * thus setting sample flags must be called + * prior to switch() statement to use address + * information before packets swapping. + */ + ret = cs_etm__set_sample_flags(etmq); + if (ret < 0) + break; + + switch (etmq->packet->sample_type) { + case CS_ETM_RANGE: + /* + * If the packet contains an instruction + * range, generate instruction sequence + * events. + */ + cs_etm__sample(etmq); + break; + case CS_ETM_EXCEPTION: + case CS_ETM_EXCEPTION_RET: + /* + * If the exception packet is coming, + * make sure the previous instruction + * range packet to be handled properly. + */ + cs_etm__exception(etmq); + break; + case CS_ETM_DISCONTINUITY: + /* + * Discontinuity in trace, flush + * previous branch stack + */ + cs_etm__flush(etmq); + break; + case CS_ETM_EMPTY: + /* + * Should not receive empty packet, + * report error. + */ + pr_err("CS ETM Trace: empty packet\n"); + return -EINVAL; + default: + break; + } + } + + return ret; +} + static int cs_etm__run_decoder(struct cs_etm_queue *etmq) { int err = 0; @@ -1544,64 +1610,13 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) if (err) return err; - /* Process each packet in this chunk */ - while (1) { - err = cs_etm_decoder__get_packet(etmq->decoder, - etmq->packet); - if (err <= 0) - /* - * Stop processing this chunk on - * end of data or error - */ - break; + /* + * Process each packet in this chunk, nothing to do if + * an error occurs other than hoping the next one will + * be better. + */ + err = cs_etm__process_decoder_queue(etmq); - /* - * Since packet addresses are swapped in packet - * handling within below switch() statements, - * thus setting sample flags must be called - * prior to switch() statement to use address - * information before packets swapping. - */ - err = cs_etm__set_sample_flags(etmq); - if (err < 0) - break; - - switch (etmq->packet->sample_type) { - case CS_ETM_RANGE: - /* - * If the packet contains an instruction - * range, generate instruction sequence - * events. - */ - cs_etm__sample(etmq); - break; - case CS_ETM_EXCEPTION: - case CS_ETM_EXCEPTION_RET: - /* - * If the exception packet is coming, - * make sure the previous instruction - * range packet to be handled properly. - */ - cs_etm__exception(etmq); - break; - case CS_ETM_DISCONTINUITY: - /* - * Discontinuity in trace, flush - * previous branch stack - */ - cs_etm__flush(etmq); - break; - case CS_ETM_EMPTY: - /* - * Should not receive empty packet, - * report error. - */ - pr_err("CS ETM Trace: empty packet\n"); - return -EINVAL; - default: - break; - } - } } while (etmq->buf_len); if (err == 0) From patchwork Fri Feb 15 00:45:31 2019 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: 158466 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp104080jaa; Thu, 14 Feb 2019 16:48:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IZCxiaKCTiPFLxnOegUB2JP7ckyES8QG9aKrnd9SsofPsQ1bsWwe4eeiMWPZ2tbNS22V2SH X-Received: by 2002:aa7:8d57:: with SMTP id s23mr6932565pfe.237.1550191710250; Thu, 14 Feb 2019 16:48:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191710; cv=none; d=google.com; s=arc-20160816; b=ZunD9XMHU3SCMx0EKO9xPthQy1r4IvAucW8YxQieDGdBG//jNxsq3RNwL4pVJZybha 02kAfKtAroG6jYr24w/stIXVwCH+Owzo0ytPi6mQz/e1V4S5ytzZPvdLn87flZcZH/pS n5AamzgHP5F9V3/q2U0e6U+hxD2gyVy1/yaNa6M8pPKmESNuXvQho+cGNWYiJjHgTdWl 564SNJbbgI4nn0hxSU9MnLezyyg3TSdaac+mE+lBnpVLNZGV4zhyz85PVL0wcC5KHA4n zdD/Daj9ijpEs1aGhTXpTA93SGSrlS8GptAB+lYoamqqljMD6EGZb0j7ASX9vSye5ug/ Cxiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HEOd/lgCZc4aTLaEIsiGWhLEAKp6aoFTst/DvChQZnE=; b=AxLQdwhPPaEw0brM4SIzIRhEMYi4XJWizfTnuw1PWIF9Nl6uRab3SsJ3v5t0xuMcM8 ThJCSvFA5G0aS/D8EXgS+d9i1HTtIZ9UVmLqmWOBdTflF7ryq9+vAYLSvUyOGantG+ju eE+LA6vZR/69a9kHfZdr2crZ0ga6KAdkZUbNx4hMEEwSHOJH0OLn2TeLBNWT5VBqBkr4 ndMMYN5bI2E5YncTt9KbTFD7NVLCiSl3qDmV5jE2hBCL0tTxfU/XDj5vM0Pq91NJDpEb vrOEESQj3uAC+ncbeCamuuVCIGatZTMIgwCg8JaOGcfuqAhtPZq2x4vNDk1wVEP30C6D ftmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xwhLmUcp; 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 o3si3784644pls.265.2019.02.14.16.48.29; Thu, 14 Feb 2019 16:48:30 -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=@kernel.org header.s=default header.b=xwhLmUcp; 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 S2389667AbfBOAs1 (ORCPT + 31 others); Thu, 14 Feb 2019 19:48:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:47516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389617AbfBOAsY (ORCPT ); Thu, 14 Feb 2019 19:48:24 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (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 8511A222A1; Fri, 15 Feb 2019 00:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191704; bh=6LdzrCVx8YqnpmPcRdemWeu0Aj6Lfc4MEov3VXtbxS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xwhLmUcpYFD23RrowCfeVr66BAmigTql/10xm+6AD7Rlx3E6d1mVK/YeawQok3boj t273uf9QOKK/WSVN8POqfY3zGjBbZ0V4LzsK7GOnzQ6FfaywWj5XeKYvEjNpKY+d3l tV7FUVmi7LbcxGHNtYUSzIfSrXcwxe6ICFJQioFI= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 35/43] perf cs-etm: Modularize auxtrace_buffer fetch function Date: Thu, 14 Feb 2019 21:45:31 -0300 Message-Id: <20190215004539.23571-36-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Making the auxtrace_buffer fetch function modular so that it can be called from different decoding context (timeless vs. non-timeless), avoiding to repeat code. No change in functionality is introduced by this patch. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-14-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 41 ++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index f607bc58bd03..110804936fc3 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1152,6 +1152,32 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq) return 0; } +/* + * cs_etm__get_data_block: Fetch a block from the auxtrace_buffer queue + * if need be. + * Returns: < 0 if error + * = 0 if no more auxtrace_buffer to read + * > 0 if the current buffer isn't empty yet + */ +static int cs_etm__get_data_block(struct cs_etm_queue *etmq) +{ + int ret; + + if (!etmq->buf_len) { + ret = cs_etm__get_trace(etmq); + if (ret <= 0) + return ret; + /* + * We cannot assume consecutive blocks in the data file + * are contiguous, reset the decoder to force re-sync. + */ + ret = cs_etm_decoder__reset(etmq->decoder); + if (ret) + return ret; + } + + return etmq->buf_len; +} static bool cs_etm__is_svc_instr(struct cs_etm_queue *etmq, struct cs_etm_packet *packet, @@ -1591,18 +1617,9 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) /* Go through each buffer in the queue and decode them one by one */ while (1) { - if (!etmq->buf_len) { - err = cs_etm__get_trace(etmq); - if (err <= 0) - return err; - /* - * We cannot assume consecutive blocks in the data file - * are contiguous, reset the decoder to force re-sync. - */ - err = cs_etm_decoder__reset(etmq->decoder); - if (err != 0) - return err; - } + err = cs_etm__get_data_block(etmq); + if (err <= 0) + return err; /* Run trace decoder until buffer consumed or end of trace */ do {