2009-12-07 16:57:49

by Masami Hiramatsu

[permalink] [raw]
Subject: [BUGFIX PATCH -tip 0/5] perf-probe/x86 insn decoder bugfixes

Hi Ingo,

Here are several bugfixes which are reported on LKML
for perf-probe and x86 insn decoder.

Thank you,

---

Juha Leppanen (1):
perf probe: Fix strtailcmp() to compare s1[0] and s2[0]

Masami Hiramatsu (4):
perf probe: Use pr_debug for debug message
perf probe: Check e_snprintf() format string
perf probe: Fix event namelist to duplicate string
x86 insn: Delete empty or incomplete inat-tables.c


arch/x86/lib/Makefile | 2 +-
tools/perf/builtin-probe.c | 4 ++--
tools/perf/util/probe-event.c | 9 +++++++--
tools/perf/util/probe-finder.c | 2 +-
4 files changed, 11 insertions(+), 6 deletions(-)

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division
e-mail: [email protected]


2009-12-07 16:56:48

by Masami Hiramatsu

[permalink] [raw]
Subject: [BUGFIX PATCH -tip 1/5] x86 insn: Delete empty or incomplete inat-tables.c

Delete empty or incomplete inat-tables.c if gen-insn-attr-x86.awk
failed, because it causes a build error if user tries to build
kernel next time.

Signed-off-by: Masami Hiramatsu <[email protected]>
Reported-by: Arkadiusz Miskiewicz <[email protected]>
Cc: Arkadiusz Miskiewicz <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Ingo Molnar <[email protected]>
---

