Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1220572 > unrolled thread

[PATCH V3 00/14] perf tools: Fix gaps propagating maps

Started byAdrian Hunter <adrian.hunter@intel.com>
First post2015-09-08 10:10 +0200
Last post2015-09-16 09:40 +0200
Articles 13 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH V3 00/14] perf tools: Fix gaps propagating maps Adrian Hunter <adrian.hunter@intel.com> - 2015-09-08 10:10 +0200
    [PATCH V3 13/14] perf tools: Fix task exit test setting maps Adrian Hunter <adrian.hunter@intel.com> - 2015-09-08 10:10 +0200
      [tip:perf/core] perf tests: Fix task exit test setting maps tip-bot for Adrian Hunter <tipbot@zytor.com> - 2015-09-16 09:40 +0200
    [PATCH V3 01/14] perf tools: Simplify perf_evlist__propagate_maps logic Adrian Hunter <adrian.hunter@intel.com> - 2015-09-08 10:10 +0200
      [tip:perf/core] perf evlist: Simplify propagate_maps() logic tip-bot for Adrian Hunter <tipbot@zytor.com> - 2015-09-16 09:40 +0200
    [PATCH V3 12/14] perf tools: Fix perf_evlist__create_syswide_maps() not propagating maps Adrian Hunter <adrian.hunter@intel.com> - 2015-09-08 10:10 +0200
      [tip:perf/core] perf evlist: Fix create_syswide_maps()   not propagating maps tip-bot for Adrian Hunter <tipbot@zytor.com> - 2015-09-16 09:40 +0200
    [PATCH V3 09/14] perf tools: Make perf_evlist__create_maps() use perf_evlist__set_maps() Adrian Hunter <adrian.hunter@intel.com> - 2015-09-08 10:10 +0200
      [tip:perf/core] perf evlist: Make create_maps() use set_maps() tip-bot for Adrian Hunter <tipbot@zytor.com> - 2015-09-16 09:40 +0200
    [PATCH V3 08/14] perf tools: Make perf_evlist__set_maps() more resilient Adrian Hunter <adrian.hunter@intel.com> - 2015-09-08 10:10 +0200
      [tip:perf/core] perf evlist: Make set_maps() more resilient tip-bot for Adrian Hunter <tipbot@zytor.com> - 2015-09-16 09:40 +0200
    [PATCH V3 06/14] perf tools: Fix missing thread_map__put in perf_evlist__propagate_maps Adrian Hunter <adrian.hunter@intel.com> - 2015-09-08 10:10 +0200
      [tip:perf/core] perf evlist:   Fix missing thread_map__put in propagate_maps() tip-bot for Adrian Hunter <tipbot@zytor.com> - 2015-09-16 09:40 +0200

#1220572 — [PATCH V3 00/14] perf tools: Fix gaps propagating maps

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-09-08 10:10 +0200
Subject[PATCH V3 00/14] perf tools: Fix gaps propagating maps
Message-ID<q6m8y-6Rc-3@gated-at.bofh.it>
Hi

Here is V3 of "Fix gaps propagating maps" that fixes some problems
revealed by to d988d5ee6478 ("perf evlist: Open event on evsel cpus and threads")

Changes in V3:

	perf tools: Remove redundant validation from perf_evlist__propagate_maps
		perf_evlist__set_maps also doesn't need to return an error anymore

	perf tools: Add evlist->has_user_cpus
		Adjusted due to perf_evlist__set_maps change

	perf tools: Make perf_evlist__create_maps() use perf_evlist__set_maps()
		Adjusted due to perf_evlist__set_maps change

	perf tools: Fix perf_evlist__create_syswide_maps() not propagating maps
		Adjusted due to perf_evlist__set_maps change

	perf tools: Fix task exit test setting maps
		Adjusted due to perf_evlist__set_maps change

	perf tools: Fix software clock events test setting maps
		Adjusted due to perf_evlist__set_maps change


