All of lore.kernel.org
 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,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Borislav Petkov <bp@suse.de>, David Ahern <dsahern@gmail.com>,
	Don Zickus <dzickus@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jean Pihet <jean.pihet@linaro.org>, Jiri Olsa <jolsa@redhat.com>,
	Mike Galbraith <efault@gmx.de>,
	Namhyung Kim <namhyung@kernel.org>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>
Subject: [PATCH 02/25] perf tools: Set thread->mg.machine in all places
Date: Wed, 29 Oct 2014 12:06:14 -0200	[thread overview]
Message-ID: <1414591597-2763-3-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1414591597-2763-1-git-send-email-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

We were setting this only in machine__init(), i.e. for the map_groups that
holds the kernel module maps, not for the one used for a thread's executable
mmaps.

Now we are sure that we can obtain the machine where a thread is by going
via thread->mg->machine, thus we can, in the following patch, make all
codepaths that receive machine _and_ thread, drop the machine one.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-y6zgaqsvhrf04v57u15e4ybm@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/machine.c | 5 ++---
 tools/perf/util/map.c     | 8 ++++----
 tools/perf/util/map.h     | 4 ++--
 tools/perf/util/thread.c  | 2 +-
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 34fc7c8672e4..c70b3ff7b289 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -21,7 +21,7 @@ static void dsos__init(struct dsos *dsos)
 
 int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 {
-	map_groups__init(&machine->kmaps);
+	map_groups__init(&machine->kmaps, machine);
 	RB_CLEAR_NODE(&machine->rb_node);
 	dsos__init(&machine->user_dsos);
 	dsos__init(&machine->kernel_dsos);
@@ -32,7 +32,6 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 
 	machine->vdso_info = NULL;
 
-	machine->kmaps.machine = machine;
 	machine->pid = pid;
 
 	machine->symbol_filter = NULL;
@@ -319,7 +318,7 @@ static void machine__update_thread_pid(struct machine *machine,
 		goto out_err;
 
 	if (!leader->mg)
-		leader->mg = map_groups__new();
+		leader->mg = map_groups__new(machine);
 
 	if (!leader->mg)
 		goto out_err;
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 2137c4596ec7..040a785c857b 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -413,14 +413,14 @@ u64 map__objdump_2mem(struct map *map, u64 ip)
 	return ip + map->reloc;
 }
 
-void map_groups__init(struct map_groups *mg)
+void map_groups__init(struct map_groups *mg, struct machine *machine)
 {
 	int i;
 	for (i = 0; i < MAP__NR_TYPES; ++i) {
 		mg->maps[i] = RB_ROOT;
 		INIT_LIST_HEAD(&mg->removed_maps[i]);
 	}
-	mg->machine = NULL;
+	mg->machine = machine;
 	mg->refcnt = 1;
 }
 
@@ -471,12 +471,12 @@ bool map_groups__empty(struct map_groups *mg)
 	return true;
 }
 
-struct map_groups *map_groups__new(void)
+struct map_groups *map_groups__new(struct machine *machine)
 {
 	struct map_groups *mg = malloc(sizeof(*mg));
 
 	if (mg != NULL)
-		map_groups__init(mg);
+		map_groups__init(mg, machine);
 
 	return mg;
 }
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 2f83954af050..6951a9d42339 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -64,7 +64,7 @@ struct map_groups {
 	int		 refcnt;
 };
 
-struct map_groups *map_groups__new(void);
+struct map_groups *map_groups__new(struct machine *machine);
 void map_groups__delete(struct map_groups *mg);
 bool map_groups__empty(struct map_groups *mg);
 
@@ -150,7 +150,7 @@ void maps__remove(struct rb_root *maps, struct map *map);
 struct map *maps__find(struct rb_root *maps, u64 addr);
 struct map *maps__first(struct rb_root *maps);
 struct map *maps__next(struct map *map);
-void map_groups__init(struct map_groups *mg);
+void map_groups__init(struct map_groups *mg, struct machine *machine);
 void map_groups__exit(struct map_groups *mg);
 int map_groups__clone(struct map_groups *mg,
 		      struct map_groups *parent, enum map_type type);
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index c41411726c7a..8db9626f6835 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -15,7 +15,7 @@ int thread__init_map_groups(struct thread *thread, struct machine *machine)
 	pid_t pid = thread->pid_;
 
 	if (pid == thread->tid || pid == -1) {
-		thread->mg = map_groups__new();
+		thread->mg = map_groups__new(machine);
 	} else {
 		leader = machine__findnew_thread(machine, pid, pid);
 		if (leader)
-- 
1.9.3


  parent reply	other threads:[~2014-10-29 14:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-29 14:06 [GIT PULL 00/25] perf/core improvements Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 01/25] perf tools powerpc: Cache the DWARF debug info Arnaldo Carvalho de Melo
2014-10-29 14:06 ` Arnaldo Carvalho de Melo [this message]
2014-10-29 14:06 ` [PATCH 03/25] perf tools: A thread's machine can be found via thread->mg->machine Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 04/25] perf thread: Adopt resolve_callchain method from machine Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 05/25] perf callchains: Use thread->mg->machine Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 06/25] perf tests: Remove misplaced __maybe_unused Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 07/25] perf tests: Use thread->mg->machine Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 08/25] perf tools: Add PARSE_OPT_DISABLED flag Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 09/25] perf tools: Export usage string and option table of perf record Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 10/25] perf kvm: Print kvm specific --help output Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 11/25] perf tools: Add support for exclusive option Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 12/25] perf probe: Use PARSE_OPT_EXCLUSIVE flag Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 13/25] perf tools: Ensure return negative value when write header error Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 14/25] perf pmu: Let pmu's with no events show up on perf list Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 15/25] perf tools: Build programs to copy 32-bit compatibility Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 16/25] perf tools: Add support for 32-bit compatibility VDSOs Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 17/25] perf tools: Do not attempt to run perf-read-vdso32 if it wasn't built Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 18/25] perf pmu: Add proper error handling to print_pmu_events() Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 19/25] perf tools: Add facility to export data in database-friendly way Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 20/25] perf scripting python: Extend interface to export data in a " Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 21/25] perf script: Add Python script to export to postgresql Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 22/25] perf probe: Add --quiet option to suppress output result message Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 23/25] perf tools: Add id index Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 24/25] perf tools: Use evlist__for_each in a few remaining places Arnaldo Carvalho de Melo
2014-10-29 14:06 ` [PATCH 25/25] perf session: Add perf_session__deliver_synth_event() Arnaldo Carvalho de Melo
2014-10-30  6:35 ` [GIT PULL 00/25] perf/core improvements 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=1414591597-2763-3-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=bp@suse.de \
    --cc=dsahern@gmail.com \
    --cc=dzickus@redhat.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jean.pihet@linaro.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.