From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753203AbbIPHdg (ORCPT ); Wed, 16 Sep 2015 03:33:36 -0400 Received: from terminus.zytor.com ([198.137.202.10]:39485 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751739AbbIPHdd (ORCPT ); Wed, 16 Sep 2015 03:33:33 -0400 Date: Wed, 16 Sep 2015 00:33:22 -0700 From: tip-bot for Adrian Hunter Message-ID: Cc: kan.liang@intel.com, acme@redhat.com, hpa@zytor.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, mingo@kernel.org, tglx@linutronix.de, adrian.hunter@intel.com Reply-To: hpa@zytor.com, acme@redhat.com, kan.liang@intel.com, adrian.hunter@intel.com, tglx@linutronix.de, mingo@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <1441699142-18905-9-git-send-email-adrian.hunter@intel.com> References: <1441699142-18905-9-git-send-email-adrian.hunter@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf evlist: Make set_maps() more resilient Git-Commit-ID: 934e0f2053ce299893ca48a411bf7fdc8ac6254f 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: 934e0f2053ce299893ca48a411bf7fdc8ac6254f Gitweb: http://git.kernel.org/tip/934e0f2053ce299893ca48a411bf7fdc8ac6254f Author: Adrian Hunter AuthorDate: Tue, 8 Sep 2015 10:58:56 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 15 Sep 2015 10:44:22 -0300 perf evlist: Make set_maps() more resilient Make perf_evlist__set_maps() more resilient by allowing for the possibility that one or another of the maps isn't being changed and therefore should not be "put". Signed-off-by: Adrian Hunter Acked-by: Jiri Olsa Cc: Kan Liang Link: http://lkml.kernel.org/r/1441699142-18905-9-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evlist.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 5bd3b49..78ff52e 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1155,11 +1155,22 @@ out_delete_threads: void perf_evlist__set_maps(struct perf_evlist *evlist, struct cpu_map *cpus, struct thread_map *threads) { - cpu_map__put(evlist->cpus); - evlist->cpus = cpus; + /* + * Allow for the possibility that one or another of the maps isn't being + * changed i.e. don't put it. Note we are assuming the maps that are + * being applied are brand new and evlist is taking ownership of the + * original reference count of 1. If that is not the case it is up to + * the caller to increase the reference count. + */ + if (cpus != evlist->cpus) { + cpu_map__put(evlist->cpus); + evlist->cpus = cpus; + } - thread_map__put(evlist->threads); - evlist->threads = threads; + if (threads != evlist->threads) { + thread_map__put(evlist->threads); + evlist->threads = threads; + } perf_evlist__propagate_maps(evlist); }