From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Ingo Molnar <mingo@redhat.com>, Naohiro Aota <naota@elisp.net>,
Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 08/41] perf probe: Fix --del option to delete events only with uprobe events
Date: Wed, 13 Aug 2014 19:47:54 -0300 [thread overview]
Message-ID: <1407970107-24540-9-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1407970107-24540-1-git-send-email-acme@kernel.org>
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Current perf probe --del doesn't work if only CONFIG_UPROBE_EVENTS=y
because it aborts when it fails to open kprobe_events file before
checking uprobe_events file.
This fixes --del option to delete dynamic events if it can open either
kprobe_events or uprobe_events. Only if it failed to open both of them,
it shows an error message and aborts.
Without this patch, if we run perf probe -d on the kernel configured
with CONFIG_KPROBE_EVENTS=n and CONFIG_UPROBE_EVENTS=y,
# perf probe -d \*
kprobe_events file does not exist - please rebuild kernel with CONFIG_KPROBE_EVENTS.
Error: Failed to delete events.
With this patch,
# perf probe -d \*
Removed event: probe_perf:alloc_event
Changes in v2:
- Use strerror_r instead of strerror.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Naohiro Aota <naota@elisp.net>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20140813161250.26440.24028.stgit@kbuild-fedora.novalocal
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-event.c | 49 +++++++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 23 deletions(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 50aa7f05ceb1..443225cb62f7 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1803,6 +1803,23 @@ static void print_open_warning(int err, bool is_kprobe)
strerror_r(-err, sbuf, sizeof(sbuf)));
}
+static void print_both_open_warning(int kerr, int uerr)
+{
+ /* Both kprobes and uprobes are disabled, warn it. */
+ if (kerr == -ENOTSUP && uerr == -ENOTSUP)
+ pr_warning("Debugfs is not mounted.\n");
+ else if (kerr == -ENOENT && uerr == -ENOENT)
+ pr_warning("Please rebuild kernel with CONFIG_KPROBE_EVENTS "
+ "or/and CONFIG_UPROBE_EVENTS.\n");
+ else {
+ char sbuf[128];
+ pr_warning("Failed to open kprobe events: %s.\n",
+ strerror_r(-kerr, sbuf, sizeof(sbuf)));
+ pr_warning("Failed to open uprobe events: %s.\n",
+ strerror_r(-uerr, sbuf, sizeof(sbuf)));
+ }
+}
+
static int open_probe_events(const char *trace_file, bool readwrite)
{
char buf[PATH_MAX];
@@ -1960,20 +1977,7 @@ int show_perf_probe_events(void)
up_fd = open_uprobe_events(false);
if (kp_fd < 0 && up_fd < 0) {
- /* Both kprobes and uprobes are disabled, warn it. */
- if (kp_fd == -ENOTSUP && up_fd == -ENOTSUP)
- pr_warning("Debugfs is not mounted.\n");
- else if (kp_fd == -ENOENT && up_fd == -ENOENT)
- pr_warning("Please rebuild kernel with "
- "CONFIG_KPROBE_EVENTS or/and "
- "CONFIG_UPROBE_EVENTS.\n");
- else {
- char sbuf[128];
- pr_warning("Failed to open kprobe events: %s.\n",
- strerror_r(-kp_fd, sbuf, sizeof(sbuf)));
- pr_warning("Failed to open uprobe events: %s.\n",
- strerror_r(-up_fd, sbuf, sizeof(sbuf)));
- }
+ print_both_open_warning(kp_fd, up_fd);
ret = kp_fd;
goto out;
}
@@ -2474,19 +2478,18 @@ int del_perf_probe_events(struct strlist *dellist)
/* Get current event names */
kfd = open_kprobe_events(true);
- if (kfd < 0) {
- print_open_warning(kfd, true);
- return kfd;
- }
+ if (kfd >= 0)
+ namelist = get_probe_trace_event_names(kfd, true);
- namelist = get_probe_trace_event_names(kfd, true);
ufd = open_uprobe_events(true);
-
- if (ufd < 0)
- print_open_warning(ufd, false);
- else
+ if (ufd >= 0)
unamelist = get_probe_trace_event_names(ufd, true);
+ if (kfd < 0 && ufd < 0) {
+ print_both_open_warning(kfd, ufd);
+ goto error;
+ }
+
if (namelist == NULL && unamelist == NULL)
goto error;
--
1.9.3
next prev parent reply other threads:[~2014-08-13 22:49 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-13 22:47 [GIT PULL 00/41] perf/core improvements and fixes Arnaldo Carvalho de Melo
2014-08-13 22:47 ` [PATCH 01/41] perf top: Don't look for kernel idle symbols in all DSOs Arnaldo Carvalho de Melo
2014-08-13 22:47 ` [PATCH 02/41] perf tools: Add cpu_startup_entry to the list of kernel idle symbols Arnaldo Carvalho de Melo
2014-08-13 22:47 ` [PATCH 03/41] perf top: Join the display thread on exit Arnaldo Carvalho de Melo
2014-08-13 22:47 ` [PATCH 04/41] perf tools: Introduce set_term_quiet_input helper function Arnaldo Carvalho de Melo
2014-08-13 22:47 ` [PATCH 05/41] perf top: Setup signals for terminal output Arnaldo Carvalho de Melo
2014-08-13 22:47 ` [PATCH 06/41] perf kvm: Fix stdin handling for 'kvm stat live' command Arnaldo Carvalho de Melo
2014-08-13 22:47 ` [PATCH 07/41] perf probe: Fix --list option to show events only with uprobe events Arnaldo Carvalho de Melo
2014-08-13 22:47 ` Arnaldo Carvalho de Melo [this message]
2014-08-13 22:47 ` [PATCH 09/41] perf trace: Add beautifier for mremap flags param Arnaldo Carvalho de Melo
2014-08-13 22:47 ` [PATCH 10/41] perf tools: Fix CLOEXEC probe for perf_event_paranoid == 2 Arnaldo Carvalho de Melo
2014-08-13 22:47 ` [PATCH 11/41] perf tools: Fix one of the probe events to exclude kernel Arnaldo Carvalho de Melo
2014-08-13 22:47 ` [PATCH 12/41] perf tools: Fix probing the kernel API with cpu-wide events Arnaldo Carvalho de Melo
2014-08-13 22:47 ` [PATCH 13/41] perf tools: Prefer to use a cpu-wide event for probing CLOEXEC Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 14/41] perf script: Fix possible memory leaks Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 15/41] perf symbols: Fix a memory leak in vmlinux_path__init() Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 16/41] perf annotate: Move session handling out of __cmd_annotate() Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 17/41] perf buildid-cache: Move session handling into cmd_buildid_cache() Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 18/41] perf inject: Move session handling out of __cmd_inject() Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 19/41] perf kmem: Move session handling out of __cmd_kmem() Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 20/41] perf kvm: Move call to symbol__init() after creating session Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 21/41] perf lock: " Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 22/41] perf sched: " Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 23/41] perf script: " Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 24/41] perf timechart: " Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 25/41] perf trace: " Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 26/41] perf tools: Check recorded kernel version when finding vmlinux Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 27/41] perf hists browser: Fix a small callchain display bug Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 28/41] perf report: Set proper sort__mode for the branch option Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 29/41] perf top: Fix -z option behavior Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 30/41] perf top: Handle 'z' key for toggle zeroing samples in TUI Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 31/41] perf symbols: Don't demangle parameters and such by default Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 32/41] perf symbols: Fix missing label symbols Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 33/41] perf evlist: Add 'system_wide' option Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 34/41] perf evlist: Add perf_evlist__set_tracking_event() Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 35/41] perf session: Add perf_session__peek_event() Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 36/41] perf script: Allow callchains if any event samples them Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 37/41] perf script python: Add helpers for calling Python objects Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 38/41] perf tools: Identify which comms are from exec Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 39/41] perf machine: Add machine__thread_exec_comm() Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 40/41] perf tools: Add flags and insn_len to struct sample Arnaldo Carvalho de Melo
2014-08-13 22:48 ` [PATCH 41/41] perf evlist: Add perf_evlist__enable_event_idx() Arnaldo Carvalho de Melo
2014-08-14 8:40 ` [GIT PULL 00/41] perf/core improvements and fixes Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1407970107-24540-9-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=naota@elisp.net \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox