diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2015-05-29 09:33:29 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-05-29 11:43:39 -0400 |
commit | 427cde3287f2c6349f308d0e22c9223f9ea05ef1 (patch) | |
tree | 0bdbdbc55612ffda2b4a1702073760dc8a551a3f /tools/perf/util/db-export.c | |
parent | 60fb7742928dab3c6a0fec7f2d2cce26d9366a3c (diff) |
perf db-export: Fix thread ref-counting
Thread ref-counting was not done for get_main_thread() meaning that
there was a thread__get() from machine__find_thread() that was not being
paired with thread__put(). Fix that.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1432906425-9911-2-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/db-export.c')
-rw-r--r-- | tools/perf/util/db-export.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c index eb7a2acb973b..1c9689e4cc17 100644 --- a/tools/perf/util/db-export.c +++ b/tools/perf/util/db-export.c | |||
@@ -234,7 +234,7 @@ int db_export__symbol(struct db_export *dbe, struct symbol *sym, | |||
234 | static struct thread *get_main_thread(struct machine *machine, struct thread *thread) | 234 | static struct thread *get_main_thread(struct machine *machine, struct thread *thread) |
235 | { | 235 | { |
236 | if (thread->pid_ == thread->tid) | 236 | if (thread->pid_ == thread->tid) |
237 | return thread; | 237 | return thread__get(thread); |
238 | 238 | ||
239 | if (thread->pid_ == -1) | 239 | if (thread->pid_ == -1) |
240 | return NULL; | 240 | return NULL; |
@@ -308,19 +308,18 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, | |||
308 | if (err) | 308 | if (err) |
309 | return err; | 309 | return err; |
310 | 310 | ||
311 | /* FIXME: check refcounting for get_main_thread, that calls machine__find_thread... */ | ||
312 | main_thread = get_main_thread(al->machine, thread); | 311 | main_thread = get_main_thread(al->machine, thread); |
313 | if (main_thread) | 312 | if (main_thread) |
314 | comm = machine__thread_exec_comm(al->machine, main_thread); | 313 | comm = machine__thread_exec_comm(al->machine, main_thread); |
315 | 314 | ||
316 | err = db_export__thread(dbe, thread, al->machine, comm); | 315 | err = db_export__thread(dbe, thread, al->machine, comm); |
317 | if (err) | 316 | if (err) |
318 | return err; | 317 | goto out_put; |
319 | 318 | ||
320 | if (comm) { | 319 | if (comm) { |
321 | err = db_export__comm(dbe, comm, main_thread); | 320 | err = db_export__comm(dbe, comm, main_thread); |
322 | if (err) | 321 | if (err) |
323 | return err; | 322 | goto out_put; |
324 | es.comm_db_id = comm->db_id; | 323 | es.comm_db_id = comm->db_id; |
325 | } | 324 | } |
326 | 325 | ||
@@ -328,7 +327,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, | |||
328 | 327 | ||
329 | err = db_ids_from_al(dbe, al, &es.dso_db_id, &es.sym_db_id, &es.offset); | 328 | err = db_ids_from_al(dbe, al, &es.dso_db_id, &es.sym_db_id, &es.offset); |
330 | if (err) | 329 | if (err) |
331 | return err; | 330 | goto out_put; |
332 | 331 | ||
333 | if ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) && | 332 | if ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) && |
334 | sample_addr_correlates_sym(&evsel->attr)) { | 333 | sample_addr_correlates_sym(&evsel->attr)) { |
@@ -338,20 +337,22 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, | |||
338 | err = db_ids_from_al(dbe, &addr_al, &es.addr_dso_db_id, | 337 | err = db_ids_from_al(dbe, &addr_al, &es.addr_dso_db_id, |
339 | &es.addr_sym_db_id, &es.addr_offset); | 338 | &es.addr_sym_db_id, &es.addr_offset); |
340 | if (err) | 339 | if (err) |
341 | return err; | 340 | goto out_put; |
342 | if (dbe->crp) { | 341 | if (dbe->crp) { |
343 | err = thread_stack__process(thread, comm, sample, al, | 342 | err = thread_stack__process(thread, comm, sample, al, |
344 | &addr_al, es.db_id, | 343 | &addr_al, es.db_id, |
345 | dbe->crp); | 344 | dbe->crp); |
346 | if (err) | 345 | if (err) |
347 | return err; | 346 | goto out_put; |
348 | } | 347 | } |
349 | } | 348 | } |
350 | 349 | ||
351 | if (dbe->export_sample) | 350 | if (dbe->export_sample) |
352 | return dbe->export_sample(dbe, &es); | 351 | err = dbe->export_sample(dbe, &es); |
353 | 352 | ||
354 | return 0; | 353 | out_put: |
354 | thread__put(main_thread); | ||
355 | return err; | ||
355 | } | 356 | } |
356 | 357 | ||
357 | static struct { | 358 | static struct { |