* [PATCH] perf, sched: Do not delete session object prematurely
@ 2011-08-08 21:03 Jiri Olsa
2011-08-09 12:46 ` [PATCH] perf, sched: Usage leftover from trace -> script rename Jiri Olsa
2011-08-10 9:47 ` [tip:perf/urgent] perf sched: Do not delete session object prematurely tip-bot for Jiri Olsa
0 siblings, 2 replies; 4+ messages in thread
From: Jiri Olsa @ 2011-08-08 21:03 UTC (permalink / raw)
To: acme, a.p.zijlstra, mingo, paulus; +Cc: linux-kernel, Jiri Olsa
The session object is released prematurely when processing
events for latency command. The session's thread objects are
used within the output_lat_thread function.
Runnning following commands:
# perf sched record
# perf sched latency
the latter displays incorrect data and might cause access
violation.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
tools/perf/builtin-sched.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index dcfe887..3d5702c 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1637,23 +1637,29 @@ static struct perf_event_ops event_ops = {
.ordered_samples = true,
};
-static int read_events(void)
+static void read_events(bool destroy, struct perf_session **psession)
{
int err = -EINVAL;
struct perf_session *session = perf_session__new(input_name, O_RDONLY,
0, false, &event_ops);
if (session == NULL)
- return -ENOMEM;
+ die("No Memory");
if (perf_session__has_traces(session, "record -R")) {
err = perf_session__process_events(session, &event_ops);
+ if (err)
+ die("Failed to process events, error %d", err);
+
nr_events = session->hists.stats.nr_events[0];
nr_lost_events = session->hists.stats.total_lost;
nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST];
}
- perf_session__delete(session);
- return err;
+ if (destroy)
+ perf_session__delete(session);
+
+ if (psession)
+ *psession = session;
}
static void print_bad_events(void)
@@ -1689,9 +1695,10 @@ static void print_bad_events(void)
static void __cmd_lat(void)
{
struct rb_node *next;
+ struct perf_session *session;
setup_pager();
- read_events();
+ read_events(false, &session);
sort_lat();
printf("\n ---------------------------------------------------------------------------------------------------------------\n");
@@ -1717,6 +1724,7 @@ static void __cmd_lat(void)
print_bad_events();
printf("\n");
+ perf_session__delete(session);
}
static struct trace_sched_handler map_ops = {
@@ -1731,7 +1739,7 @@ static void __cmd_map(void)
max_cpu = sysconf(_SC_NPROCESSORS_CONF);
setup_pager();
- read_events();
+ read_events(true, NULL);
print_bad_events();
}
@@ -1744,7 +1752,7 @@ static void __cmd_replay(void)
test_calibrations();
- read_events();
+ read_events(true, NULL);
printf("nr_run_events: %ld\n", nr_run_events);
printf("nr_sleep_events: %ld\n", nr_sleep_events);
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] perf, sched: Usage leftover from trace -> script rename
2011-08-08 21:03 [PATCH] perf, sched: Do not delete session object prematurely Jiri Olsa
@ 2011-08-09 12:46 ` Jiri Olsa
2011-08-10 9:47 ` [tip:perf/urgent] perf " tip-bot for Jiri Olsa
2011-08-10 9:47 ` [tip:perf/urgent] perf sched: Do not delete session object prematurely tip-bot for Jiri Olsa
1 sibling, 1 reply; 4+ messages in thread
From: Jiri Olsa @ 2011-08-09 12:46 UTC (permalink / raw)
To: acme, a.p.zijlstra, mingo, paulus; +Cc: linux-kernel
and this oneline change depending on the previous one ;)
thanks,
jirka
---
The 'perf sched' command usage still showing 'trace'
command instead of the 'script' command.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
tools/perf/builtin-sched.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 3d5702c..5177964 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1777,7 +1777,7 @@ static void __cmd_replay(void)
static const char * const sched_usage[] = {
- "perf sched [<options>] {record|latency|map|replay|trace}",
+ "perf sched [<options>] {record|latency|map|replay|script}",
NULL
};
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [tip:perf/urgent] perf sched: Do not delete session object prematurely
2011-08-08 21:03 [PATCH] perf, sched: Do not delete session object prematurely Jiri Olsa
2011-08-09 12:46 ` [PATCH] perf, sched: Usage leftover from trace -> script rename Jiri Olsa
@ 2011-08-10 9:47 ` tip-bot for Jiri Olsa
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Jiri Olsa @ 2011-08-10 9:47 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, jolsa, tglx, mingo
Commit-ID: 4c09bafae37d870ab8efc50faeeb4855cb55b5b7
Gitweb: http://git.kernel.org/tip/4c09bafae37d870ab8efc50faeeb4855cb55b5b7
Author: Jiri Olsa <jolsa@redhat.com>
AuthorDate: Mon, 8 Aug 2011 23:03:34 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 9 Aug 2011 13:31:38 -0300
perf sched: Do not delete session object prematurely
The session object is released prematurely when processing events for
latency command. The session's thread objects are used within the
output_lat_thread function.
Runnning following commands:
# perf sched record
# perf sched latency
the latter displays incorrect data and might cause access violation.
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1312837414-3819-1-git-send-email-jolsa@redhat.com
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-sched.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index dcfe887..3d5702c 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1637,23 +1637,29 @@ static struct perf_event_ops event_ops = {
.ordered_samples = true,
};
-static int read_events(void)
+static void read_events(bool destroy, struct perf_session **psession)
{
int err = -EINVAL;
struct perf_session *session = perf_session__new(input_name, O_RDONLY,
0, false, &event_ops);
if (session == NULL)
- return -ENOMEM;
+ die("No Memory");
if (perf_session__has_traces(session, "record -R")) {
err = perf_session__process_events(session, &event_ops);
+ if (err)
+ die("Failed to process events, error %d", err);
+
nr_events = session->hists.stats.nr_events[0];
nr_lost_events = session->hists.stats.total_lost;
nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST];
}
- perf_session__delete(session);
- return err;
+ if (destroy)
+ perf_session__delete(session);
+
+ if (psession)
+ *psession = session;
}
static void print_bad_events(void)
@@ -1689,9 +1695,10 @@ static void print_bad_events(void)
static void __cmd_lat(void)
{
struct rb_node *next;
+ struct perf_session *session;
setup_pager();
- read_events();
+ read_events(false, &session);
sort_lat();
printf("\n ---------------------------------------------------------------------------------------------------------------\n");
@@ -1717,6 +1724,7 @@ static void __cmd_lat(void)
print_bad_events();
printf("\n");
+ perf_session__delete(session);
}
static struct trace_sched_handler map_ops = {
@@ -1731,7 +1739,7 @@ static void __cmd_map(void)
max_cpu = sysconf(_SC_NPROCESSORS_CONF);
setup_pager();
- read_events();
+ read_events(true, NULL);
print_bad_events();
}
@@ -1744,7 +1752,7 @@ static void __cmd_replay(void)
test_calibrations();
- read_events();
+ read_events(true, NULL);
printf("nr_run_events: %ld\n", nr_run_events);
printf("nr_sleep_events: %ld\n", nr_sleep_events);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [tip:perf/urgent] perf sched: Usage leftover from trace -> script rename
2011-08-09 12:46 ` [PATCH] perf, sched: Usage leftover from trace -> script rename Jiri Olsa
@ 2011-08-10 9:47 ` tip-bot for Jiri Olsa
0 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Jiri Olsa @ 2011-08-10 9:47 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, jolsa, tglx, mingo
Commit-ID: 580cabed88ebc631e740b16010f2fa6ba882652f
Gitweb: http://git.kernel.org/tip/580cabed88ebc631e740b16010f2fa6ba882652f
Author: Jiri Olsa <jolsa@redhat.com>
AuthorDate: Tue, 9 Aug 2011 14:46:51 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 9 Aug 2011 13:32:12 -0300
perf sched: Usage leftover from trace -> script rename
The 'perf sched' command usage still showing 'trace' command instead of
the 'script' command.
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20110809124651.GD2056@jolsa.brq.redhat.com
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-sched.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 3d5702c..5177964 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1777,7 +1777,7 @@ static void __cmd_replay(void)
static const char * const sched_usage[] = {
- "perf sched [<options>] {record|latency|map|replay|trace}",
+ "perf sched [<options>] {record|latency|map|replay|script}",
NULL
};
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-10 9:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-08 21:03 [PATCH] perf, sched: Do not delete session object prematurely Jiri Olsa
2011-08-09 12:46 ` [PATCH] perf, sched: Usage leftover from trace -> script rename Jiri Olsa
2011-08-10 9:47 ` [tip:perf/urgent] perf " tip-bot for Jiri Olsa
2011-08-10 9:47 ` [tip:perf/urgent] perf sched: Do not delete session object prematurely tip-bot for Jiri Olsa
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).