linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8
@ 2020-06-29  9:19 Adrian Hunter
  2020-06-29  9:19 ` [PATCH 1/6] perf scripts python: export-to-postgresql.py: Fix struct.pack() int argument Adrian Hunter
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Adrian Hunter @ 2020-06-29  9:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

Hi

Here are some Intel PT related fixes for v5.8.


Adrian Hunter (6):
      perf scripts python: export-to-postgresql.py: Fix struct.pack() int argument
      perf record: Fix duplicated sideband events with Intel PT system wide tracing
      perf scripts python: exported-sql-viewer.py: Fix unexpanded 'Find' result
      perf scripts python: exported-sql-viewer.py: Fix zero id in call graph 'Find' result
      perf scripts python: exported-sql-viewer.py: Fix zero id in call tree 'Find' result
      perf scripts python: exported-sql-viewer.py: Fix time chart call tree

 tools/perf/builtin-record.c                       | 18 +++++++++---------
 tools/perf/scripts/python/export-to-postgresql.py |  2 +-
 tools/perf/scripts/python/exported-sql-viewer.py  | 11 +++++++++--
 tools/perf/util/evlist.c                          | 12 ++++++++++++
 tools/perf/util/evlist.h                          |  1 +
 tools/perf/util/evsel.c                           |  8 +-------
 tools/perf/util/evsel.h                           |  6 ++++++
 7 files changed, 39 insertions(+), 19 deletions(-)


Regards
Adrian

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

* [PATCH 1/6] perf scripts python: export-to-postgresql.py: Fix struct.pack() int argument
  2020-06-29  9:19 [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8 Adrian Hunter
@ 2020-06-29  9:19 ` Adrian Hunter
  2020-06-29  9:19 ` [PATCH 2/6] perf record: Fix duplicated sideband events with Intel PT system wide tracing Adrian Hunter
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Adrian Hunter @ 2020-06-29  9:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

Python 3.8 is requiring that arguments being packed as integers are
also integers.  Add int() accordingly.

 Before:

   $ perf record -e intel_pt//u uname
   $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-postgresql.py perf_data_db branches calls
   2020-06-25 16:09:10.547256 Creating database...
   2020-06-25 16:09:10.733185 Writing to intermediate files...
   Traceback (most recent call last):
     File "/home/ahunter/libexec/perf-core/scripts/python/export-to-postgresql.py", line 1106, in synth_data
       cbr(id, raw_buf)
     File "/home/ahunter/libexec/perf-core/scripts/python/export-to-postgresql.py", line 1058, in cbr
       value = struct.pack("!hiqiiiiii", 4, 8, id, 4, cbr, 4, MHz, 4, percent)
   struct.error: required argument is not an integer
   Fatal Python error: problem in Python trace event handler
   Python runtime state: initialized

   Current thread 0x00007f35d3695780 (most recent call first):
   <no Python frame>
   Aborted (core dumped)

 After:

   $ dropdb perf_data_db
   $ rm -rf perf_data_db-perf-data
   $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-postgresql.py perf_data_db branches calls
   2020-06-25 16:09:40.990267 Creating database...
   2020-06-25 16:09:41.207009 Writing to intermediate files...
   2020-06-25 16:09:41.270915 Copying to database...
   2020-06-25 16:09:41.382030 Removing intermediate files...
   2020-06-25 16:09:41.384630 Adding primary keys
   2020-06-25 16:09:41.541894 Adding foreign keys
   2020-06-25 16:09:41.677044 Dropping unused tables
   2020-06-25 16:09:41.703761 Done

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: aba44287a224 ("perf scripts python: export-to-postgresql.py: Export Intel PT power and ptwrite events")
Cc: stable@vger.kernel.org
---
 tools/perf/scripts/python/export-to-postgresql.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/scripts/python/export-to-postgresql.py b/tools/perf/scripts/python/export-to-postgresql.py
index 7bd73a904b4e..d187e46c2683 100644
--- a/tools/perf/scripts/python/export-to-postgresql.py
+++ b/tools/perf/scripts/python/export-to-postgresql.py
@@ -1055,7 +1055,7 @@ def cbr(id, raw_buf):
 	cbr = data[0]
 	MHz = (data[4] + 500) / 1000
 	percent = ((cbr * 1000 / data[2]) + 5) / 10
-	value = struct.pack("!hiqiiiiii", 4, 8, id, 4, cbr, 4, MHz, 4, percent)
+	value = struct.pack("!hiqiiiiii", 4, 8, id, 4, cbr, 4, int(MHz), 4, int(percent))
 	cbr_file.write(value)
 
 def mwait(id, raw_buf):
-- 
2.17.1


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

* [PATCH 2/6] perf record: Fix duplicated sideband events with Intel PT system wide tracing
  2020-06-29  9:19 [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8 Adrian Hunter
  2020-06-29  9:19 ` [PATCH 1/6] perf scripts python: export-to-postgresql.py: Fix struct.pack() int argument Adrian Hunter
