linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH perf/urgent] perf tools: Fix crash on synthesizing the unit
@ 2018-11-12 13:00 Jiri Olsa
  2018-11-12 16:40 ` Arnaldo Carvalho de Melo
  2018-11-21 15:00 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  0 siblings, 2 replies; 3+ messages in thread
From: Jiri Olsa @ 2018-11-12 13:00 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Adam Lee, lkml, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
	Peter Zijlstra

Adam reported a record command crash for simple session like:
  $ perf record -e cpu-clock ls

with following backtrace:

  Program received signal SIGSEGV, Segmentation fault.
  3543            ev = event_update_event__new(size + 1, PERF_EVENT_UPDATE__UNIT, evsel->id[0]);
  (gdb) bt
  #0  perf_event__synthesize_event_update_unit
  #1  0x000000000051e469 in perf_event__synthesize_extra_attr
  #2  0x00000000004445cb in record__synthesize
  #3  0x0000000000444bc5 in __cmd_record
  ...

We synthesize an update event that needs to touch the evsel id array, which is
not defined at that time. Fixing this by forcing the id allocation for events
with their unit defined.

Reflecting possible read_format ID bit in the attr tests.

Cc: Adam Lee <leeadamrobert@gmail.com>
Reported-by: Yongxin Liu <yongxin.liu@outlook.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201477
Fixes: bfd8f72c2778 ("perf record: Synthesize unit/scale/... in event update")
Link: http://lkml.kernel.org/n/tip-hmt7oavo3w97btxl8sfq8n0i@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/tests/attr/base-record | 2 +-
 tools/perf/util/evsel.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/attr/base-record b/tools/perf/tests/attr/base-record
index 37940665f736..efd0157b9d22 100644
--- a/tools/perf/tests/attr/base-record
+++ b/tools/perf/tests/attr/base-record
@@ -9,7 +9,7 @@ size=112
 config=0
 sample_period=*
 sample_type=263
-read_format=0
+read_format=0|4
 disabled=1
 inherit=1
 pinned=0
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d37bb1566cd9..dbc0466db368 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1092,7 +1092,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
 		attr->exclude_user   = 1;
 	}
 
-	if (evsel->own_cpus)
+	if (evsel->own_cpus || evsel->unit)
 		evsel->attr.read_format |= PERF_FORMAT_ID;
 
 	/*
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH perf/urgent] perf tools: Fix crash on synthesizing the unit
  2018-11-12 13:00 [PATCH perf/urgent] perf tools: Fix crash on synthesizing the unit Jiri Olsa
@ 2018-11-12 16:40 ` Arnaldo Carvalho de Melo
  2018-11-21 15:00 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-11-12 16:40 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Adam Lee, lkml, Ingo Molnar, Namhyung Kim, Alexander Shishkin,
	Peter Zijlstra

Em Mon, Nov 12, 2018 at 02:00:12PM +0100, Jiri Olsa escreveu:
> Adam reported a record command crash for simple session like:
>   $ perf record -e cpu-clock ls

Thanks, tested, confirmed it fixes the problem, applied.

- Arnaldo
 
