lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1386765443-26966-16-git-send-email-alexander.shishkin@linux.intel.com>
Date:	Wed, 11 Dec 2013 14:36:27 +0200
From:	Alexander Shishkin <alexander.shishkin@...ux.intel.com>
To:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc:	Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
	David Ahern <dsahern@...il.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Jiri Olsa <jolsa@...hat.com>, Mike Galbraith <efault@....de>,
	Namhyung Kim <namhyung@...il.com>,
	Paul Mackerras <paulus@...ba.org>,
	Stephane Eranian <eranian@...gle.com>,
	Andi Kleen <ak@...ux.intel.com>,
	Adrian Hunter <adrian.hunter@...el.com>
Subject: [PATCH v0 15/71] perf tools: Add ability to record the current tid for each cpu

From: Adrian Hunter <adrian.hunter@...el.com>

Add an array to struct machine to store
the current tid running on each cpu.
Add machine functions to get / set
the tid for a cpu.

This will be used to determine the tid
when decoding a per-cpu Instruction Trace.

Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
---
 tools/perf/util/machine.c | 39 +++++++++++++++++++++++++++++++++++++++
 tools/perf/util/machine.h |  4 ++++
 2 files changed, 43 insertions(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 52fbfb6..a04210d 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -43,6 +43,8 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 		thread__set_comm(thread, comm, 0);
 	}
 
+	machine->current_tid = NULL;
+
 	return 0;
 }
 
@@ -103,6 +105,8 @@ void machine__exit(struct machine *machine)
 	dsos__delete(&machine->kernel_dsos);
 	free(machine->root_dir);
 	machine->root_dir = NULL;
+	free(machine->current_tid);
+	machine->current_tid = NULL;
 }
 
 void machine__delete(struct machine *machine)
@@ -1438,3 +1442,38 @@ int machine__set_thread_cpu(struct machine *machine, pid_t pid, pid_t tid,
 
 	return 0;
 }
+
+pid_t machine__get_current_tid(struct machine *machine, int cpu)
+{
+	if (cpu < 0 || cpu >= MAX_NR_CPUS || !machine->current_tid)
+		return -1;
+
+	return machine->current_tid[cpu];
+}
+
+int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
+			     pid_t tid)
+{
+	if (cpu < 0)
+		return -EINVAL;
+
+	if (!machine->current_tid) {
+		int i;
+
+		machine->current_tid = calloc(MAX_NR_CPUS, sizeof(pid_t));
+		if (!machine->current_tid)
+			return -ENOMEM;
+		for (i = 0; i < MAX_NR_CPUS; i++)
+			machine->current_tid[i] = -1;
+	}
+
+	if (cpu >= MAX_NR_CPUS) {
+		pr_err("Requested CPU %d too large. ", cpu);
+		pr_err("Consider raising MAX_NR_CPUS\n");
+		return -EINVAL;
+	}
+
+	machine->current_tid[cpu] = tid;
+
+	return machine__set_thread_cpu(machine, pid, tid, cpu);
+}
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 27486af..aaad99a 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -31,6 +31,7 @@ struct machine {
 	struct map_groups kmaps;
 	struct map	  *vmlinux_maps[MAP__NR_TYPES];
 	symbol_filter_t	  symbol_filter;
+	pid_t		  *current_tid;
 };
 
 static inline
@@ -194,5 +195,8 @@ pid_t machine__get_thread_pid(struct machine *machine, pid_t tid);
 int machine__get_thread_cpu(struct machine *machine, pid_t tid, pid_t *pid);
 int machine__set_thread_cpu(struct machine *machine, pid_t pid, pid_t tid,
 			    int cpu);
+pid_t machine__get_current_tid(struct machine *machine, int cpu);
+int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
+			     pid_t tid);
 
 #endif /* __PERF_MACHINE_H */
-- 
1.8.5.1

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