From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1949303AbcBTLeV (ORCPT ); Sat, 20 Feb 2016 06:34:21 -0500 Received: from terminus.zytor.com ([198.137.202.10]:38009 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932136AbcBTLeN (ORCPT ); Sat, 20 Feb 2016 06:34:13 -0500 Date: Sat, 20 Feb 2016 03:33:44 -0800 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: hpa@zytor.com, steven@uplinklabs.net, wangnan0@huawei.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, jolsa@kernel.org, dsahern@gmail.com, mingo@kernel.org, adrian.hunter@intel.com, namhyung@kernel.org, acme@redhat.com Reply-To: dsahern@gmail.com, adrian.hunter@intel.com, mingo@kernel.org, acme@redhat.com, namhyung@kernel.org, hpa@zytor.com, wangnan0@huawei.com, steven@uplinklabs.net, linux-kernel@vger.kernel.org, jolsa@kernel.org, tglx@linutronix.de To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf evlist: Reference count the cpu and thread maps at set_maps() Git-Commit-ID: a55e5663761366fb883f6f25375dd68bc958b9db X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a55e5663761366fb883f6f25375dd68bc958b9db Gitweb: http://git.kernel.org/tip/a55e5663761366fb883f6f25375dd68bc958b9db Author: Arnaldo Carvalho de Melo AuthorDate: Wed, 17 Feb 2016 10:57:19 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 18 Feb 2016 10:48:37 -0300 perf evlist: Reference count the cpu and thread maps at set_maps() 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 Report-Link: http://lkml.kernel.org/r/CAKbGBLjC2Dx5vshxyGmQkcD+VwiAQLbHoXA9i7kvRB2-2opHZQ@mail.gmail.com Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan 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 --- 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 d81f13d..a7eb0ea 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);