Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4602749imu; Tue, 29 Jan 2019 04:31:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN7229LQHnwyQs/f7uV/eM3eZcA7aPkRX57QkeGxvIIRIx9rLscafANNV7khNuQYJLThG4iP X-Received: by 2002:a63:4a0a:: with SMTP id x10mr23472603pga.237.1548765095025; Tue, 29 Jan 2019 04:31:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548765094; cv=none; d=google.com; s=arc-20160816; b=E2EuCYWA34Yzjem0qg8lOpv+HFpp0uyyEdjp52gnaKqMXGFXiGpW3Mfi+hArX51Mur 30W8xEqACmgHqxS4LGEOSCz8tErdZSs1Yxik3ypDh6gIeY5T7e2f0I45au/4ijh43MQ+ sWWF65rt2EpEnrNZaua1cqypkT83FucCkZigfSaVlLSGCZQhdnR3kExs0FZYHq9Vj3E4 BbioYUro1azfjIizw/R02QeHR/LLpIy9xoKZcnPs12LXHyFMFZwHxseJ9fyLDhwqDW5U FxuOya8ZdHB71ErMcra4pZlDHITixXwLzJlU0MSQ5Xv6etudd78pvymH/Zh7jmirz/mC 45MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=fI4dv7garnzy2W+m3mE1OJK4oTIdQwDug0wFO9zg2Vo=; b=iImh8XOAR7evdhQLRykAZfjcmRPMrwHAsOfeKv7ulojmY2hLTgg6qJc8KZKtOWSsU5 M4OazjmlGk61NkISnokDTjIwMfnk240yJFVp6V3bzy4ei7HSeS6K4D5n2MzGzC5N57iF AIefTPTR0PJQ0rqBuIZ3ZnzHg7jiK5WNpXDRPgvoploFFtqg/jQ4yquCBtVVtsxtkbk2 gWgoK/KfQ8egt+nF8AdkengJJ6yPM2t5WJi7NaU+eVNQctftuzv5OxbB+JwkTIdQm5dv BwUAA+sQoNzOeEIKNKKMY2EFp/xkFkvSduL8Te+M0uFsCIltObzq+FZ/dXW6xJ1Q0UHk BI6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hu9sy8Ql; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si35219006pgq.139.2019.01.29.04.31.12; Tue, 29 Jan 2019 04:31:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hu9sy8Ql; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727996AbfA2M3t (ORCPT + 99 others); Tue, 29 Jan 2019 07:29:49 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40565 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725772AbfA2M3t (ORCPT ); Tue, 29 Jan 2019 07:29:49 -0500 Received: by mail-pl1-f195.google.com with SMTP id u18so9276559plq.7 for ; Tue, 29 Jan 2019 04:29:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=fI4dv7garnzy2W+m3mE1OJK4oTIdQwDug0wFO9zg2Vo=; b=hu9sy8QlavPoSx0f2aSnK3yC82eHibeUy45I8SrzNFHY3bUa31DXJPZEQCIiWTnJnt lytDw26Mg64tahth+FZGj47OVk8Wpl7JbdfspWAn4QRsgGjbDe9k4D2p9YUYkJv7a9lS eaBe7U74u0OOmH75rWDk0H3D3b7wAW9obTC3c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fI4dv7garnzy2W+m3mE1OJK4oTIdQwDug0wFO9zg2Vo=; b=XhXF+E62FFswi3R6uQQOOr8hSBHOjleHLjb6mOTcPyhJzAMwzC+3fZtJACq02JlDMr 0fY13oCQLxOp2UlVMCuEqgJ8ubpE8HR7ukujPH2tk4ijlsuVskwoQtWCo9ZisThf2ZR/ dYipdWRLGk09q97qRLZJFE4Awyje5CNtiuQUkoxr6WhskwlrNDy9OvCOpPyGjuE0kyBC zGP85Hvp0uTdRrCdE/I4S4/sYXxuaJnHxynuIOhG6PBNraYWcN21M1la3S6YvPbkyCs+ MDqojYXh0xQ6oWrruekvFY7zqnmLk7bQrASYJdwsfAJVQy8DgiuDfCKe8st0Vwqb2jCG b/aw== X-Gm-Message-State: AJcUukdOML1GnaTgDUvWgf5HH+C+x3k3seXE/ipOy9TQT7n2G8OoMMKz 9xOGcy72KXTXwgdWsAzUX3Jmbw== X-Received: by 2002:a17:902:b943:: with SMTP id h3mr26151550pls.12.1548764987824; Tue, 29 Jan 2019 04:29:47 -0800 (PST) Received: from localhost.localdomain (li569-141.members.linode.com. [192.155.82.141]) by smtp.gmail.com with ESMTPSA id h64sm59552502pfc.142.2019.01.29.04.29.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 04:29:46 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mike Leach , Robert Walker , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Coresight ML Cc: Leo Yan Subject: [PATCH v7 0/8] perf cs-etm: Add support for sample flags Date: Tue, 29 Jan 2019 20:28:34 +0800 Message-Id: <20190129122842.32041-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch seris adds support for sample flags so can facilitate perf to print sample flags for branch instruction. Patch 0001 is used to save last branch information in packet structure, this includes instruction type, subtype and condition flag to help making decision for which branch instruction it is. It passes related information from decoder layer to cs-etm.c, so we use cs-etm.c as a central place to set sample flags. Patch 0002 is used to set sample flags for instruction range packet. Patch 0003 is used to set sample flags for trace discontinuity packet. Patches 0004/0005/0006 are preparation for exception packet handling: Patch 0004 addes exception number in packet; pacth 0005/0006 is to use traceID/metadata tuple to access metadata pointer based on traceID, this can help decide if the CPU is connected with ETMv3 or ETMv4, ETMv3 and ETMv4 have totally different definition for exception numbers. Patch 0007 sets sample flags for exception packet; patch 0008 support sample flags for exception return packet. This patch set is applied on the acme's perf core branch with the latest commit bdec77cfe58d ("Merge remote-tracking branch 'tip/perf/urgent' into perf/core"). This patch set has been verified for x86 and arm64 perf building and also is verified with below command: Before: # perf script -F,-time,+flags -k vmlinux [...] main 6650 [001] 1 branches: f7b08490 lib_loop_test+0xc (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: f7b084a2 lib_loop_test+0x1e (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: f7b084a2 lib_loop_test+0x1e (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: f7b084a2 lib_loop_test+0x1e (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: f7b084a2 lib_loop_test+0x1e (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: f7b084a2 lib_loop_test+0x1e (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: f7b084b0 lib_loop_test+0x2c (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: 6b65a8 main+0x1c (/root/coresight_test/main) main 6650 [001] 1 branches: 6b6448 printf@plt+0x8 (/root/coresight_test/main) main 6650 [001] 1 branches: 6b642c _init+0x18 (/root/coresight_test/main) main 6650 [001] 1 branches: f7b2d23c [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: f7b2906e [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: f7b2559a [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: f7b2559a [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: f7b2559a [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: f7b2559a [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: f7b2559a [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: f7b255ee [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: f7b25634 [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) [...] After: # perf script -F,-time,+flags -k vmlinux [...] main 6650 [001] 1 branches: jmp f7b08490 lib_loop_test+0xc (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: jcc f7b084a2 lib_loop_test+0x1e (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: jcc f7b084a2 lib_loop_test+0x1e (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: jcc f7b084a2 lib_loop_test+0x1e (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: jcc f7b084a2 lib_loop_test+0x1e (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: jcc f7b084a2 lib_loop_test+0x1e (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: return f7b084b0 lib_loop_test+0x2c (/root/coresight_test/libcstest.so) main 6650 [001] 1 branches: call 6b65a8 main+0x1c (/root/coresight_test/main) main 6650 [001] 1 branches: return 6b6448 printf@plt+0x8 (/root/coresight_test/main) main 6650 [001] 1 branches: return 6b642c _init+0x18 (/root/coresight_test/main) main 6650 [001] 1 branches: call f7b2d23c [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: call f7b2906e [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: jcc f7b2559a [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: jcc f7b2559a [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: jcc f7b2559a [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: jcc f7b2559a [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: jcc f7b2559a [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: jmp f7b255ee [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) main 6650 [001] 1 branches: call f7b25634 [unknown] (/usr/lib/arm-linux-gnueabihf/ld-2.27.so) [...] Changes from v6: * Addressed Mathieu's suggestion for patch 0005, refined its commit log and comment and fixed cs_etm__get_cpu() definitions in header file; also tested with perf for Arm and x86 buildings. * Added Mathieu's review tags. Changes from v5: * Addressed Rob's suggestion to add specification info for exception number encoding; * Added Rob's review tag in patch 0007. Changes from v4: * Fixed typos in comments, and removed redundant info from commit log; * Addressed Mathieu's suggestion to add helper functions for metadata fields (CS_ETM_CPU and CS_ETM_MAGIC) accessing; * Addressed Mathieu's suggestion to include headers with alphabetical order. Changes from v3: * Fixed typos in commit logs; * Rearranged fields in cs_etm_packet by grouping with same variable types; * Fixed ETMv4 exception number which pointed by Mike; * Fixed ETMv4 SVC / SMC / HVC in the same CALL, by checking svc instruction to distinguish them; * Refine ETMv4 return exception packet handling. Changes from v2: * Addressed Mathieu's suggestion to split one big patch to 3 small patches for setting sample flags, one is for instruction range packet, one is for discontinuity packet and one is for exception packet. * Added supporting for ETMv3 exception packet. * Followed Mathieu's suggestion to move all sample flags handling from decoder layer to cs-etm.c, thus it has enough info to set flags based on trace context in single place. Changes from v1: * Moved exception packets handling patches into patch series 'perf cs-etm: Correct packets handling'. * Added sample flags fixing up for TRACE_OFF packet. * Created a new function which is used to maintain flags fixing up. Leo Yan (8): perf cs-etm: Add last instruction information in packet perf cs-etm: Set sample flags for instruction range packet perf cs-etm: Set sample flags for trace discontinuity perf cs-etm: Add exception number in exception packet perf cs-etm: Change tuple from traceID-CPU# to traceID-metadata perf cs-etm: Add traceID in packet perf cs-etm: Set sample flags for exception packet perf cs-etm: Set sample flags for exception return packet .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 41 +- .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 6 + tools/perf/util/cs-etm.c | 394 +++++++++++++++++- tools/perf/util/cs-etm.h | 53 ++- 4 files changed, 476 insertions(+), 18 deletions(-) -- 2.17.1