From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 02/13] perf syscalltbl: Support glob matching on syscall names
Date: Mon, 4 Sep 2017 11:00:33 -0300 [thread overview]
Message-ID: <20170904140044.22912-3-acme@kernel.org> (raw)
In-Reply-To: <20170904140044.22912-1-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
With two new methods, one to find the first match, returning its syscall
id and its index in whatever internal database it keeps the syscall
into, then one to find the next match, if any.
Implemented only on arches where we actually read the syscall table from
the kernel sources, i.e. x86-64 for now, all the others use the libaudit
method for which this returns -1, i.e. just stubs were added, with the
actual implementation using whatever libaudit functions for matching
that may be available.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-i0sj4rxk1a63pfe9gl8z8irs@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/syscalltbl.c | 33 +++++++++++++++++++++++++++++++++
tools/perf/util/syscalltbl.h | 3 +++
2 files changed, 36 insertions(+)
diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
index bbb4c1957578..19e5db90394c 100644
--- a/tools/perf/util/syscalltbl.c
+++ b/tools/perf/util/syscalltbl.c
@@ -19,6 +19,7 @@
#ifdef HAVE_SYSCALL_TABLE
#include <linux/compiler.h>
#include <string.h>
+#include "string2.h"
#include "util.h"
#if defined(__x86_64__)
@@ -105,6 +106,27 @@ int syscalltbl__id(struct syscalltbl *tbl, const char *name)
return sc ? sc->id : -1;
}
+int syscalltbl__strglobmatch_next(struct syscalltbl *tbl, const char *syscall_glob, int *idx)
+{
+ int i;
+ struct syscall *syscalls = tbl->syscalls.entries;
+
+ for (i = *idx + 1; i < tbl->syscalls.nr_entries; ++i) {
+ if (strglobmatch(syscalls[i].name, syscall_glob)) {
+ *idx = i;
+ return syscalls[i].id;
+ }
+ }
+
+ return -1;
+}
+
+int syscalltbl__strglobmatch_first(struct syscalltbl *tbl, const char *syscall_glob, int *idx)
+{
+ *idx = -1;
+ return syscalltbl__strglobmatch_next(tbl, syscall_glob, idx);
+}
+
#else /* HAVE_SYSCALL_TABLE */
#include <libaudit.h>
@@ -131,4 +153,15 @@ int syscalltbl__id(struct syscalltbl *tbl, const char *name)
{
return audit_name_to_syscall(name, tbl->audit_machine);
}
+
+int syscalltbl__strglobmatch_next(struct syscalltbl *tbl __maybe_unused,
+ const char *syscall_glob __maybe_unused, int *idx __maybe_unused)
+{
+ return -1;
+}
+
+int syscalltbl__strglobmatch_first(struct syscalltbl *tbl, const char *syscall_glob, int *idx)
+{
+ return syscalltbl__strglobmatch_next(tbl, syscall_glob, idx);
+}
#endif /* HAVE_SYSCALL_TABLE */
diff --git a/tools/perf/util/syscalltbl.h b/tools/perf/util/syscalltbl.h
index e2951510484f..e9fb8786da7c 100644
--- a/tools/perf/util/syscalltbl.h
+++ b/tools/perf/util/syscalltbl.h
@@ -17,4 +17,7 @@ void syscalltbl__delete(struct syscalltbl *tbl);
const char *syscalltbl__name(const struct syscalltbl *tbl, int id);
int syscalltbl__id(struct syscalltbl *tbl, const char *name);
+int syscalltbl__strglobmatch_first(struct syscalltbl *tbl, const char *syscall_glob, int *idx);
+int syscalltbl__strglobmatch_next(struct syscalltbl *tbl, const char *syscall_glob, int *idx);
+
#endif /* __PERF_SYSCALLTBL_H */
--
2.13.5
next prev parent reply other threads:[~2017-09-04 14:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-04 14:00 [GIT PULL 00/13] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-09-04 14:00 ` [PATCH 01/13] perf report: Calculate the average cycles of iterations Arnaldo Carvalho de Melo
2017-09-04 14:00 ` Arnaldo Carvalho de Melo [this message]
2017-09-04 14:00 ` [PATCH 03/13] perf trace: Support syscall name globbing Arnaldo Carvalho de Melo
2017-09-04 14:00 ` [PATCH 04/13] perf test powerpc: Fix 'Object code reading' test Arnaldo Carvalho de Melo
2017-09-04 14:00 ` [PATCH 05/13] perf intel-pt: Fix syntax in documentation of config option Arnaldo Carvalho de Melo
2017-09-04 14:00 ` [PATCH 06/13] perf vendor events powerpc: Remove duplicate events Arnaldo Carvalho de Melo
2017-09-04 16:51 ` Andi Kleen
2017-09-04 14:00 ` [PATCH 07/13] perf tools: Support new sample type for physical address Arnaldo Carvalho de Melo
2017-09-04 14:00 ` [PATCH 08/13] perf sort: Add sort option " Arnaldo Carvalho de Melo
2017-09-04 14:00 ` [PATCH 09/13] perf mem: Support " Arnaldo Carvalho de Melo
2017-09-04 14:00 ` [PATCH 10/13] perf script: " Arnaldo Carvalho de Melo
2017-09-04 14:00 ` [PATCH 11/13] perf test: Add test case for PERF_SAMPLE_PHYS_ADDR Arnaldo Carvalho de Melo
2017-09-04 14:00 ` [PATCH 12/13] perf stat: Only auto-merge events that are PMU aliases Arnaldo Carvalho de Melo
2017-09-04 14:00 ` [PATCH 13/13] perf annotate browser: Help for cycling thru hottest instructions with TAB/shift+TAB Arnaldo Carvalho de Melo
2017-09-05 5:15 ` [GIT PULL 00/13] 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=20170904140044.22912-3-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=wangnan0@huawei.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).