linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 01/22] perf evlist: Reference count the cpu and thread maps at set_maps()
Date: Fri, 19 Feb 2016 19:41:15 -0300	[thread overview]
Message-ID: <1455921696-3895-2-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1455921696-3895-1-git-send-email-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

We were dropping the reference we possibly held but not obtaining one
for the new maps, which we will drop at perf_evlist__delete(), fix it.

This was caught by Steven Noonan in some of the machines which would
produce this output when caught by glibc debug mechanisms:

  $ sudo perf test 21
  21: Test object code reading                                 :***
  Error in `perf': corrupted double-linked list: 0x00000000023ffcd0 ***
  ======= Backtrace: =========
  /usr/lib/libc.so.6(+0x72055)[0x7f25be0f3055]
  /usr/lib/libc.so.6(+0x779b6)[0x7f25be0f89b6]
  /usr/lib/libc.so.6(+0x7a0ed)[0x7f25be0fb0ed]
  /usr/lib/libc.so.6(__libc_calloc+0xba)[0x7f25be0fceda]
  perf(parse_events_lex_init_extra+0x38)[0x4cfff8]
  perf(parse_events+0x55)[0x4a0615]
  perf(perf_evlist__config+0xcf)[0x4eeb2f]
  perf[0x479f82]
  perf(test__code_reading+0x1e)[0x47ad4e]
  perf(cmd_test+0x5dd)[0x46452d]
  perf[0x47f4e3]
  perf(main+0x603)[0x42c723]
  /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f25be0a1610]
  perf(_start+0x29)[0x42c859]

Further investigation using valgrind led to the reference count imbalance fixed
in this patch.

Reported-and-Tested-by: Steven Noonan <steven@uplinklabs.net>
Report-Link: http://lkml.kernel.org/r/CAKbGBLjC2Dx5vshxyGmQkcD+VwiAQLbHoXA9i7kvRB2-2opHZQ@mail.gmail.com
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: f30a79b012e5 ("perf tools: Add reference counting for cpu_map object")
Link: http://lkml.kernel.org/n/tip-j0u1bdhr47sa511sgg76kb8h@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d81f13de2476..a7eb0eae9938 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1181,12 +1181,12 @@ void perf_evlist__set_maps(struct perf_evlist *evlist, struct cpu_map *cpus,
 	 */
 	if (cpus != evlist->cpus) {
 		cpu_map__put(evlist->cpus);
-		evlist->cpus = cpus;
+		evlist->cpus = cpu_map__get(cpus);
 	}
 
 	if (threads != evlist->threads) {
 		thread_map__put(evlist->threads);
-		evlist->threads = threads;
+		evlist->threads = thread_map__get(threads);
 	}
 
 	perf_evlist__propagate_maps(evlist);
-- 
2.5.0

  reply	other threads:[~2016-02-19 22:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-19 22:41 [GIT PULL 00/22] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-02-19 22:41 ` Arnaldo Carvalho de Melo [this message]
2016-02-19 22:41 ` [PATCH 02/22] perf record: Add --all-user/--all-kernel options Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 03/22] perf evlist: Handle -EINVAL for sample_freq > max_sample_rate in strerror_open() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 04/22] perf tests: Use perf_evlist__strerror_open() to provide hints about max_freq Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 05/22] perf test: Reduce the sample_freq for the 'object code reading' test Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 06/22] perf stat: Handled scaled == -1 case for counters Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 07/22] perf bpf: Rename bpf_prog_priv__clear() to clear_prog_priv() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 08/22] perf tools: Fix checking asprintf return value Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 09/22] perf tools: Create config_term_names array Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 10/22] perf stat: Bail out on unsupported event config modifiers Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 11/22] perf tools: Rename and move pmu_event_name to get_config_name Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 12/22] perf tools: Introduce opt_event_config nonterminal Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 13/22] perf tools: Enable config raw and numeric events Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 14/22] perf tools: Enable config and setting names for legacy cache events Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 15/22] perf hists browser: Fix percentage update on key press Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 16/22] perf callchain: Check return value of add_child() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 17/22] perf callchain: Check return value of fill_node() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 18/22] perf callchain: Add enum match_result for match_chain() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 19/22] perf callchain: Check return value of split_add_child() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 20/22] perf callchain: Check return value of append_chain_children() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 21/22] perf hists: Return error from hists__collapse_resort() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 22/22] perf report: Check error during report__collapse_hists() Arnaldo Carvalho de Melo
2016-02-20 10:56 ` [GIT PULL 00/22] 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=1455921696-3895-2-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@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).