> with following backtrace:
> 
>   Program received signal SIGSEGV, Segmentation fault.
>   3543            ev = event_update_event__new(size + 1, PERF_EVENT_UPDATE__UNIT, evsel->id[0]);
>   (gdb) bt
>   #0  perf_event__synthesize_event_update_unit
>   #1  0x000000000051e469 in perf_event__synthesize_extra_attr
>   #2  0x00000000004445cb in record__synthesize
>   #3  0x0000000000444bc5 in __cmd_record
>   ...
> 
> We synthesize an update event that needs to touch the evsel id array, which is
> not defined at that time. Fixing this by forcing the id allocation for events
> with their unit defined.
> 
> Reflecting possible read_format ID bit in the attr tests.
> 
> Cc: Adam Lee <leeadamrobert@gmail.com>
> Reported-by: Yongxin Liu <yongxin.liu@outlook.com>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201477
> Fixes: bfd8f72c2778 ("perf record: Synthesize unit/scale/... in event update")
> Link: http://lkml.kernel.org/n/tip-hmt7oavo3w97btxl8sfq8n0i@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/tests/attr/base-record | 2 +-
>  tools/perf/util/evsel.c           | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/tests/attr/base-record b/tools/perf/tests/attr/base-record
> index 37940665f736..efd0157b9d22 100644
> --- a/tools/perf/tests/attr/base-record
> +++ b/tools/perf/tests/attr/base-record
> @@ -9,7 +9,7 @@ size=112
>  config=0
>  sample_period=*
>  sample_type=263
> -read_format=0
> +read_format=0|4
>  disabled=1
>  inherit=1
>  pinned=0
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index d37bb1566cd9..dbc0466db368 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1092,7 +1092,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
>  		attr->exclude_user   = 1;
>  	}
>  
> -	if (evsel->own_cpus)
> +	if (evsel->own_cpus || evsel->unit)
>  		evsel->attr.read_format |= PERF_FORMAT_ID;
>  
>  	/*
> -- 
> 2.17.2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perf/urgent] perf tools: Fix crash on synthesizing the unit
  2018-11-12 13:00 [PATCH perf/urgent] perf tools: Fix crash on synthesizing the unit Jiri Olsa
  2018-11-12 16:40 ` Arnaldo Carvalho de Melo
@ 2018-11-21 15:00 ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-11-21 15:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: yongxin.liu, linux-kernel, leeadamrobert, jolsa, mingo, hpa,
	acme, tglx, namhyung, alexander.shishkin, peterz

Commit-ID:  fb50c09e923870a358d68b0d58891bd145b8d7c7
Gitweb:     https://git.kernel.org/tip/fb50c09e923870a358d68b0d58891bd145b8d7c7
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 12 Nov 2018 14:00:12 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 12 Nov 2018 08:37:49 -0800

perf tools: Fix crash on synthesizing the unit

Adam reported a record command crash for simple session like:

  $ perf record -e cpu-clock ls

with following backtrace:

  Program received signal SIGSEGV, Segmentation fault.
  3543            ev = event_update_event__new(size + 1, PERF_EVENT_UPDATE__UNIT, evsel->id[0]);
  (gdb) bt
  #0  perf_event__synthesize_event_update_unit
  #1  0x000000000051e469 in perf_event__synthesize_extra_attr
  #2  0x00000000004445cb in record__synthesize
  #3  0x0000000000444bc5 in __cmd_record
  ...

We synthesize an update event that needs to touch the evsel id array,
which is not defined at that time. Fix this by forcing the id allocation
for events with their unit defined.

Reflecting possible read_format ID bit in the attr tests.

Reported-by: Yongxin Liu <yongxin.liu@outlook.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adam Lee <leeadamrobert@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201477
Fixes: bfd8f72c2778 ("perf record: Synthesize unit/scale/... in event update")
Link: http://lkml.kernel.org/r/20181112130012.5424-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/attr/base-record | 2 +-
 tools/perf/util/evsel.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/attr/base-record b/tools/perf/tests/attr/base-record
index 37940665f736..efd0157b9d22 100644
--- a/tools/perf/tests/attr/base-record
+++ b/tools/perf/tests/attr/base-record
@@ -9,7 +9,7 @@ size=112
 config=0
 sample_period=*
 sample_type=263
-read_format=0
+read_format=0|4
 disabled=1
 inherit=1
 pinned=0
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d37bb1566cd9..dbc0466db368 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1092,7 +1092,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
 		attr->exclude_user   = 1;
 	}
 
-	if (evsel->own_cpus)
+	if (evsel->own_cpus || evsel->unit)
 		evsel->attr.read_format |= PERF_FORMAT_ID;
 
 	/*

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-21 15:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-12 13:00 [PATCH perf/urgent] perf tools: Fix crash on synthesizing the unit Jiri Olsa
2018-11-12 16:40 ` Arnaldo Carvalho de Melo
2018-11-21 15:00 ` [tip:perf/urgent] " 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).