From patchwork Fri Dec 11 14:22:31 2015 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: 58279 Delivered-To: patch@linaro.org Received: by 10.112.157.166 with SMTP id wn6csp168131lbb; Fri, 11 Dec 2015 06:23:46 -0800 (PST) X-Received: by 10.67.22.137 with SMTP id hs9mr25366838pad.66.1449843826783; Fri, 11 Dec 2015 06:23:46 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x22si1539670pfi.55.2015.12.11.06.23.46; Fri, 11 Dec 2015 06:23:46 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754655AbbLKOXn (ORCPT + 28 others); Fri, 11 Dec 2015 09:23:43 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:51316 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754357AbbLKOXS (ORCPT ); Fri, 11 Dec 2015 09:23:18 -0500 Received: from [187.65.86.84] (helo=zoo.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1a7ObH-0003QQ-W5; Fri, 11 Dec 2015 14:23:12 +0000 Received: by zoo.infradead.org (Postfix, from userid 1000) id 3D0BC22097A; Fri, 11 Dec 2015 11:23:04 -0300 (BRT) From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Wang Nan , Adrian Hunter , "David S. Miller" , Jiri Olsa , Namhyung Kim , Zefan Li , pi3orama@163.com, Arnaldo Carvalho de Melo Subject: [PATCH 8/9] perf script: Add support for PERF_TYPE_BREAKPOINT Date: Fri, 11 Dec 2015 11:22:31 -0300 Message-Id: <1449843752-28395-9-git-send-email-acme@kernel.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1449843752-28395-1-git-send-email-acme@kernel.org> References: <1449843752-28395-1-git-send-email-acme@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wang Nan Useful for getting stack traces for hardware breakpoint events. Test result: Before this patch: # ~/perf record -g -e mem:0x600980 ./sample [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.011 MB perf.data (12 samples) ] # ~/perf script # ~/perf script -F comm,tid,pid,time,event,ip,sym,dso sample 22520/22520 97457.836294: mem:0x600980: 5a4ad8 __clear_user (/lib/modules/4.3.0-rc4+/build/vmlinux) ... 3f41ba sys_execve (/lib/modules/4.3.0-rc4+/build/vmlinux) 979395 return_from_execve (/lib/modules/4.3.0-rc4+/build/vmlinux) 7f1b59719cf7 [unknown] ([unknown]) sample 22520/22520 97457.836648: mem:0x600980: 532 main (/home/w00229757/DataBreakpoints/sample) 21bd5 __libc_start_main (/tmp/oxygen_root-root/lib64/libc-2.18.so) ... After this patch: # ~/perf script sample 22520 97457.836294: mem:0x600980: 5a4ad8 __clear_user (/lib/modules/4.3.0-rc4+/build/vmlinux) ... 3f41ba sys_execve (/lib/modules/4.3.0-rc4+/build/vmlinux) 979395 return_from_execve (/lib/modules/4.3.0-rc4+/build/vmlinux) 7f1b59719cf7 [unknown] ([unknown]) sample 22520 97457.836648: mem:0x600980: 532 main (/home/w00229757/DataBreakpoints/sample) 21bd5 __libc_start_main (/tmp/oxygen_root-root/lib64/libc-2.18.so) Committer note: So, further testing, lets do it for a kernel global variable, tcp_hashinfo: # grep -w tcp_hashinfo /proc/kallsyms ffffffff8202fc00 B tcp_hashinfo # Note: allow specifying mem:tcp_hashinfo: # perf record -g -e mem:0xffffffff81c65ac0 -a ^C[ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.790 MB perf.data ] # # perf evlist mem:0xffffffff8202fc00 # perf evlist -v mem:0xffffffff8202fc00: type: 5, size: 112, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CALLCHAIN|CPU, disabled: 1, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, bp_type: 3, { bp_addr, config1 }: 0xffffffff8202fc00, { bp_len, config2 }: 0x4 # Then, after this patch: # perf script swapper 0 [000] 171036.986988: mem:0xffffffff8202fc00: 8a0fb5 __inet_lookup_established (/lib/modules/4.3.0+/build/vmlinux) 8bc09d tcp_v4_early_demux (/lib/modules/4.3.0+/build/vmlinux) 896def ip_rcv_finish (/lib/modules/4.3.0+/build/vmlinux) 8976c2 ip_rcv (/lib/modules/4.3.0+/build/vmlinux) 855eba __netif_receive_skb_core (/lib/modules/4.3.0+/build/vmlinux) 8565d8 __netif_receive_skb (/lib/modules/4.3.0+/build/vmlinux) 8572a8 process_backlog (/lib/modules/4.3.0+/build/vmlinux) 856b11 net_rx_action (/lib/modules/4.3.0+/build/vmlinux) 2a284b __do_softirq (/lib/modules/4.3.0+/build/vmlinux) 2a2ba3 irq_exit (/lib/modules/4.3.0+/build/vmlinux) 96b7a4 do_IRQ (/lib/modules/4.3.0+/build/vmlinux) 969807 ret_from_intr (/lib/modules/4.3.0+/build/vmlinux) 804c27 cpuidle_enter (/lib/modules/4.3.0+/build/vmlinux) 2ded22 call_cpuidle (/lib/modules/4.3.0+/build/vmlinux) 2defb6 cpu_startup_entry (/lib/modules/4.3.0+/build/vmlinux) 95d5bc rest_init (/lib/modules/4.3.0+/build/vmlinux) 1163ffa start_kernel ([kernel.vmlinux].init.text) 11634d7 x86_64_start_reservations ([kernel.vmlinux].init.text) 1163623 x86_64_start_kernel ([kernel.vmlinux].init.text) Signed-off-by: Wang Nan Tested-by: Arnaldo Carvalho de Melo Cc: Adrian Hunter Cc: David S. Miller Cc: Jiri Olsa Cc: Namhyung Kim Cc: Zefan Li Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1449541544-67621-16-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-script.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 3c3f8d0e3064..d259e9aa3a71 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -130,6 +130,18 @@ static struct { .invalid_fields = PERF_OUTPUT_TRACE, }, + + [PERF_TYPE_BREAKPOINT] = { + .user_set = false, + + .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID | + PERF_OUTPUT_CPU | PERF_OUTPUT_TIME | + PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP | + PERF_OUTPUT_SYM | PERF_OUTPUT_DSO | + PERF_OUTPUT_PERIOD, + + .invalid_fields = PERF_OUTPUT_TRACE, + }, }; static bool output_set_by_user(void) @@ -1129,6 +1141,8 @@ static int parse_output_fields(const struct option *opt __maybe_unused, type = PERF_TYPE_TRACEPOINT; else if (!strcmp(str, "raw")) type = PERF_TYPE_RAW; + else if (!strcmp(str, "break")) + type = PERF_TYPE_BREAKPOINT; else { fprintf(stderr, "Invalid event type in field string.\n"); rc = -EINVAL;