@ 2020-06-29  9:19 ` Adrian Hunter
  2020-06-29  9:19 ` [PATCH 3/6] perf scripts python: exported-sql-viewer.py: Fix unexpanded 'Find' result Adrian Hunter
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Adrian Hunter @ 2020-06-29  9:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

Commit 0a892c1c9472 ("perf record: Add dummy event during system wide
synthesis") reveals an issue with Intel PT system wide tracing.
Specifically that Intel PT already adds a dummy tracking event, and it is
not the first event.  Adding another dummy tracking event causes duplicated
sideband events.  Fix by checking for an existing dummy tracking event
first.

Example showing duplicated switch events:

 Before:

   # perf record -a -e intel_pt//u uname
   Linux
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.895 MB perf.data ]
   # perf script --no-itrace --show-switch-events | head
            swapper     0 [007]  6390.516222: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:    11/11
            swapper     0 [007]  6390.516222: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:    11/11
          rcu_sched    11 [007]  6390.516223: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
          rcu_sched    11 [007]  6390.516224: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
          rcu_sched    11 [007]  6390.516227: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
          rcu_sched    11 [007]  6390.516227: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
            swapper     0 [007]  6390.516228: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:    11/11
            swapper     0 [007]  6390.516228: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:    11/11
            swapper     0 [002]  6390.516415: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:  5556/5559
            swapper     0 [002]  6390.516416: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:  5556/5559

 After:

   # perf record -a -e intel_pt//u uname
   Linux
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.868 MB perf.data ]
   #  perf script --no-itrace --show-switch-events | head
            swapper     0 [005]  6450.567013: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:  7179/7181
               perf  7181 [005]  6450.567014: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
               perf  7181 [005]  6450.567028: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
            swapper     0 [005]  6450.567029: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:  7179/7181
            swapper     0 [005]  6450.571699: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:    11/11
          rcu_sched    11 [005]  6450.571700: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
          rcu_sched    11 [005]  6450.571702: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
            swapper     0 [005]  6450.571703: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:    11/11
            swapper     0 [005]  6450.579703: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:    11/11
          rcu_sched    11 [005]  6450.579704: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/builtin-record.c | 18 +++++++++---------
 tools/perf/util/evlist.c    | 12 ++++++++++++
 tools/perf/util/evlist.h    |  1 +
 tools/perf/util/evsel.c     |  8 +-------
 tools/perf/util/evsel.h     |  6 ++++++
 5 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e108d90ae2ed..a37e7910e9e9 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -852,20 +852,20 @@ static int record__open(struct record *rec)
 	 * event synthesis.
 	 */
 	if (opts->initial_delay || target__has_cpu(&opts->target)) {
-		if (perf_evlist__add_dummy(evlist))
-			return -ENOMEM;
+		pos = perf_evlist__get_tracking_event(evlist);
+		if (!evsel__is_dummy_event(pos)) {
+			/* Set up dummy event. */
+			if (perf_evlist__add_dummy(evlist))
+				return -ENOMEM;
+			pos = evlist__last(evlist);
+			perf_evlist__set_tracking_event(evlist, pos);
+		}
 
-		/* Disable tracking of mmaps on lead event. */
-		pos = evlist__first(evlist);
-		pos->tracking = 0;
-		/* Set up dummy event. */
-		pos = evlist__last(evlist);
-		pos->tracking = 1;
 		/*
 		 * Enable the dummy event when the process is forked for
 		 * initial_delay, immediately for system wide.
 		 */
-		if (opts->initial_delay)
+		if (opts->initial_delay && !pos->immediate)
 			pos->core.attr.enable_on_exec = 1;
 		else
 			pos->immediate = 1;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 173b4f0e0e6e..ab48be4cf258 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1566,6 +1566,18 @@ void perf_evlist__to_front(struct evlist *evlist,
 	list_splice(&move, &evlist->core.entries);
 }
 
+struct evsel *perf_evlist__get_tracking_event(struct evlist *evlist)
+{
+	struct evsel *evsel;
+
+	evlist__for_each_entry(evlist, evsel) {
+		if (evsel->tracking)
+			return evsel;
+	}
+
+	return evlist__first(evlist);
+}
+
 void perf_evlist__set_tracking_event(struct evlist *evlist,
 				     struct evsel *tracking_evsel)
 {
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index b6f325dfb4d2..a8081dfc19cf 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -335,6 +335,7 @@ void perf_evlist__to_front(struct evlist *evlist,
 	evlist__cpu_iter_start(evlist);			\
 	perf_cpu_map__for_each_cpu (cpu, index, (evlist)->core.all_cpus)
 
+struct evsel *perf_evlist__get_tracking_event(struct evlist *evlist);
 void perf_evlist__set_tracking_event(struct evlist *evlist,
 				     struct evsel *tracking_evsel);
 
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 96e5171dce41..a68ac3632ae6 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -898,12 +898,6 @@ static void evsel__apply_config_terms(struct evsel *evsel,
 	}
 }
 
-static bool is_dummy_event(struct evsel *evsel)
-{
-	return (evsel->core.attr.type == PERF_TYPE_SOFTWARE) &&
-	       (evsel->core.attr.config == PERF_COUNT_SW_DUMMY);
-}
-
 struct evsel_config_term *__evsel__get_config_term(struct evsel *evsel, enum evsel_term_type type)
 {
 	struct evsel_config_term *term, *found_term = NULL;
@@ -1161,7 +1155,7 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
 	 * The software event will trigger -EOPNOTSUPP error out,
 	 * if BRANCH_STACK bit is set.
 	 */
-	if (is_dummy_event(evsel))
+	if (evsel__is_dummy_event(evsel))
 		evsel__reset_sample_bit(evsel, BRANCH_STACK);
 }
 
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 0f963c2a88a5..35e3f6d66085 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -399,6 +399,12 @@ static inline bool evsel__has_br_stack(const struct evsel *evsel)
 	       evsel->synth_sample_type & PERF_SAMPLE_BRANCH_STACK;
 }
 
+static inline bool evsel__is_dummy_event(struct evsel *evsel)
+{
+	return (evsel->core.attr.type == PERF_TYPE_SOFTWARE) &&
+	       (evsel->core.attr.config == PERF_COUNT_SW_DUMMY);
+}
+
 struct perf_env *evsel__env(struct evsel *evsel);
 
 int evsel__store_ids(struct evsel *evsel, struct evlist *evlist);
-- 
2.17.1


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

* [PATCH 3/6] perf scripts python: exported-sql-viewer.py: Fix unexpanded 'Find' result
  2020-06-29  9:19 [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8 Adrian Hunter
  2020-06-29  9:19 ` [PATCH 1/6] perf scripts python: export-to-postgresql.py: Fix struct.pack() int argument Adrian Hunter
  2020-06-29  9:19 ` [PATCH 2/6] perf record: Fix duplicated sideband events with Intel PT system wide tracing Adrian Hunter
@ 2020-06-29  9:19 ` Adrian Hunter
  2020-06-29  9:19 ` [PATCH 4/6] perf scripts python: exported-sql-viewer.py: Fix zero id in call graph " Adrian Hunter
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Adrian Hunter @ 2020-06-29  9:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

Using Python version 3.8.2 and PySide2 version 5.14.0, ctrl-F ('Find')
would not expand the tree to the result. Fix by using setExpanded().

Example:
 $ perf record -e intel_pt//u uname
 Linux
 [ perf record: Woken up 1 times to write data ]
 [ perf record: Captured and wrote 0.034 MB perf.data ]
 $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
 2020-06-26 15:32:14.928997 Creating database ...
 2020-06-26 15:32:14.933971 Writing records...
 2020-06-26 15:32:15.535251 Adding indexes
 2020-06-26 15:32:15.542993 Dropping unused tables
 2020-06-26 15:32:15.549716 Done
 $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db

 Select: Reports -> Context-Sensitive Call Graph    or     Reports -> Call Tree
 Press: Ctrl-F
 Enter: main
 Press: Enter

 Before: line showing 'main' does not display
 After: tree is expanded to line showing 'main'

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes:; ebd70c7dc2f5f ("perf scripts python: exported-sql-viewer.py: Add ability to find symbols in the call-graph")
Cc: stable@vger.kernel.org
---
 tools/perf/scripts/python/exported-sql-viewer.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index 26d7be785288..4be7cb68c8bb 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -1050,6 +1050,7 @@ class TreeWindowBase(QMdiSubWindow):
 				child = self.model.index(row, 0, parent)
 				if child.internalPointer().dbid == dbid:
 					found = True
+					self.view.setExpanded(parent, True)
 					self.view.setCurrentIndex(child)
 					parent = child
 					break
-- 
2.17.1


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

* [PATCH 4/6] perf scripts python: exported-sql-viewer.py: Fix zero id in call graph 'Find' result
  2020-06-29  9:19 [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8 Adrian Hunter
                   ` (2 preceding siblings ...)
  2020-06-29  9:19 ` [PATCH 3/6] perf scripts python: exported-sql-viewer.py: Fix unexpanded 'Find' result Adrian Hunter
@ 2020-06-29  9:19 ` Adrian Hunter
  2020-06-29  9:19 ` [PATCH 5/6] perf scripts python: exported-sql-viewer.py: Fix zero id in call tree " Adrian Hunter
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Adrian Hunter @ 2020-06-29  9:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

Using ctrl-F ('Find') would not find 'unknown' because it matches id zero.
Fix by excluding id zero from selection.

Example:
 $ perf record -e intel_pt//u uname
 Linux
 [ perf record: Woken up 1 times to write data ]
 [ perf record: Captured and wrote 0.034 MB perf.data ]
 $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
 2020-06-26 15:32:14.928997 Creating database ...
 2020-06-26 15:32:14.933971 Writing records...
 2020-06-26 15:32:15.535251 Adding indexes
 2020-06-26 15:32:15.542993 Dropping unused tables
 2020-06-26 15:32:15.549716 Done
 $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db

 Select: Reports -> Context-Sensitive Call Graph
 Press: Ctrl-F
 Enter: unknown
 Press: Enter

 Before: gets stuck
 After: tree is expanded to line showing 'unknown'

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: 254c0d820b86d ("perf scripts python: exported-sql-viewer.py: Factor out CallGraphModelBase")
Cc: stable@vger.kernel.org
---
 tools/perf/scripts/python/exported-sql-viewer.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index 4be7cb68c8bb..e0c90aeff15e 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -768,7 +768,8 @@ class CallGraphModel(CallGraphModelBase):
 						" FROM calls"
 						" INNER JOIN call_paths ON calls.call_path_id = call_paths.id"
 						" INNER JOIN symbols ON call_paths.symbol_id = symbols.id"
-						" WHERE symbols.name" + match +
+						" WHERE calls.id <> 0"
+						" AND symbols.name" + match +
 						" GROUP BY comm_id, thread_id, call_path_id"
 						" ORDER BY comm_id, thread_id, call_path_id")
 
-- 
2.17.1


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

* [PATCH 5/6] perf scripts python: exported-sql-viewer.py: Fix zero id in call tree 'Find' result
  2020-06-29  9:19 [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8 Adrian Hunter
                   ` (3 preceding siblings ...)
  2020-06-29  9:19 ` [PATCH 4/6] perf scripts python: exported-sql-viewer.py: Fix zero id in call graph " Adrian Hunter
@ 2020-06-29  9:19 ` Adrian Hunter
  2020-06-29  9:19 ` [PATCH 6/6] perf scripts python: exported-sql-viewer.py: Fix time chart call tree Adrian Hunter
  2020-07-03 11:20 ` [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8 Arnaldo Carvalho de Melo
  6 siblings, 0 replies; 8+ messages in thread
From: Adrian Hunter @ 2020-06-29  9:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

Using ctrl-F ('Find') would not find 'unknown' because it matches id zero.
Fix by excluding id zero from selection.

Example:
 $ perf record -e intel_pt//u uname
 Linux
 [ perf record: Woken up 1 times to write data ]
 [ perf record: Captured and wrote 0.034 MB perf.data ]
 $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
 2020-06-26 15:32:14.928997 Creating database ...
 2020-06-26 15:32:14.933971 Writing records...
 2020-06-26 15:32:15.535251 Adding indexes
 2020-06-26 15:32:15.542993 Dropping unused tables
 2020-06-26 15:32:15.549716 Done
 $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db

 Select: Reports -> Call Tree
 Press: Ctrl-F
 Enter: unknown
 Press: Enter

 Before: displays 'unknown' not found
 After: tree is expanded to line showing 'unknown'

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: ae8b887c00d3f ("perf scripts python: exported-sql-viewer.py: Add call tree")
Cc: stable@vger.kernel.org
---
 tools/perf/scripts/python/exported-sql-viewer.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index e0c90aeff15e..0f295055ac6b 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -964,7 +964,8 @@ class CallTreeModel(CallGraphModelBase):
 						" FROM calls"
 						" INNER JOIN call_paths ON calls.call_path_id = call_paths.id"
 						" INNER JOIN symbols ON call_paths.symbol_id = symbols.id"
-						" WHERE symbols.name" + match +
+						" WHERE calls.id <> 0"
+						" AND symbols.name" + match +
 						" ORDER BY comm_id, thread_id, call_time, calls.id")
 
 	def FindPath(self, query):
-- 
2.17.1


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

* [PATCH 6/6] perf scripts python: exported-sql-viewer.py: Fix time chart call tree
  2020-06-29  9:19 [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8 Adrian Hunter
                   ` (4 preceding siblings ...)
  2020-06-29  9:19 ` [PATCH 5/6] perf scripts python: exported-sql-viewer.py: Fix zero id in call tree " Adrian Hunter
@ 2020-06-29  9:19 ` Adrian Hunter
  2020-07-03 11:20 ` [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8 Arnaldo Carvalho de Melo
  6 siblings, 0 replies; 8+ messages in thread
From: Adrian Hunter @ 2020-06-29  9:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

Using Python version 3.8.2 and PySide2 version 5.14.0, time chart call tree
would not expand the tree to the result. Fix by using setExpanded().

Example:
 $ perf record -e intel_pt//u uname
 Linux
 [ perf record: Woken up 1 times to write data ]
 [ perf record: Captured and wrote 0.034 MB perf.data ]
 $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
 2020-06-26 15:32:14.928997 Creating database ...
 2020-06-26 15:32:14.933971 Writing records...
 2020-06-26 15:32:15.535251 Adding indexes
 2020-06-26 15:32:15.542993 Dropping unused tables
 2020-06-26 15:32:15.549716 Done
 $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db

 Select: Charts -> Time chart by CPU
 Move mouse over middle of chart
 Right-click and select Show Call Tree

 Before: displays Call Tree but not expanded to selected time
 After: displays Call Tree expanded to selected time

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: e69d5df75d74d ("perf scripts python: exported-sql-viewer.py: Add ability for Call tree to open at a specified task and time")
Cc: stable@vger.kernel.org
---
 tools/perf/scripts/python/exported-sql-viewer.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index 0f295055ac6b..7daa8bb70a5a 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -1130,6 +1130,7 @@ class CallTreeWindow(TreeWindowBase):
 				child = self.model.index(row, 0, parent)
 				if child.internalPointer().dbid == dbid:
 					found = True
+					self.view.setExpanded(parent, True)
 					self.view.setCurrentIndex(child)
 					parent = child
 					break
@@ -1142,6 +1143,7 @@ class CallTreeWindow(TreeWindowBase):
 				return
 			last_child = None
 			for row in xrange(n):
+				self.view.setExpanded(parent, True)
 				child = self.model.index(row, 0, parent)
 				child_call_time = child.internalPointer().call_time
 				if child_call_time < time:
@@ -1154,9 +1156,11 @@ class CallTreeWindow(TreeWindowBase):
 			if not last_child:
 				if not found:
 					child = self.model.index(0, 0, parent)
+					self.view.setExpanded(parent, True)
 					self.view.setCurrentIndex(child)
 				return
 			found = True
+			self.view.setExpanded(parent, True)
 			self.view.setCurrentIndex(last_child)
 			parent = last_child
 
-- 
2.17.1


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

* Re: [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8
  2020-06-29  9:19 [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8 Adrian Hunter
                   ` (5 preceding siblings ...)
  2020-06-29  9:19 ` [PATCH 6/6] perf scripts python: exported-sql-viewer.py: Fix time chart call tree Adrian Hunter
@ 2020-07-03 11:20 ` Arnaldo Carvalho de Melo
  6 siblings, 0 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-07-03 11:20 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: Jiri Olsa, linux-kernel

Em Mon, Jun 29, 2020 at 12:19:49PM +0300, Adrian Hunter escreveu:
> Hi
> 
> Here are some Intel PT related fixes for v5.8.

Thanks, applied.

- Arnaldo
 
> 
> Adrian Hunter (6):
>       perf scripts python: export-to-postgresql.py: Fix struct.pack() int argument
>       perf record: Fix duplicated sideband events with Intel PT system wide tracing
>       perf scripts python: exported-sql-viewer.py: Fix unexpanded 'Find' result
>       perf scripts python: exported-sql-viewer.py: Fix zero id in call graph 'Find' result
>       perf scripts python: exported-sql-viewer.py: Fix zero id in call tree 'Find' result
>       perf scripts python: exported-sql-viewer.py: Fix time chart call tree
> 
>  tools/perf/builtin-record.c                       | 18 +++++++++---------
>  tools/perf/scripts/python/export-to-postgresql.py |  2 +-
>  tools/perf/scripts/python/exported-sql-viewer.py  | 11 +++++++++--
>  tools/perf/util/evlist.c                          | 12 ++++++++++++
>  tools/perf/util/evlist.h                          |  1 +
>  tools/perf/util/evsel.c                           |  8 +-------
>  tools/perf/util/evsel.h                           |  6 ++++++
>  7 files changed, 39 insertions(+), 19 deletions(-)
> 
> 
> Regards
> Adrian

-- 

- Arnaldo

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

end of thread, other threads:[~2020-07-03 11:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29  9:19 [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8 Adrian Hunter
2020-06-29  9:19 ` [PATCH 1/6] perf scripts python: export-to-postgresql.py: Fix struct.pack() int argument Adrian Hunter
2020-06-29  9:19 ` [PATCH 2/6] perf record: Fix duplicated sideband events with Intel PT system wide tracing Adrian Hunter
2020-06-29  9:19 ` [PATCH 3/6] perf scripts python: exported-sql-viewer.py: Fix unexpanded 'Find' result Adrian Hunter
2020-06-29  9:19 ` [PATCH 4/6] perf scripts python: exported-sql-viewer.py: Fix zero id in call graph " Adrian Hunter
2020-06-29  9:19 ` [PATCH 5/6] perf scripts python: exported-sql-viewer.py: Fix zero id in call tree " Adrian Hunter
2020-06-29  9:19 ` [PATCH 6/6] perf scripts python: exported-sql-viewer.py: Fix time chart call tree Adrian Hunter
2020-07-03 11:20 ` [PATCH 0/6] perf tools: Some Intel PT related fixes for v5.8 Arnaldo Carvalho de Melo

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