* [tip:perf/urgent] perf thread_map: Fix the sizeof() calculation for map entries
@ 2015-07-10 8:14 tip-bot for Arnaldo Carvalho de Melo
0 siblings, 0 replies; only message in thread
From: tip-bot for Arnaldo Carvalho de Melo @ 2015-07-10 8:14 UTC (permalink / raw)
To: linux-tip-commits
Cc: mingo, eranian, hpa, acme, jolsa, namhyung, dsahern,
linux-kernel, fweisbec, tglx, bp, adrian.hunter
Commit-ID: 08ae217b8d44986062fe3648c5bb83816d5bc00f
Gitweb: http://git.kernel.org/tip/08ae217b8d44986062fe3648c5bb83816d5bc00f
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Thu, 9 Jul 2015 12:14:43 -0300
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 9 Jul 2015 12:28:53 -0300
perf thread_map: Fix the sizeof() calculation for map entries
When we started adding extra stuff per array entry, growing the size of
those entries to more than sizeof(pid_t), we had to convert those sizeof
operations to the more robust sizeof(map->map[0]) idiom, that is future
proof, i.e. if/when we add more stuff to those entries, that expression
will produce the new per-entry size.
And besides that, we need to zero out those extra fields, that sometimes
may not get filled, like when we couldn't care less about the comms,
since we don't need those, but since we will try freeing it at
thread_map__delete(), we better fix it.
That is why a thread_map__realloc() was provided.
But that method wasn't used in thread_map__new_by_uid(), fix it.
Reported-by: Ingo Molnar <mingo@kernel.org>
Fixes: 792402fd5c0a ("perf thrad_map: Add comm string into array")
Fixes: 9d7e8c3a96e5 ("perf tools: Add thread_map__(alloc|realloc) helpers")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-6a0swlm6m8lnu3wpjv284hkb@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/thread_map.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index da7646d..292ae2c 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -136,8 +136,7 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
if (grow) {
struct thread_map *tmp;
- tmp = realloc(threads, (sizeof(*threads) +
- max_threads * sizeof(pid_t)));
+ tmp = thread_map__realloc(threads, max_threads);
if (tmp == NULL)
goto out_free_namelist;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-07-10 8:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-10 8:14 [tip:perf/urgent] perf thread_map: Fix the sizeof() calculation for map entries tip-bot for Arnaldo Carvalho de Melo
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®