Changes in V2:
	Split into multiple patches
	Add evsel->own_cpus to identify evsels with their own cpu map
	And consequently don't need to unpropagate

	perf tools: Fix perf_evlist__splice_list_tail not setting evlist
		New patch

	perf tools: Fix task exit test setting maps
		New patch

	perf tools: Fix software clock events test setting maps
		New patch


Adrian Hunter (14):
      perf tools: Simplify perf_evlist__propagate_maps logic
      perf tools: Simplify perf_evlist__set_maps logic
      perf tools: Remove redundant validation from perf_evlist__propagate_maps
      perf tools: Add evlist->has_user_cpus
      perf tools: Fix perf_evlist__splice_list_tail not setting evlist
      perf tools: Fix missing thread_map__put in perf_evlist__propagate_maps
      perf tools: Add evsel->own_cpus
      perf tools: Make perf_evlist__set_maps() more resilient
      perf tools: Make perf_evlist__create_maps() use perf_evlist__set_maps()
      perf tools: Factor out a function to propagate maps for a single evsel
      perf tools: Fix perf_evlist__add() not propagating maps
      perf tools: Fix perf_evlist__create_syswide_maps() not propagating maps
      perf tools: Fix task exit test setting maps
      perf tools: Fix software clock events test setting maps

 tools/perf/tests/sw-clock.c    |  18 ++++--
 tools/perf/tests/task-exit.c   |  18 ++++--
 tools/perf/util/evlist.c       | 138 +++++++++++++++++++++++------------------
 tools/perf/util/evlist.h       |   9 ++-
 tools/perf/util/evsel.c        |   1 +
 tools/perf/util/evsel.h        |   1 +
 tools/perf/util/parse-events.c |   7 +--
 7 files changed, 113 insertions(+), 79 deletions(-)


Regards
Adrian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1220575 — [PATCH V3 13/14] perf tools: Fix task exit test setting maps

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-09-08 10:10 +0200
Subject[PATCH V3 13/14] perf tools: Fix task exit test setting maps
Message-ID<q6m8z-6Rc-53@gated-at.bofh.it>
In reply to#1220572
The test titled "Test number of exit event of a simple workload"
was setting cpu/thread maps directly.  Make it use the proper
function perf_evlist__set_maps() especially now that it also
propagates the maps.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/tests/task-exit.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index 3a8fedef83bc..add16385f13e 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -43,6 +43,8 @@ int test__task_exit(void)
 	};
 	const char *argv[] = { "true", NULL };
 	char sbuf[STRERR_BUFSIZE];
+	struct cpu_map *cpus;
+	struct thread_map *threads;
 
 	signal(SIGCHLD, sig_handler);
 
@@ -58,14 +60,19 @@ int test__task_exit(void)
 	 * perf_evlist__prepare_workload we'll fill in the only thread
 	 * we're monitoring, the one forked there.
 	 */
-	evlist->cpus = cpu_map__dummy_new();
-	evlist->threads = thread_map__new_by_tid(-1);
-	if (!evlist->cpus || !evlist->threads) {
+	cpus = cpu_map__dummy_new();
+	threads = thread_map__new_by_tid(-1);
+	if (!cpus || !threads) {
 		err = -ENOMEM;
 		pr_debug("Not enough memory to create thread/cpu maps\n");
-		goto out_delete_evlist;
+		goto out_free_maps;
 	}
 
+	perf_evlist__set_maps(evlist, cpus, threads);
+
+	cpus	= NULL;
+	threads = NULL;
+
 	err = perf_evlist__prepare_workload(evlist, &target, argv, false,
 					    workload_exec_failed_signal);
 	if (err < 0) {
@@ -114,6 +121,9 @@ retry:
 		err = -1;
 	}
 
+out_free_maps:
+	cpu_map__put(cpus);
+	thread_map__put(threads);
 out_delete_evlist:
 	perf_evlist__delete(evlist);
 	return err;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1225800 — [tip:perf/core] perf tests: Fix task exit test setting maps

Fromtip-bot for Adrian Hunter <tipbot@zytor.com>
Date2015-09-16 09:40 +0200
Subject[tip:perf/core] perf tests: Fix task exit test setting maps
Message-ID<q9ftV-6eY-61@gated-at.bofh.it>
In reply to#1220575
Commit-ID:  2998272275fc31fc3d478ef9c95e7eaef67dafa3
Gitweb:     http://git.kernel.org/tip/2998272275fc31fc3d478ef9c95e7eaef67dafa3
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Tue, 8 Sep 2015 10:59:01 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 15 Sep 2015 11:03:58 -0300

perf tests: Fix task exit test setting maps

The test titled "Test number of exit event of a simple workload" was
setting cpu/thread maps directly.  Make it use the proper function
perf_evlist__set_maps() especially now that it also propagates the maps.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/r/1441699142-18905-14-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/task-exit.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index 3a8fedef..add1638 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -43,6 +43,8 @@ int test__task_exit(void)
 	};
 	const char *argv[] = { "true", NULL };
 	char sbuf[STRERR_BUFSIZE];
