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: <1432090115-902-2-git-send-email-namhyung@kernel.org>
Date:	Wed, 20 May 2015 11:48:34 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:	Ingo Molnar <mingo@...nel.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Jiri Olsa <jolsa@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>,
	David Ahern <dsahern@...il.com>
Subject: [PATCH 2/3] perf trace: Create struct thread for command line workload

When perf creates a new child to profile, the events are enabled on
exec().  And in this case, it doesn't synthesize any event for the
child since they'll be generated during exec().  But there's an window
between the enabling and the event generation.  This leads to some
early event not having a comm but pid (like ':15328').

Fix it by using perf_evlist__start_workload_ex() to create
corresponding thread at the same time.

Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
 tools/perf/builtin-trace.c |  4 +++-
 tools/perf/util/evlist.c   | 14 ++++++++++++++
 tools/perf/util/evlist.h   |  2 ++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index a05490d06374..e30d0ed1e60f 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2282,7 +2282,9 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
 		perf_evlist__enable(evlist);
 
 	if (forks)
-		perf_evlist__start_workload(evlist);
+		perf_evlist__start_workload_ex(evlist,
+					       perf_evlist__create_workload_thread,
+					       trace->host);
 
 	trace->multiple_threads = evlist->threads->map[0] == -1 ||
 				  evlist->threads->nr > 1 ||
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index bfe455ec673b..f84305915e47 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1516,6 +1516,20 @@ int perf_evlist__start_workload_ex(struct perf_evlist *evlist,
 	return ret;
 }
 
+int perf_evlist__create_workload_thread(struct perf_evlist *evlist, void *arg)
+{
+	struct machine *machine = arg;
+	int pid = evlist->workload.pid;
+	struct thread *thread;
+
+	thread = machine__findnew_thread(machine, pid, pid);
+	if (thread == NULL)
+		return -1;
+
+	thread__set_comm(thread, program_invocation_short_name, 0);
+	return 0;
+}
+
 int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event,
 			      struct perf_sample *sample)
 {
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 6212f036c134..a02b0f4ba4f9 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -126,6 +126,8 @@ int perf_evlist__start_workload(struct perf_evlist *evlist);
 typedef int (*workload_callback_t)(struct perf_evlist *evlist, void *arg);
 int perf_evlist__start_workload_ex(struct perf_evlist *evlist,
 				   workload_callback_t callback, void *arg);
+/* workload_callbacks */
+int perf_evlist__create_workload_thread(struct perf_evlist *evlist, void *arg);
 
 struct option;
 
-- 
2.4.0

--
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