Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3322293yba; Tue, 16 Apr 2019 09:02:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqySNuMTZv8mMtRul/H+QbHGnCqPY7h6a4k9WjghB+3c7TEklOIQIUOIldtkNtsWQ21q1/Xy X-Received: by 2002:a17:902:b48c:: with SMTP id y12mr80950462plr.280.1555430565092; Tue, 16 Apr 2019 09:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555430565; cv=none; d=google.com; s=arc-20160816; b=ypif0naLDD6DM0EhpYmiNNPLX/9iG+HoOyMI+d9UYF1YyksVSB0Yzv00GVfUtwNqfd 7PosA5XAkpkpYzShScrhXAiOD9rWxXrJfPCRnLqP/7tlUl8D3IyhOe/HXyUV2v81JRnF QCL6NnC+xsr4RRjbT6xp3pQW+k7DxNvFmp7IphFAut91+baJSESG3idcbZub6pUGcBcd RN8zHGlcn3NmFQ1dJrzdwX+PoyLqvabXS1lUx3X3Y1aHH/PvoXdwb/mUmeK6RVa8s4k7 99XYDztlSAaWc2fH3OShmLNUe5XhlE15LA7zSpSMwKP/zPQNrs7MzR8N4RBdfq3hiVQA IwKg== 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; bh=IzIV/pbN2pWUT91ezDP0vSKqpTRHTY5g/pcTJ9B6cQI=; b=wPKiXsAWD4hWz9wdDVlkm1FEDvEoQ02dQICoyqaRxDZzR+21iMK/bnbB2peuDe+3T3 mZVWrOcLasqptKV7w18awwBVx+i7fa2C1kdczPA+i4C7c0qRd6v2kMJ+PetvhUCN38jM dmQZaBmFZi5TDB3HlfOKT/IqvQFaXPk6b4KDKVCDrEEhLi5GV+NMQgLBpL7ou/q6yUEA SyiPCKVHQPRnazYgAC9bix/lDfksZssv1MqN9eFhNz4Xp4+8fojK55gspeiOj0h8HOTJ 6i0HFVterM1OCWWE1fI0xjH1g1Atizpd47yJDT1LvNQ7ekLn4ap1Ym3tx1UquT0bw9r1 ubVg== ARC-Authentication-Results: i=1; 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; dmarc=fail (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 o4si45302829pgp.160.2019.04.16.09.02.27; Tue, 16 Apr 2019 09:02:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729830AbfDPQBh (ORCPT + 99 others); Tue, 16 Apr 2019 12:01:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38280 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728712AbfDPQBh (ORCPT ); Tue, 16 Apr 2019 12:01:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AEE80308795D; Tue, 16 Apr 2019 16:01:36 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1ED965D71B; Tue, 16 Apr 2019 16:01:27 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Jesper Dangaard Brouer , Alexei Starovoitov , Daniel Borkmann , Stanislav Fomichev , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Andi Kleen , Adrian Hunter , Song Liu Subject: [PATCH 00/12] perf tools: Display eBPF code in intel_pt trace Date: Tue, 16 Apr 2019 18:01:15 +0200 Message-Id: <20190416160127.30203-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 16 Apr 2019 16:01:37 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi, this patchset adds dso support to read and display bpf code in intel_pt trace output. I had to change some of the kernel maps processing code, so hopefully I did not break too many things ;-) It's now possible to see bpf code flow via: # perf-with-kcore record pt -e intel_pt//ku -- sleep 1 # perf-with-kcore script pt --insn-trace --xed ... sleep 36660 [016] 1057036.806464404: ffffffff811dfba5 trace_call_bpf+0x65 ([kernel.kallsyms]) nopl %eax, (%rax,%rax,1) sleep 36660 [016] 1057036.806464404: ffffffff811dfbaa trace_call_bpf+0x6a ([kernel.kallsyms]) movq 0x30(%rbx), %rax sleep 36660 [016] 1057036.806464404: ffffffff811dfbae trace_call_bpf+0x6e ([kernel.kallsyms]) leaq 0x38(%rbx), %rsi sleep 36660 [016] 1057036.806464404: ffffffff811dfbb2 trace_call_bpf+0x72 ([kernel.kallsyms]) mov %r13, %rdi sleep 36660 [016] 1057036.806464404: ffffffff811dfbb5 trace_call_bpf+0x75 ([kernel.kallsyms]) callq 0xffffffff81c00c30 sleep 36660 [016] 1057036.806464404: ffffffff81c00c30 __x86_indirect_thunk_rax+0x0 ([kernel.kallsyms]) callq 0xffffffff81c00c3c sleep 36660 [016] 1057036.806464404: ffffffff81c00c3c __x86_indirect_thunk_rax+0xc ([kernel.kallsyms]) movq %rax, (%rsp) sleep 36660 [016] 1057036.806464404: ffffffff81c00c40 __x86_indirect_thunk_rax+0x10 ([kernel.kallsyms]) retq sleep 36660 [016] 1057036.806464725: ffffffffa05e89ef bpf_prog_da4fe6b3d2c29b25_trace_return+0x0 (bpf_prog_da4fe6b3d2c29b25_trace_return) pushq %rbp sleep 36660 [016] 1057036.806464725: ffffffffa05e89f0 bpf_prog_da4fe6b3d2c29b25_trace_return+0x1 (bpf_prog_da4fe6b3d2c29b25_trace_return) mov %rsp, %rbp sleep 36660 [016] 1057036.806464725: ffffffffa05e89f3 bpf_prog_da4fe6b3d2c29b25_trace_return+0x4 (bpf_prog_da4fe6b3d2c29b25_trace_return) sub $0x158, %rsp sleep 36660 [016] 1057036.806464725: ffffffffa05e89fa bpf_prog_da4fe6b3d2c29b25_trace_return+0xb (bpf_prog_da4fe6b3d2c29b25_trace_return) sub $0x28, %rbp sleep 36660 [016] 1057036.806464725: ffffffffa05e89fe bpf_prog_da4fe6b3d2c29b25_trace_return+0xf (bpf_prog_da4fe6b3d2c29b25_trace_return) movq %rbx, (%rbp) sleep 36660 [016] 1057036.806464725: ffffffffa05e8a02 bpf_prog_da4fe6b3d2c29b25_trace_return+0x13 (bpf_prog_da4fe6b3d2c29b25_trace_return) movq %r13, 0x8(%rbp) sleep 36660 [016] 1057036.806464725: ffffffffa05e8a06 bpf_prog_da4fe6b3d2c29b25_trace_return+0x17 (bpf_prog_da4fe6b3d2c29b25_trace_return) movq %r14, 0x10(%rbp) sleep 36660 [016] 1057036.806464725: ffffffffa05e8a0a bpf_prog_da4fe6b3d2c29b25_trace_return+0x1b (bpf_prog_da4fe6b3d2c29b25_trace_return) movq %r15, 0x18(%rbp) sleep 36660 [016] 1057036.806464725: ffffffffa05e8a0e bpf_prog_da4fe6b3d2c29b25_trace_return+0x1f (bpf_prog_da4fe6b3d2c29b25_trace_return) xor %eax, %eax sleep 36660 [016] 1057036.806464725: ffffffffa05e8a10 bpf_prog_da4fe6b3d2c29b25_trace_return+0x21 (bpf_prog_da4fe6b3d2c29b25_trace_return) movq %rax, 0x20(%rbp) sleep 36660 [016] 1057036.806464725: ffffffffa05e8a14 bpf_prog_da4fe6b3d2c29b25_trace_return+0x25 (bpf_prog_da4fe6b3d2c29b25_trace_return) mov %rdi, %rbx sleep 36660 [016] 1057036.806464725: ffffffffa05e8a17 bpf_prog_da4fe6b3d2c29b25_trace_return+0x28 (bpf_prog_da4fe6b3d2c29b25_trace_return) callq 0xffffffff811fed50 sleep 36660 [016] 1057036.806464725: ffffffff811fed50 bpf_get_current_pid_tgid+0x0 ([kernel.kallsyms]) nopl %eax, (%rax,%rax,1) sleep 36660 [016] 1057036.806464725: ffffffff811fed55 bpf_get_current_pid_tgid+0x5 ([kernel.kallsyms]) movq %gs:0x15c00, %rdx sleep 36660 [016] 1057036.806464725: ffffffff811fed5e bpf_get_current_pid_tgid+0xe ([kernel.kallsyms]) test %rdx, %rdx sleep 36660 [016] 1057036.806464725: ffffffff811fed61 bpf_get_current_pid_tgid+0x11 ([kernel.kallsyms]) jz 0xffffffff811fed79 sleep 36660 [016] 1057036.806464725: ffffffff811fed63 bpf_get_current_pid_tgid+0x13 ([kernel.kallsyms]) movsxdl 0x494(%rdx), %rax sleep 36660 [016] 1057036.806464725: ffffffff811fed6a bpf_get_current_pid_tgid+0x1a ([kernel.kallsyms]) movsxdl 0x490(%rdx), %rdx sleep 36660 [016] 1057036.806464725: ffffffff811fed71 bpf_get_current_pid_tgid+0x21 ([kernel.kallsyms]) shl $0x20, %rax sleep 36660 [016] 1057036.806464725: ffffffff811fed75 bpf_get_current_pid_tgid+0x25 ([kernel.kallsyms]) or %rdx, %rax sleep 36660 [016] 1057036.806464725: ffffffff811fed78 bpf_get_current_pid_tgid+0x28 ([kernel.kallsyms]) retq sleep 36660 [016] 1057036.806464725: ffffffffa05e8a1c bpf_prog_da4fe6b3d2c29b25_trace_return+0x2d (bpf_prog_da4fe6b3d2c29b25_trace_return) movq %rax, -0x8(%rbp) sleep 36660 [016] 1057036.806464725: ffffffffa05e8a20 bpf_prog_da4fe6b3d2c29b25_trace_return+0x31 (bpf_prog_da4fe6b3d2c29b25_trace_return) xor %edi, %edi sleep 36660 [016] 1057036.806464725: ffffffffa05e8a22 bpf_prog_da4fe6b3d2c29b25_trace_return+0x33 (bpf_prog_da4fe6b3d2c29b25_trace_return) movq %rdi, -0x10(%rbp) sleep 36660 [016] 1057036.806464725: ffffffffa05e8a26 bpf_prog_da4fe6b3d2c29b25_trace_return+0x37 (bpf_prog_da4fe6b3d2c29b25_trace_return) movq %rdi, -0x18(%rbp) # perf-core/perf-with-kcore script pt --call-trace ... sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms] ) kretprobe_perf_func sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms] ) trace_call_bpf sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms] ) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms] ) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_get_current_pid_tgid sleep 36660 [016] 1057036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_ktime_get_ns sleep 36660 [016] 1057036.806464725: ([kernel.kallsyms] ) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806464725: ([kernel.kallsyms] ) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806465045: (bpf_prog_da4fe6b3d2c29b25_trace_return ) __htab_map_lookup_elem sleep 36660 [016] 1057036.806465366: ([kernel.kallsyms] ) memcmp sleep 36660 [016] 1057036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_probe_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) probe_kernel_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) __check_object_size sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) check_stack_object sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) copy_user_enhanced_fast_string sleep 36660 [016] 1057036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_probe_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) probe_kernel_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) __check_object_size sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) check_stack_object sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) copy_user_enhanced_fast_string sleep 36660 [016] 1057036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_get_current_uid_gid sleep 36660 [016] 1057036.806466008: ([kernel.kallsyms] ) from_kgid sleep 36660 [016] 1057036.806466008: ([kernel.kallsyms] ) from_kuid sleep 36660 [016] 1057036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_perf_event_output sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms] ) perf_event_output sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms] ) perf_prepare_sample sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms] ) perf_misc_flags sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms] ) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms] ) __x86_indirect_thunk_rax It's also available in here: git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git perf/fixes thanks, jirka Cc: Jesper Dangaard Brouer Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Stanislav Fomichev --- Jiri Olsa (11): perf tools: Separate generic code in dso__data_file_size perf tools: Separate generic code in dso_cache__read perf tools: Simplify dso_cache__read function perf tools: Add bpf dso read and size hooks perf tools: Read also the end of the kernel perf tools: Do not erase uncovered maps by kcore perf tools: Fix side band thread draining perf tools: Fix map reference counting perf tools: Keep zero in pgoff bpf map perf tools: Reuse shared eBPF dso objects perf script: Pad dso name for --call-trace Song Liu (1): perf tools: Check maps for bpf programs tools/include/linux/kernel.h | 1 + tools/lib/vsprintf.c | 19 +++++++++++++++++++ tools/perf/builtin-script.c | 1 + tools/perf/util/dso.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------ tools/perf/util/evlist.c | 14 +++++++++----- tools/perf/util/machine.c | 45 +++++++++++++++++++++++++++++++-------------- tools/perf/util/map.c | 26 +++++++++++++++++++++++--- tools/perf/util/map.h | 4 +++- tools/perf/util/symbol.c | 14 +++++++++++++- tools/perf/util/symbol_conf.h | 1 + tools/perf/util/symbol_fprintf.c | 1 + 11 files changed, 190 insertions(+), 60 deletions(-)