Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4308593ybi; Mon, 27 May 2019 15:42:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtTZeFj0uvqXYyRAlH+SjepRmy4L0AKzRbkFXcQrMwt99VbUcRrtH6qnRrSJLaa2WfULMb X-Received: by 2002:a63:ed09:: with SMTP id d9mr11997527pgi.419.1558996964983; Mon, 27 May 2019 15:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558996964; cv=none; d=google.com; s=arc-20160816; b=iz/eWtOSTpiyGY0UoYOiX8mrmIzufIUgNfLncS9c0yFlCP8GP5IyhztzkVbFoN9cKH FViQo5Pl40euNyTtPOqgUTQ7RBmRRrCcwoNpHk19RVEm15Xvv96izTORjN+EAVH8XzGz NLxId3hbfY9YQ6MBEgK3YHbma5GYOAbTcwrRZXTSxx6PLydRiK+1/9WwDdOYSJrlytbw hqFLR4eJ6qKZ4+tY18L7IOVopdHv8t+R6NMl0MQHbRKDmUFD4pW2w+YZQW7vNKxHsdvn ElP5zslKaLMtGVYmZqnOCL0T/ut6RpissYzFM+eJgNpfQxCa54qL3fOHB7vOQsN/CZQi uFkg== 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=OuKciJfMToqvMa9dhpWp5degUa9XNxHH+ZVeaLy97AA=; b=rOhqYKfAvS8gDt0kF/+nxD2Un8ciV7gad9+p1Zy9sIbe2cbe6Mk6ZwFfVbw+BRZpAa bwuoKb1FQbJH3XXj9nc2DE8gpg9ZlzoZjHiR6gd/cuMa9m5/CXPSMw6vkIVbErk8IvFD XOxOuQrbPdFf7/sLX32E6RXF9Fm9VJdj+9tPim2fsUpMZTnEKrmUPaYOF7p75JOHDeGO qcfLYjr0BEW4IE6EKs0+TeqKmDmByUfSqJHpt4/WUjt85eZJvtEdf91MiDMlzelizS7O A9GD4OBho+CK3GWFht6i863vGAvANEI/nK+TRxSrgspyLzds9tV8Q+PM7mngOEWPwYEY 7GGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uTu5G56g; 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 13si18941315pgl.419.2019.05.27.15.42.29; Mon, 27 May 2019 15:42:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uTu5G56g; 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 S1728060AbfE0WlA (ORCPT + 99 others); Mon, 27 May 2019 18:41:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:46802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727392AbfE0WlA (ORCPT ); Mon, 27 May 2019 18:41:00 -0400 Received: from quaco.ghostprotocols.net (179-240-171-7.3g.claro.net.br [179.240.171.7]) (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 ED2862081C; Mon, 27 May 2019 22:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558996858; bh=LUR9z8YUrouOfa2iWAAd0RCTcTyS2Am+Ti6wICsO9z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uTu5G56gODRrKSpnHF7OehUe7Pwsk9YOWFiatcYsrTpJ0gVmR6Aozn3R/bprb4Jnx 7NfWv4rT2gqavFq+FuBygj8ic3AUzzN8yMQP66bhTG7hHe4NYHhNrEBjuJAPxWV0CF n65h84ROrQhM+2/poTEbRv19DoT8mhhqxf61mw/Y= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Song Liu , Arnaldo Carvalho de Melo , Adrian Hunter , Alexander Shishkin , Andi Kleen , Peter Zijlstra , Stanislav Fomichev Subject: [PATCH 40/44] perf script: Add --show-bpf-events to show eBPF related events Date: Mon, 27 May 2019 19:37:26 -0300 Message-Id: <20190527223730.11474-41-acme@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190527223730.11474-1-acme@kernel.org> References: <20190527223730.11474-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa Add the --show-bpf-events command line option to show the eBPF related events: PERF_RECORD_KSYMBOL PERF_RECORD_BPF_EVENT Usage: # perf record -a ... # perf script --show-bpf-events ... swapper 0 [000] 0.000000: PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc0ef971d len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 swapper 0 [000] 0.000000: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 36 ... Committer testing: # perf script --show-bpf-events | egrep -i 'PERF_RECORD_(BPF|KSY)' 0 PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc029a6c3 len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 47 0 PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc029c1ae len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 48 0 PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc02ddd1c len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 49 0 PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc02dfc11 len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 50 0 PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc045da0a len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 51 0 PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc04ef4b4 len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 52 0 PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc09e15da len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 53 0 PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc0d2b1a3 len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 54 0 PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc0fd9850 len 381 type 1 flags 0x0 name bpf_prog_819967866022f1e1_sys_enter 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 179 0 PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc0feb1ec len 191 type 1 flags 0x0 name bpf_prog_c1bd85c092d6e4aa_sys_exit 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 180 ^C[root@quaco pt]# perf evlist intel_pt//ku dummy:u # Signed-off-by: Jiri Olsa Acked-by: Song Liu Tested-by: Arnaldo Carvalho de Melo Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-11-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-script.txt | 3 ++ tools/perf/builtin-script.c | 42 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt index 9b0d04dd2a61..af8282782911 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt @@ -313,6 +313,9 @@ OPTIONS --show-round-events Display finished round events i.e. events of type PERF_RECORD_FINISHED_ROUND. +--show-bpf-events + Display bpf events i.e. events of type PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT. + --demangle:: Demangle symbol names to human readable form. It's enabled by default, disable with --no-demangle. diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 7adaa6c63a0b..3a48a2627670 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1606,6 +1606,7 @@ struct perf_script { bool show_namespace_events; bool show_lost_events; bool show_round_events; + bool show_bpf_events; bool allocated; bool per_event_dump; struct cpu_map *cpus; @@ -2318,6 +2319,41 @@ process_finished_round_event(struct perf_tool *tool __maybe_unused, return 0; } +static int +process_bpf_events(struct perf_tool *tool __maybe_unused, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine) +{ + struct thread *thread; + struct perf_script *script = container_of(tool, struct perf_script, tool); + struct perf_session *session = script->session; + struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id); + + if (machine__process_ksymbol(machine, event, sample) < 0) + return -1; + + if (!evsel->attr.sample_id_all) { + perf_event__fprintf(event, stdout); + return 0; + } + + thread = machine__findnew_thread(machine, sample->pid, sample->tid); + if (thread == NULL) { + pr_debug("problem processing MMAP event, skipping it.\n"); + return -1; + } + + if (!filter_cpu(sample)) { + perf_sample__fprintf_start(sample, thread, evsel, + event->header.type, stdout); + perf_event__fprintf(event, stdout); + } + + thread__put(thread); + return 0; +} + static void sig_handler(int sig __maybe_unused) { session_done = 1; @@ -2420,6 +2456,10 @@ static int __cmd_script(struct perf_script *script) script->tool.ordered_events = false; script->tool.finished_round = process_finished_round_event; } + if (script->show_bpf_events) { + script->tool.ksymbol = process_bpf_events; + script->tool.bpf_event = process_bpf_events; + } if (perf_script__setup_per_event_dump(script)) { pr_err("Couldn't create the per event dump files\n"); @@ -3439,6 +3479,8 @@ int cmd_script(int argc, const char **argv) "Show lost events (if recorded)"), OPT_BOOLEAN('\0', "show-round-events", &script.show_round_events, "Show round events (if recorded)"), + OPT_BOOLEAN('\0', "show-bpf-events", &script.show_bpf_events, + "Show bpf related events (if recorded)"), OPT_BOOLEAN('\0', "per-event-dump", &script.per_event_dump, "Dump trace output to files named by the monitored events"), OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"), -- 2.20.1