linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
To: acme@kernel.org, jolsa@kernel.org, irogers@google.com
Cc: ak@linux.intel.com, namhyung@kernel.org, james.clark@arm.com,
	mpe@ellerman.id.au, linux-perf-users@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, maddy@linux.ibm.com,
	rnsastry@linux.ibm.com, kjain@linux.ibm.com,
	disgoel@linux.ibm.com
Subject: [PATCH] tools/perf: Disable perf probe when libtraceevent is missing
Date: Fri, 20 Jan 2023 17:32:56 +0530	[thread overview]
Message-ID: <20230120120256.34694-1-atrajeev@linux.vnet.ibm.com> (raw)

While parsing the tracepoint events in parse_events_add_tracepoint()
function, code checks for HAVE_LIBTRACEEVENT support. This is needed
since libtraceevent is necessary for tracepoint. But while adding
probe points, check for LIBTRACEEVENT is not done in case of perf probe.
Hence, in environment with missing libtraceevent-devel, it is
observed that adding a probe point works even though its not
supported.

Example:
Adding probe point:
	./perf probe 'vfs_getname=getname_flags:72 pathname=result->name:string'
	Added new event:
	  probe:vfs_getname    (on getname_flags:72 with pathname=result->name:string)

	You can now use it in all perf tools, such as:

		perf record -e probe:vfs_getname -aR sleep 1

But trying perf record:
	./perf  record -e probe:vfs_getname -aR sleep 1
	event syntax error: 'probe:vfs_getname'
				\___ unsupported tracepoint
	libtraceevent is necessary for tracepoint support
	Run 'perf list' for a list of valid events

Fix this by wrapping "builtin-probe" compilation and
"perf probe" usage under "CONFIG_LIBTRACEEVENT" check.

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
 tools/perf/Build  | 4 +++-
 tools/perf/perf.c | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Build b/tools/perf/Build
index 6dd67e502295..a138a2304929 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -33,7 +33,9 @@ ifeq ($(CONFIG_LIBTRACEEVENT),y)
   perf-$(CONFIG_TRACE) += trace/beauty/
 endif
 
-perf-$(CONFIG_LIBELF) += builtin-probe.o
+ifeq ($(CONFIG_LIBTRACEEVENT),y)
+  perf-$(CONFIG_LIBELF) += builtin-probe.o
+endif
 
 perf-y += bench/
 perf-y += tests/
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 82bbe0ca858b..7b0d79284d5a 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -80,9 +80,11 @@ static struct cmd_struct commands[] = {
 #ifdef HAVE_LIBTRACEEVENT
 	{ "sched",	cmd_sched,	0 },
 #endif
+#ifdef HAVE_LIBTRACEEVENT
 #ifdef HAVE_LIBELF_SUPPORT
 	{ "probe",	cmd_probe,	0 },
 #endif
+#endif
 #ifdef HAVE_LIBTRACEEVENT
 	{ "kmem",	cmd_kmem,	0 },
 	{ "lock",	cmd_lock,	0 },
-- 
2.39.0


             reply	other threads:[~2023-01-20 12:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 12:02 Athira Rajeev [this message]
2023-01-20 14:28 ` [PATCH] tools/perf: Disable perf probe when libtraceevent is missing Arnaldo Carvalho de Melo
2023-01-25 14:46   ` Athira Rajeev

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=20230120120256.34694-1-atrajeev@linux.vnet.ibm.com \
    --to=atrajeev@linux.vnet.ibm.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=disgoel@linux.ibm.com \
    --cc=irogers@google.com \
    --cc=james.clark@arm.com \
    --cc=jolsa@kernel.org \
    --cc=kjain@linux.ibm.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=namhyung@kernel.org \
    --cc=rnsastry@linux.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).