arch/x86/lib/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 442b3b3..45b20e4 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -5,7 +5,7 @@
inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
quiet_cmd_inat_tables = GEN $@
- cmd_inat_tables = $(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@
+ cmd_inat_tables = $(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@ || rm -f $@

$(obj)/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
$(call cmd,inat_tables)


--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2009-12-07 16:57:56

by Masami Hiramatsu

[permalink] [raw]
Subject: [BUGFIX PATCH -tip 2/5] perf probe: Fix strtailcmp() to compare s1[0] and s2[0]

From: Juha Leppanen <[email protected]>

Fix strtailcmp() to compare s1[0] and s2[0].
strtailcmp() returns 0 if "a" and "b" or "a" and "ab", it's
a wrong behavior. This patch fixes it.

Signed-off-by: "Juha Leppanen" <[email protected]>
Reported-by: "Juha Leppanen" <[email protected]>
Acked-by: Masami Hiramatsu <[email protected]>
---

tools/perf/util/probe-finder.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 293cdfc..4585f1d 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -106,7 +106,7 @@ static int strtailcmp(const char *s1, const char *s2)
{
int i1 = strlen(s1);
int i2 = strlen(s2);
- while (--i1 > 0 && --i2 > 0) {
+ while (--i1 >= 0 && --i2 >= 0) {
if (s1[i1] != s2[i2])
return s1[i1] - s2[i2];
}


--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2009-12-07 16:56:38

by Masami Hiramatsu

[permalink] [raw]
Subject: [BUGFIX PATCH -tip 3/5] perf probe: Fix event namelist to duplicate string

Fix event namelist to duplicate string. Without duplicating,
adding multiple probes causes stack overwrite bug, because
it reuses a buffer on stack while the buffer is already
added in the namelist. String duplication solves this bug
because only contents of the buffer is copied to the namelist.

Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
---

tools/perf/util/probe-event.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index cd7fbda..de0d913 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -413,12 +413,13 @@ static struct strlist *get_perf_event_names(int fd)

rawlist = get_trace_kprobe_event_rawlist(fd);

- sl = strlist__new(false, NULL);
+ sl = strlist__new(true, NULL);
for (i = 0; i < strlist__nr_entries(rawlist); i++) {
ent = strlist__entry(rawlist, i);
parse_trace_kprobe_event(ent->s, &group, &event, NULL);
strlist__add(sl, event);
free(group);
+ free(event);
}

strlist__delete(rawlist);
@@ -480,5 +481,6 @@ void add_trace_kprobe_events(struct probe_point *probes, int nr_probes)
strlist__add(namelist, event);
}
}
+ strlist__delete(namelist);
close(fd);
}


--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2009-12-07 16:56:52

by Masami Hiramatsu

[permalink] [raw]
Subject: [BUGFIX PATCH -tip 4/5] perf probe: Check e_snprintf() format string

Check e_snprintf() format string by gcc, and fix a bug of
e_snprintf() caller.

Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
---

tools/perf/util/probe-event.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index de0d913..88e1804 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -48,6 +48,9 @@

/* If there is no space to write, returns -E2BIG. */
static int e_snprintf(char *str, size_t size, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+
+static int e_snprintf(char *str, size_t size, const char *format, ...)
{
int ret;
va_list ap;
@@ -258,7 +261,7 @@ int synthesize_perf_probe_event(struct probe_point *pp)
ret = e_snprintf(buf, MAX_CMDLEN, "%s%s%s%s", pp->function,
offs, pp->retprobe ? "%return" : "", line);
else
- ret = e_snprintf(buf, MAX_CMDLEN, "%s%s%s%s", pp->file, line);
+ ret = e_snprintf(buf, MAX_CMDLEN, "%s%s", pp->file, line);
if (ret <= 0)
goto error;
len = ret;


--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2009-12-07 17:23:55

by Masami Hiramatsu

[permalink] [raw]
Subject: [BUGFIX PATCH -tip 5/5] perf probe: Use pr_debug for debug message

Use pr_debug() for "missing vmlinux" debugging message.

Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
---

tools/perf/builtin-probe.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index a58e11b..8993a1f 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -194,8 +194,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
if (session.need_dwarf)
die("Could not open vmlinux/module file.");

- pr_warning("Could not open vmlinux/module file."
- " Try to use symbols.\n");
+ pr_debug("Could not open vmlinux/module file."
+ " Try to use symbols.\n");
goto end_dwarf;
}



--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2009-12-07 17:39:32

by Masami Hiramatsu

[permalink] [raw]
Subject: [tip:perf/urgent] x86 insn: Delete empty or incomplete inat-tables.c

Commit-ID: d32ba45503acf9c23b301eba2397ca2ee322627b
Gitweb: http://git.kernel.org/tip/d32ba45503acf9c23b301eba2397ca2ee322627b
Author: Masami Hiramatsu <[email protected]>
AuthorDate: Mon, 7 Dec 2009 12:00:33 -0500
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 7 Dec 2009 18:33:19 +0100

x86 insn: Delete empty or incomplete inat-tables.c

Delete empty or incomplete inat-tables.c if gen-insn-attr-x86.awk
failed, because it causes a build error if user tries to build
kernel next time.

Reported-by: Arkadiusz Miskiewicz <[email protected]>
Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: systemtap <[email protected]>
Cc: DLE <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/lib/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 442b3b3..45b20e4 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -5,7 +5,7 @@
inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
quiet_cmd_inat_tables = GEN $@
- cmd_inat_tables = $(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@
+ cmd_inat_tables = $(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@ || rm -f $@

$(obj)/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
$(call cmd,inat_tables)

Subject: [tip:perf/urgent] perf probe: Fix strtailcmp() to compare s1and s2[0]

Commit-ID: d56728b8d7fb3e1e5e5f97b88fdf6b43a35b4f5e
Gitweb: http://git.kernel.org/tip/d56728b8d7fb3e1e5e5f97b88fdf6b43a35b4f5e
Author: Juha Leppanen <[email protected]>
AuthorDate: Mon, 7 Dec 2009 12:00:40 -0500
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 7 Dec 2009 18:33:20 +0100

perf probe: Fix strtailcmp() to compare s1and s2[0]

Fix strtailcmp() to compare s1[0] and s2[0]. strtailcmp() returns 0
if "a" and "b" or "a" and "ab", it's a wrong behavior. This patch
fixes it.

Signed-off-by: "Juha Leppanen" <[email protected]>
Acked-by: Masami Hiramatsu <[email protected]>
Cc: systemtap <[email protected]>
Cc: DLE <[email protected]>
Cc: Juha Leppanen <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/util/probe-finder.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 293cdfc..4585f1d 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -106,7 +106,7 @@ static int strtailcmp(const char *s1, const char *s2)
{
int i1 = strlen(s1);
int i2 = strlen(s2);
- while (--i1 > 0 && --i2 > 0) {
+ while (--i1 >= 0 && --i2 >= 0) {
if (s1[i1] != s2[i2])
return s1[i1] - s2[i2];
}

2009-12-07 17:39:00

by Masami Hiramatsu

[permalink] [raw]
Subject: [tip:perf/urgent] perf probe: Fix event namelist to duplicate string

Commit-ID: e1d2017b24fb31602f1128e6a8b2afc54c9283cd
Gitweb: http://git.kernel.org/tip/e1d2017b24fb31602f1128e6a8b2afc54c9283cd
Author: Masami Hiramatsu <[email protected]>
AuthorDate: Mon, 7 Dec 2009 12:00:46 -0500
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 7 Dec 2009 18:33:21 +0100

perf probe: Fix event namelist to duplicate string

Fix event namelist to duplicate string. Without duplicating, adding
multiple probes causes stack overwrite bug, because it reuses a
buffer on stack while the buffer is already added in the namelist.
String duplication solves this bug because only contents of the
buffer is copied to the namelist.

Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: systemtap <[email protected]>
Cc: DLE <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/util/probe-event.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index cd7fbda..de0d913 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -413,12 +413,13 @@ static struct strlist *get_perf_event_names(int fd)

rawlist = get_trace_kprobe_event_rawlist(fd);

- sl = strlist__new(false, NULL);
+ sl = strlist__new(true, NULL);
for (i = 0; i < strlist__nr_entries(rawlist); i++) {
ent = strlist__entry(rawlist, i);
parse_trace_kprobe_event(ent->s, &group, &event, NULL);
strlist__add(sl, event);
free(group);
+ free(event);
}

strlist__delete(rawlist);
@@ -480,5 +481,6 @@ void add_trace_kprobe_events(struct probe_point *probes, int nr_probes)
strlist__add(namelist, event);
}
}
+ strlist__delete(namelist);
close(fd);
}

2009-12-07 17:39:16

by Masami Hiramatsu

[permalink] [raw]
Subject: [tip:perf/urgent] perf probe: Check e_snprintf() format string

Commit-ID: 849884508ecbe2d220131840e4cc7c32ca24ebe3
Gitweb: http://git.kernel.org/tip/849884508ecbe2d220131840e4cc7c32ca24ebe3
Author: Masami Hiramatsu <[email protected]>
AuthorDate: Mon, 7 Dec 2009 12:00:53 -0500
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 7 Dec 2009 18:33:21 +0100

perf probe: Check e_snprintf() format string

Check e_snprintf() format string by gcc, and fix a bug of
e_snprintf() caller.

Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: systemtap <[email protected]>
Cc: DLE <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/util/probe-event.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index de0d913..88e1804 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -48,6 +48,9 @@

/* If there is no space to write, returns -E2BIG. */
static int e_snprintf(char *str, size_t size, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+
+static int e_snprintf(char *str, size_t size, const char *format, ...)
{
int ret;
va_list ap;
@@ -258,7 +261,7 @@ int synthesize_perf_probe_event(struct probe_point *pp)
ret = e_snprintf(buf, MAX_CMDLEN, "%s%s%s%s", pp->function,
offs, pp->retprobe ? "%return" : "", line);
else
- ret = e_snprintf(buf, MAX_CMDLEN, "%s%s%s%s", pp->file, line);
+ ret = e_snprintf(buf, MAX_CMDLEN, "%s%s", pp->file, line);
if (ret <= 0)
goto error;
len = ret;

2009-12-07 17:38:54

by Masami Hiramatsu

[permalink] [raw]
Subject: [tip:perf/urgent] perf probe: Use pr_debug for debug message

Commit-ID: d3a2dbf844d81b4b9c9ad6044563c294e7a48cac
Gitweb: http://git.kernel.org/tip/d3a2dbf844d81b4b9c9ad6044563c294e7a48cac
Author: Masami Hiramatsu <[email protected]>
AuthorDate: Mon, 7 Dec 2009 12:00:59 -0500
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 7 Dec 2009 18:33:22 +0100

perf probe: Use pr_debug for debug message

Use pr_debug() for "missing vmlinux" debugging message.

Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: systemtap <[email protected]>
Cc: DLE <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/builtin-probe.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index a58e11b..8993a1f 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -194,8 +194,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
if (session.need_dwarf)
die("Could not open vmlinux/module file.");

- pr_warning("Could not open vmlinux/module file."
- " Try to use symbols.\n");
+ pr_debug("Could not open vmlinux/module file."
+ " Try to use symbols.\n");
goto end_dwarf;
}