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, Jiri Olsa <jolsa@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 03/11] perf cpu_map: Add has() method
Date: Wed, 13 Apr 2016 11:43:09 -0300	[thread overview]
Message-ID: <1460558597-16895-4-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1460558597-16895-1-git-send-email-acme@kernel.org>

From: Jiri Olsa <jolsa@kernel.org>

Adding cpu_map__has() to return bool of cpu presence in cpus map.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460467771-26532-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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 9bcf2bed3a6d..02d801670f30 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 81a2562aaa2b..1a0a35073ce1 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 */
-- 
2.5.5

  parent reply	other threads:[~2016-04-13 14:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13 14:43 [GIT PULL 00/11] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-04-13 14:43 ` [PATCH 01/11] perf trace: Support callchains for --event too Arnaldo Carvalho de Melo
2016-04-13 14:43 ` [PATCH 02/11] perf thread_map: Add has() method Arnaldo Carvalho de Melo
2016-04-13 14:43 ` Arnaldo Carvalho de Melo [this message]
2016-04-13 14:43 ` [PATCH 04/11] perf sched: Add compact display option Arnaldo Carvalho de Melo
2016-04-13 14:43 ` [PATCH 05/11] perf sched: Use color_fprintf for output Arnaldo Carvalho de Melo
2016-04-13 14:43 ` [PATCH 06/11] perf thread_map: Make new_by_tid_str constructor public Arnaldo Carvalho de Melo
2016-04-13 14:43 ` [PATCH 07/11] perf sched map: Color given pids Arnaldo Carvalho de Melo
2016-04-13 14:43 ` [PATCH 08/11] perf sched map: Color given cpus Arnaldo Carvalho de Melo
2016-04-13 14:43 ` [PATCH 09/11] perf sched map: Display only " Arnaldo Carvalho de Melo
2016-04-13 14:43 ` [PATCH 10/11] perf evsel: Move some methods from session.[ch] to evsel.[ch] Arnaldo Carvalho de Melo
2016-04-13 14:43 ` [PATCH 11/11] perf trace: Do not accept --no-syscalls together with -e Arnaldo Carvalho de Melo
2016-04-13 18:28 ` [GIT PULL 00/11] 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=1460558597-16895-4-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /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).