+	struct cpu_map *cpus;
+	struct thread_map *threads;
 
 	signal(SIGCHLD, sig_handler);
 
@@ -58,14 +60,19 @@ int test__task_exit(void)
 	 * perf_evlist__prepare_workload we'll fill in the only thread
 	 * we're monitoring, the one forked there.
 	 */
-	evlist->cpus = cpu_map__dummy_new();
-	evlist->threads = thread_map__new_by_tid(-1);
-	if (!evlist->cpus || !evlist->threads) {
+	cpus = cpu_map__dummy_new();
+	threads = thread_map__new_by_tid(-1);
+	if (!cpus || !threads) {
 		err = -ENOMEM;
 		pr_debug("Not enough memory to create thread/cpu maps\n");
-		goto out_delete_evlist;
+		goto out_free_maps;
 	}
 
+	perf_evlist__set_maps(evlist, cpus, threads);
+
+	cpus	= NULL;
+	threads = NULL;
+
 	err = perf_evlist__prepare_workload(evlist, &target, argv, false,
 					    workload_exec_failed_signal);
 	if (err < 0) {
@@ -114,6 +121,9 @@ retry:
 		err = -1;
 	}
 
+out_free_maps:
+	cpu_map__put(cpus);
+	thread_map__put(threads);
 out_delete_evlist:
 	perf_evlist__delete(evlist);
 	return err;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1220576 — [PATCH V3 01/14] perf tools: Simplify perf_evlist__propagate_maps logic

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-09-08 10:10 +0200
Subject[PATCH V3 01/14] perf tools: Simplify perf_evlist__propagate_maps logic
Message-ID<q6m8A-6Rc-55@gated-at.bofh.it>
In reply to#1220572
If evsel->cpus is to be reassigned then the current value
must be "put", which works even if it is NULL.  Simplify
the current logic by moving the "put" next to the assignment.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/evlist.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d51a5200c8af..95e07ea3904c 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1113,11 +1113,10 @@ static int perf_evlist__propagate_maps(struct perf_evlist *evlist,
 		 * We already have cpus for evsel (via PMU sysfs) so
 		 * keep it, if there's no target cpu list defined.
 		 */
-		if (evsel->cpus && has_user_cpus)
+		if (!evsel->cpus || has_user_cpus) {
 			cpu_map__put(evsel->cpus);
-
-		if (!evsel->cpus || has_user_cpus)
 			evsel->cpus = cpu_map__get(evlist->cpus);
+		}
 
 		evsel->threads = thread_map__get(evlist->threads);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1225792 — [tip:perf/core] perf evlist: Simplify propagate_maps() logic

Fromtip-bot for Adrian Hunter <tipbot@zytor.com>
Date2015-09-16 09:40 +0200
Subject[tip:perf/core] perf evlist: Simplify propagate_maps() logic
Message-ID<q9ftV-6eY-45@gated-at.bofh.it>
In reply to#1220576
Commit-ID:  a69b09e2342a9c144b0291b9aeb849ab7d5843bf
Gitweb:     http://git.kernel.org/tip/a69b09e2342a9c144b0291b9aeb849ab7d5843bf
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Tue, 8 Sep 2015 10:58:49 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 15 Sep 2015 10:08:22 -0300

perf evlist: Simplify propagate_maps() logic

If evsel->cpus is to be reassigned then the current value must be "put",
which works even if it is NULL.  Simplify the current logic by moving
the "put" next to the assignment.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/r/1441699142-18905-2-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d51a520..95e07ea 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1113,11 +1113,10 @@ static int perf_evlist__propagate_maps(struct perf_evlist *evlist,
 		 * We already have cpus for evsel (via PMU sysfs) so
 		 * keep it, if there's no target cpu list defined.
 		 */
-		if (evsel->cpus && has_user_cpus)
+		if (!evsel->cpus || has_user_cpus) {
 			cpu_map__put(evsel->cpus);
-
-		if (!evsel->cpus || has_user_cpus)
 			evsel->cpus = cpu_map__get(evlist->cpus);
+		}
 
 		evsel->threads = thread_map__get(evlist->threads);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1220577 — [PATCH V3 12/14] perf tools: Fix perf_evlist__create_syswide_maps() not propagating maps

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-09-08 10:10 +0200
Subject[PATCH V3 12/14] perf tools: Fix perf_evlist__create_syswide_maps() not propagating maps
Message-ID<q6m8z-6Rc-51@gated-at.bofh.it>
In reply to#1220572
Fix it by making it call perf_evlist__set_maps() instead of
setting the maps itself.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/evlist.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 99267ab0d24a..c8fc8a258f42 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1400,6 +1400,8 @@ void perf_evlist__close(struct perf_evlist *evlist)
 
 static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist)
 {
+	struct cpu_map	  *cpus;
+	struct thread_map *threads;
 	int err = -ENOMEM;
 
 	/*
@@ -1411,20 +1413,19 @@ static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist)
 	 * error, and we may not want to do that fallback to a
 	 * default cpu identity map :-\
 	 */
-	evlist->cpus = cpu_map__new(NULL);
-	if (evlist->cpus == NULL)
+	cpus = cpu_map__new(NULL);
+	if (!cpus)
 		goto out;
 
-	evlist->threads = thread_map__new_dummy();
-	if (evlist->threads == NULL)
-		goto out_free_cpus;
+	threads = thread_map__new_dummy();
+	if (!threads)
+		goto out_put;
 
-	err = 0;
+	perf_evlist__set_maps(evlist, cpus, threads);
 out:
 	return err;
-out_free_cpus:
-	cpu_map__put(evlist->cpus);
-	evlist->cpus = NULL;
+out_put:
+	cpu_map__put(cpus);
 	goto out;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1225794 — [tip:perf/core] perf evlist: Fix create_syswide_maps() not propagating maps

Fromtip-bot for Adrian Hunter <tipbot@zytor.com>
Date2015-09-16 09:40 +0200
Subject[tip:perf/core] perf evlist: Fix create_syswide_maps() not propagating maps
Message-ID<q9ftV-6eY-51@gated-at.bofh.it>
In reply to#1220577
Commit-ID:  8c0498b6891d7ca5c379c6283de7fc7fe8eebe5c
Gitweb:     http://git.kernel.org/tip/8c0498b6891d7ca5c379c6283de7fc7fe8eebe5c
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Tue, 8 Sep 2015 10:59:00 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 15 Sep 2015 11:03:22 -0300

perf evlist: Fix create_syswide_maps() not propagating maps

Fix it by making it call perf_evlist__set_maps() instead of setting the
maps itself.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/r/1441699142-18905-13-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 99267ab..c8fc8a2 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1400,6 +1400,8 @@ void perf_evlist__close(struct perf_evlist *evlist)
 
 static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist)
 {
+	struct cpu_map	  *cpus;
+	struct thread_map *threads;
 	int err = -ENOMEM;
 
 	/*
@@ -1411,20 +1413,19 @@ static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist)
 	 * error, and we may not want to do that fallback to a
 	 * default cpu identity map :-\
 	 */
-	evlist->cpus = cpu_map__new(NULL);
-	if (evlist->cpus == NULL)
+	cpus = cpu_map__new(NULL);
+	if (!cpus)
 		goto out;
 
-	evlist->threads = thread_map__new_dummy();
-	if (evlist->threads == NULL)
-		goto out_free_cpus;
+	threads = thread_map__new_dummy();
+	if (!threads)
+		goto out_put;
 
-	err = 0;
+	perf_evlist__set_maps(evlist, cpus, threads);
 out:
 	return err;
-out_free_cpus:
-	cpu_map__put(evlist->cpus);
-	evlist->cpus = NULL;
+out_put:
+	cpu_map__put(cpus);
 	goto out;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1220578 — [PATCH V3 09/14] perf tools: Make perf_evlist__create_maps() use perf_evlist__set_maps()

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-09-08 10:10 +0200
Subject[PATCH V3 09/14] perf tools: Make perf_evlist__create_maps() use perf_evlist__set_maps()
Message-ID<q6m8A-6Rc-59@gated-at.bofh.it>
In reply to#1220572
Since there is a function to set maps, perf_evlist__create_maps()
should use it.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/evlist.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 78ff52ee8788..c17f3558a37a 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1126,29 +1126,30 @@ static void perf_evlist__propagate_maps(struct perf_evlist *evlist)
 
 int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
 {
-	evlist->threads = thread_map__new_str(target->pid, target->tid,
-					      target->uid);
+	struct cpu_map *cpus;
+	struct thread_map *threads;
 
-	if (evlist->threads == NULL)
+	threads = thread_map__new_str(target->pid, target->tid, target->uid);
+
+	if (!threads)
 		return -1;
 
 	if (target__uses_dummy_map(target))
-		evlist->cpus = cpu_map__dummy_new();
+		cpus = cpu_map__dummy_new();
 	else
-		evlist->cpus = cpu_map__new(target->cpu_list);
+		cpus = cpu_map__new(target->cpu_list);
 
-	if (evlist->cpus == NULL)
+	if (!cpus)
 		goto out_delete_threads;
 
 	evlist->has_user_cpus = !!target->cpu_list;
 
-	perf_evlist__propagate_maps(evlist);
+	perf_evlist__set_maps(evlist, cpus, threads);
 
 	return 0;
 
 out_delete_threads:
-	thread_map__put(evlist->threads);
-	evlist->threads = NULL;
+	thread_map__put(threads);
 	return -1;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1225787 — [tip:perf/core] perf evlist: Make create_maps() use set_maps()

Fromtip-bot for Adrian Hunter <tipbot@zytor.com>
Date2015-09-16 09:40 +0200
Subject[tip:perf/core] perf evlist: Make create_maps() use set_maps()
Message-ID<q9ftU-6eY-31@gated-at.bofh.it>
In reply to#1220578
Commit-ID:  74bfd2b25de354feb4484c553dce4fe8d9c3b60b
Gitweb:     http://git.kernel.org/tip/74bfd2b25de354feb4484c553dce4fe8d9c3b60b
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Tue, 8 Sep 2015 10:58:57 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 15 Sep 2015 10:45:47 -0300

perf evlist: Make create_maps() use set_maps()

Since there is a function to set maps, perf_evlist__create_maps() should
use it.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/r/1441699142-18905-10-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 78ff52e..c17f355 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1126,29 +1126,30 @@ static void perf_evlist__propagate_maps(struct perf_evlist *evlist)
 
 int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
 {
-	evlist->threads = thread_map__new_str(target->pid, target->tid,
-					      target->uid);
+	struct cpu_map *cpus;
+	struct thread_map *threads;
 
-	if (evlist->threads == NULL)
+	threads = thread_map__new_str(target->pid, target->tid, target->uid);
+
+	if (!threads)
 		return -1;
 
 	if (target__uses_dummy_map(target))
-		evlist->cpus = cpu_map__dummy_new();
+		cpus = cpu_map__dummy_new();
 	else
-		evlist->cpus = cpu_map__new(target->cpu_list);
+		cpus = cpu_map__new(target->cpu_list);
 
-	if (evlist->cpus == NULL)
+	if (!cpus)
 		goto out_delete_threads;
 
 	evlist->has_user_cpus = !!target->cpu_list;
 
-	perf_evlist__propagate_maps(evlist);
+	perf_evlist__set_maps(evlist, cpus, threads);
 
 	return 0;
 
 out_delete_threads:
-	thread_map__put(evlist->threads);
-	evlist->threads = NULL;
+	thread_map__put(threads);
 	return -1;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1220579 — [PATCH V3 08/14] perf tools: Make perf_evlist__set_maps() more resilient

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-09-08 10:10 +0200
Subject[PATCH V3 08/14] perf tools: Make perf_evlist__set_maps() more resilient
Message-ID<q6m8A-6Rc-61@gated-at.bofh.it>
In reply to#1220572
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 <adrian.hunter@intel.com>
---
 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 5bd3b49452c6..78ff52ee8788 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);
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1225783 — [tip:perf/core] perf evlist: Make set_maps() more resilient

Fromtip-bot for Adrian Hunter <tipbot@zytor.com>
Date2015-09-16 09:40 +0200
Subject[tip:perf/core] perf evlist: Make set_maps() more resilient
Message-ID<q9ftU-6eY-27@gated-at.bofh.it>
In reply to#1220579
Commit-ID:  934e0f2053ce299893ca48a411bf7fdc8ac6254f
Gitweb:     http://git.kernel.org/tip/934e0f2053ce299893ca48a411bf7fdc8ac6254f
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Tue, 8 Sep 2015 10:58:56 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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 <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/r/1441699142-18905-9-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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);
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1220580 — [PATCH V3 06/14] perf tools: Fix missing thread_map__put in perf_evlist__propagate_maps

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-09-08 10:10 +0200
Subject[PATCH V3 06/14] perf tools: Fix missing thread_map__put in perf_evlist__propagate_maps
Message-ID<q6m8B-6Rc-63@gated-at.bofh.it>
In reply to#1220572
perf_evlist__propagate_maps() incorrectly assumes evsel->threads
is NULL before reassigning it, but it won't be NULL when
perf_evlist__set_maps() is used to set different (or NULL) maps.
Thus thread_map__put must be used, which works even if
evsel->threads is NULL.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/evlist.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 961560b2046b..79056c6ae507 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1116,6 +1116,7 @@ static void perf_evlist__propagate_maps(struct perf_evlist *evlist)
 			evsel->cpus = cpu_map__get(evlist->cpus);
 		}
 
+		thread_map__put(evsel->threads);
 		evsel->threads = thread_map__get(evlist->threads);
 	}
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1225797 — [tip:perf/core] perf evlist: Fix missing thread_map__put in propagate_maps()

Fromtip-bot for Adrian Hunter <tipbot@zytor.com>
Date2015-09-16 09:40 +0200
Subject[tip:perf/core] perf evlist: Fix missing thread_map__put in propagate_maps()
Message-ID<q9ftV-6eY-53@gated-at.bofh.it>
In reply to#1220580
Commit-ID:  b278c364b35ae940b05f6a9edf8061fc886cd09e
Gitweb:     http://git.kernel.org/tip/b278c364b35ae940b05f6a9edf8061fc886cd09e
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Tue, 8 Sep 2015 10:58:54 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 15 Sep 2015 10:24:30 -0300

perf evlist: Fix missing thread_map__put in propagate_maps()

perf_evlist__propagate_maps() incorrectly assumes evsel->threads is NULL
before reassigning it, but it won't be NULL when perf_evlist__set_maps()
is used to set different (or NULL) maps.  Thus thread_map__put must be
used, which works even if evsel->threads is NULL.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/r/1441699142-18905-7-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 961560b..79056c6 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1116,6 +1116,7 @@ static void perf_evlist__propagate_maps(struct perf_evlist *evlist)
 			evsel->cpus = cpu_map__get(evlist->cpus);
 		}
 
+		thread_map__put(evsel->threads);
 		evsel->threads = thread_map__get(evlist->threads);
 	}
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web