mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf tools: ensure comm properly terminated If threads in a multi-threaded process have names shorter than the main thread the comm for the named threads is not properly terminated.
@ 2012-02-24 19:31 David Ahern
  2012-02-24 19:39 ` Arnaldo Carvalho de Melo
  2012-03-02  9:51 ` [tip:perf/urgent] perf tools: Ensure comm string is " tip-bot for David Ahern
  0 siblings, 2 replies; 3+ messages in thread
From: David Ahern @ 2012-02-24 19:31 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: mingo, peterz, fweisbec, paulus, tglx, David Ahern

e.g., for the process 'namedthreads' where each thread is named noploop%d
where %d is the thread number:

Before:
    perf script -f comm,tid,ip,sym,dso
    noploop:4ads 21616  400a49 noploop (/tmp/namedthreads)
The 'ads' in the thread comm bleeds over from the process name.

After:
    perf script -f comm,tid,ip,sym,dso
       noploop:4 21616  400a49 noploop (/tmp/namedthreads)

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 tools/perf/util/event.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 2044324..2a6f33c 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -74,6 +74,7 @@ static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, size_t len)
 			if (size >= len)
 				size = len - 1;
 			memcpy(comm, name, size);
+			comm[size] = '\0';
 
 		} else if (memcmp(bf, "Tgid:", 5) == 0) {
 			char *tgids = bf + 5;
-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf tools: ensure comm properly terminated If threads in a multi-threaded process have names shorter than the main thread the comm for the named threads is not properly terminated.
  2012-02-24 19:31 [PATCH] perf tools: ensure comm properly terminated If threads in a multi-threaded process have names shorter than the main thread the comm for the named threads is not properly terminated David Ahern
@ 2012-02-24 19:39 ` Arnaldo Carvalho de Melo
  2012-03-02  9:51 ` [tip:perf/urgent] perf tools: Ensure comm string is " tip-bot for David Ahern
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2012-02-24 19:39 UTC (permalink / raw)
  To: David Ahern; +Cc: linux-kernel, mingo, peterz, fweisbec, paulus, tglx

Em Fri, Feb 24, 2012 at 12:31:38PM -0700, David Ahern escreveu:
> e.g., for the process 'namedthreads' where each thread is named noploop%d
> where %d is the thread number:
> 
> Before:
>     perf script -f comm,tid,ip,sym,dso
>     noploop:4ads 21616  400a49 noploop (/tmp/namedthreads)
> The 'ads' in the thread comm bleeds over from the process name.
> 
> After:
>     perf script -f comm,tid,ip,sym,dso
>        noploop:4 21616  400a49 noploop (/tmp/namedthreads)

Thanks, applied to perf/urgent.

- Arnaldo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perf/urgent] perf tools: Ensure comm string is properly terminated
  2012-02-24 19:31 [PATCH] perf tools: ensure comm properly terminated If threads in a multi-threaded process have names shorter than the main thread the comm for the named threads is not properly terminated David Ahern
  2012-02-24 19:39 ` Arnaldo Carvalho de Melo
@ 2012-03-02  9:51 ` tip-bot for David Ahern
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for David Ahern @ 2012-03-02  9:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, peterz, fweisbec,
	dsahern, tglx, mingo

Commit-ID:  cfbd70c17c4535e64be92ea442a2a45078a18184
Gitweb:     http://git.kernel.org/tip/cfbd70c17c4535e64be92ea442a2a45078a18184
Author:     David Ahern <dsahern@gmail.com>
AuthorDate: Fri, 24 Feb 2012 12:31:38 -0700
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 29 Feb 2012 18:29:45 -0300

perf tools: Ensure comm string is properly terminated

If threads in a multi-threaded process have names shorter than the main
thread the comm for the named threads is not properly terminated.

E.g., for the process 'namedthreads' where each thread is named noploop%d
where %d is the thread number:

Before:
    perf script -f comm,tid,ip,sym,dso
    noploop:4ads 21616  400a49 noploop (/tmp/namedthreads)
The 'ads' in the thread comm bleeds over from the process name.

After:
    perf script -f comm,tid,ip,sym,dso
       noploop:4 21616  400a49 noploop (/tmp/namedthreads)

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1330111898-68071-1-git-send-email-dsahern@gmail.com
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/event.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 2044324..2a6f33c 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -74,6 +74,7 @@ static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, size_t len)
 			if (size >= len)
 				size = len - 1;
 			memcpy(comm, name, size);
+			comm[size] = '\0';
 
 		} else if (memcmp(bf, "Tgid:", 5) == 0) {
 			char *tgids = bf + 5;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-02  9:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-24 19:31 [PATCH] perf tools: ensure comm properly terminated If threads in a multi-threaded process have names shorter than the main thread the comm for the named threads is not properly terminated David Ahern
2012-02-24 19:39 ` Arnaldo Carvalho de Melo
2012-03-02  9:51 ` [tip:perf/urgent] perf tools: Ensure comm string is " tip-bot for David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®