From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752856AbcDNFn4 (ORCPT ); Thu, 14 Apr 2016 01:43:56 -0400 Received: from terminus.zytor.com ([198.137.202.10]:47512 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751491AbcDNFny (ORCPT ); Thu, 14 Apr 2016 01:43:54 -0400 Date: Wed, 13 Apr 2016 22:43:39 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: namhyung@kernel.org, hpa@zytor.com, mingo@kernel.org, a.p.zijlstra@chello.nl, tglx@linutronix.de, jolsa@kernel.org, acme@redhat.com, dsahern@gmail.com, linux-kernel@vger.kernel.org Reply-To: jolsa@kernel.org, acme@redhat.com, dsahern@gmail.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, hpa@zytor.com, mingo@kernel.org, a.p.zijlstra@chello.nl, tglx@linutronix.de In-Reply-To: <1460467771-26532-3-git-send-email-jolsa@kernel.org> References: <1460467771-26532-3-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf cpu_map: Add has() method Git-Commit-ID: e632aa69c919462a7f93c8799b97c8a9ddd48fc2 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: e632aa69c919462a7f93c8799b97c8a9ddd48fc2 Gitweb: http://git.kernel.org/tip/e632aa69c919462a7f93c8799b97c8a9ddd48fc2 Author: Jiri Olsa AuthorDate: Tue, 12 Apr 2016 15:29:25 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 13 Apr 2016 10:11:50 -0300 perf cpu_map: Add has() method Adding cpu_map__has() to return bool of cpu presence in cpus map. Signed-off-by: Jiri Olsa Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1460467771-26532-3-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cpumap.c | 12 ++++++++++++ tools/perf/util/cpumap.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 9bcf2be..02d8016 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -587,3 +587,15 @@ int cpu__setup_cpunode_map(void) closedir(dir1); return 0; } + +bool cpu_map__has(struct cpu_map *cpus, int cpu) +{ + int i; + + for (i = 0; i < cpus->nr; ++i) { + if (cpus->map[i] == cpu) + return true; + } + + return false; +} diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index 81a2562..1a0a350 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -66,4 +66,6 @@ int cpu__get_node(int cpu); int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res, int (*f)(struct cpu_map *map, int cpu, void *data), void *data); + +bool cpu_map__has(struct cpu_map *cpus, int cpu); #endif /* __PERF_CPUMAP_H */