linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>,
	David Ahern <dsahern@gmail.com>,
	Namhyung Kim <namhyung.kim@lge.com>
Subject: [PATCH 2/7] perf evlist: Use cpu_map__nr() helper
Date: Mon, 11 Mar 2013 16:43:13 +0900	[thread overview]
Message-ID: <1362987798-24969-2-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1362987798-24969-1-git-send-email-namhyung@kernel.org>

From: Namhyung Kim <namhyung.kim@lge.com>

Use the cpu_map__nr() helper to protect a possible NULL cpu map
dereference.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/evlist.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index a199f1887bef..a482547495b6 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -228,7 +228,7 @@ void perf_evlist__disable(struct perf_evlist *evlist)
 	int cpu, thread;
 	struct perf_evsel *pos;
 
-	for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
+	for (cpu = 0; cpu < cpu_map__nr(evlist->cpus); cpu++) {
 		list_for_each_entry(pos, &evlist->entries, node) {
 			if (!perf_evsel__is_group_leader(pos))
 				continue;
@@ -443,7 +443,7 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int m
 	struct perf_evsel *evsel;
 	int cpu, thread;
 
-	for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
+	for (cpu = 0; cpu < cpu_map__nr(evlist->cpus); cpu++) {
 		int output = -1;
 
 		for (thread = 0; thread < evlist->threads->nr; thread++) {
@@ -470,7 +470,7 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int m
 	return 0;
 
 out_unmap:
-	for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
+	for (cpu = 0; cpu < cpu_map__nr(evlist->cpus); cpu++) {
 		if (evlist->mmap[cpu].base != NULL) {
 			munmap(evlist->mmap[cpu].base, evlist->mmap_len);
 			evlist->mmap[cpu].base = NULL;
@@ -725,7 +725,7 @@ int perf_evlist__open(struct perf_evlist *evlist)
 
 	return 0;
 out_err:
-	ncpus = evlist->cpus ? evlist->cpus->nr : 1;
+	ncpus = cpu_map__nr(evlist->cpus);
 	nthreads = evlist->threads ? evlist->threads->nr : 1;
 
 	list_for_each_entry_reverse(evsel, &evlist->entries, node)
-- 
1.7.11.7


  reply	other threads:[~2013-03-11  7:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-11  7:43 [PATCH 1/7] perf evlist: Remove cpus and threads arguments from perf_evlist__new() Namhyung Kim
2013-03-11  7:43 ` Namhyung Kim [this message]
2013-03-21 11:05   ` [tip:perf/core] perf evlist: Use cpu_map__nr() helper tip-bot for Namhyung Kim
2013-03-11  7:43 ` [PATCH 3/7] perf evlist: Add thread_map__nr() helper Namhyung Kim
2013-03-21 11:07   ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-03-11  7:43 ` [PATCH 4/7] perf evlist: Pass struct perf_target to perf_evlist__prepare_workload() Namhyung Kim
2013-03-21 11:08   ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-03-11  7:43 ` [PATCH 5/7] perf evlist: Do not pass struct record_opts " Namhyung Kim
2013-03-21 11:09   ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-03-11  7:43 ` [PATCH 6/7] perf evlist: Add want_signal parameter " Namhyung Kim
2013-03-21 11:10   ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-03-11  7:43 ` [PATCH 7/7] perf stat: use perf_evlist__prepare/start_workload() Namhyung Kim
2013-03-21 11:11   ` [tip:perf/core] perf stat: Use perf_evlist__prepare/ start_workload() tip-bot for Namhyung Kim
2013-03-21 11:04 ` [tip:perf/core] perf evlist: Remove cpus and threads arguments from perf_evlist__new() tip-bot for Namhyung Kim

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=1362987798-24969-2-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=dsahern@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=paulus@samba.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).