From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756912AbbJ2Jl1 (ORCPT ); Thu, 29 Oct 2015 05:41:27 -0400 Received: from terminus.zytor.com ([198.137.202.10]:56120 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756746AbbJ2JlX (ORCPT ); Thu, 29 Oct 2015 05:41:23 -0400 Date: Thu, 29 Oct 2015 02:41:05 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: acme@redhat.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, jolsa@kernel.org, a.p.zijlstra@chello.nl, hpa@zytor.com, namhyung@kernel.org, kan.liang@intel.com, mingo@kernel.org Reply-To: acme@redhat.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, tglx@linutronix.de, a.p.zijlstra@chello.nl, hpa@zytor.com, mingo@kernel.org, kan.liang@intel.com, namhyung@kernel.org In-Reply-To: <1445784728-21732-2-git-send-email-jolsa@kernel.org> References: <1445784728-21732-2-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf cpu_map: Add cpu_map__empty_new function Git-Commit-ID: 2322f573f8131da9c6d1fab01fe0a0c2c23aa549 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: 2322f573f8131da9c6d1fab01fe0a0c2c23aa549 Gitweb: http://git.kernel.org/tip/2322f573f8131da9c6d1fab01fe0a0c2c23aa549 Author: Jiri Olsa AuthorDate: Sun, 25 Oct 2015 15:51:17 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 27 Oct 2015 15:05:36 -0300 perf cpu_map: Add cpu_map__empty_new function Adding cpu_map__empty_new interface to create empty cpumap with given size. The cpumap entries are initialized with -1. It'll be used for caching cpu_map in following patches. Signed-off-by: Jiri Olsa Tested-by: Kan Liang Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1445784728-21732-2-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cpumap.c | 17 +++++++++++++++++ tools/perf/util/cpumap.h | 1 + 2 files changed, 18 insertions(+) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index aa6b490..10af1e7 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -203,6 +203,23 @@ struct cpu_map *cpu_map__dummy_new(void) return cpus; } +struct cpu_map *cpu_map__empty_new(int nr) +{ + struct cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int) * nr); + + if (cpus != NULL) { + int i; + + cpus->nr = nr; + for (i = 0; i < nr; i++) + cpus->map[i] = -1; + + atomic_set(&cpus->refcnt, 1); + } + + return cpus; +} + static void cpu_map__delete(struct cpu_map *map) { if (map) { diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index f1bcd2c..85f7772 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -15,6 +15,7 @@ struct cpu_map { }; struct cpu_map *cpu_map__new(const char *cpu_list); +struct cpu_map *cpu_map__empty_new(int nr); struct cpu_map *cpu_map__dummy_new(void); struct cpu_map *cpu_map__read(FILE *file); size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp);