Skip to contentSkip to conversation

perf, tools, report: Add support for srcfile sort key

PATCH Applied Andi Kleen 4 participants 13 messages Aug 7, 2015 – Aug 12, 2015 perf events

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 perf, tools, report: Add support for srcfile sort key

From: Andi Kleen <[email protected]>

In some cases it's useful to characterize samples by file. This is useful to get a higher level categorization, for example to map cost to subsystems.

Add a srcfile sort key to perf report. It builds on top of the existing srcline support.

---
 tools/perf/Documentation/perf-report.txt |  2 ++
 tools/perf/util/hist.c                   |  2 ++
 tools/perf/util/hist.h                   |  1 +
 tools/perf/util/sort.c                   | 52 ++++++++++++++++++++++++++++++++
 tools/perf/util/sort.h                   |  2 ++
 5 files changed, 59 insertions(+)
tools/perf/Documentation/perf-report.txt +2 -0
index aabb1b4..724ab3f 100644
@@ -81,6 +81,8 @@ OPTIONS
 	- cpu: cpu number the task ran at the time of sample
 	- srcline: filename and line number executed at the time of sample.  The
 	DWARF debugging info must be provided.
+	- srcfile: file name of the source file of the same. Requires dwarf
+	information.
 	- weight: Event specific weight, e.g. memory latency or transaction
 	abort cost. This is the global weight.
 	- local_weight: Local weight version of the weight above.
tools/perf/util/hist.c +2 -0
index 6f28d53..37dd8ae 100644
@@ -944,6 +944,8 @@ void hist_entry__delete(struct hist_entry *he)
 
 	zfree(&he->stat_acc);
 	free_srcline(he->srcline);
+	if (he->srcfile && he->srcfile[0])
+		free(he->srcfile);
 	free_callchain(he->callchain);
 	free(he);
 }
tools/perf/util/hist.h +1 -0
index 5ed8d9c..3be8087 100644
@@ -30,6 +30,7 @@ enum hist_column {
 	HISTC_PARENT,
 	HISTC_CPU,
 	HISTC_SRCLINE,
+	HISTC_SRCFILE,
 	HISTC_MISPREDICT,
 	HISTC_IN_TX,
 	HISTC_ABORT,
tools/perf/util/sort.c +52 -0

64 lines not on this page · raw message

tools/perf/util/sort.h +2 -0
index e97cd47..13705b2 100644
@@ -114,6 +114,7 @@ struct hist_entry {
 		};
 	};
 	char			*srcline;
+	char			*srcfile;
 	struct symbol		*parent;
 	struct rb_root		sorted_chain;
 	struct branch_info	*branch_info;
@@ -172,6 +173,7 @@ enum sort_type {
 	SORT_PARENT,
 	SORT_CPU,
 	SORT_SRCLINE,
+	SORT_SRCFILE,
 	SORT_LOCAL_WEIGHT,
 	SORT_GLOBAL_WEIGHT,
 	SORT_TRANSACTION,
Signature · 1 line
2.4.3
maintainer Applied
#1 lore raw

Em Fri, Aug 07, 2015 at 03:54:24PM -0700, Andi Kleen escreveu:

Quoted 8 lines

From: Andi Kleen <[email protected]>

In some cases it's useful to characterize samples by file. This is useful to get a higher level categorization, for example to map cost to subsystems.

Add a srcfile sort key to perf report. It builds on top of the existing srcline support.

Applied

Quoted 139 lines
---
 tools/perf/Documentation/perf-report.txt |  2 ++
 tools/perf/util/hist.c                   |  2 ++
 tools/perf/util/hist.h                   |  1 +
 tools/perf/util/sort.c                   | 52 ++++++++++++++++++++++++++++++++
 tools/perf/util/sort.h                   |  2 ++
 5 files changed, 59 insertions(+)
tools/perf/Documentation/perf-report.txt +2 -0
index aabb1b4..724ab3f 100644
@@ -81,6 +81,8 @@ OPTIONS
 	- cpu: cpu number the task ran at the time of sample
 	- srcline: filename and line number executed at the time of sample.  The
 	DWARF debugging info must be provided.
+	- srcfile: file name of the source file of the same. Requires dwarf
+	information.
 	- weight: Event specific weight, e.g. memory latency or transaction
 	abort cost. This is the global weight.
 	- local_weight: Local weight version of the weight above.
tools/perf/util/hist.c +2 -0
index 6f28d53..37dd8ae 100644
@@ -944,6 +944,8 @@ void hist_entry__delete(struct hist_entry *he)
 
 	zfree(&he->stat_acc);
 	free_srcline(he->srcline);
+	if (he->srcfile && he->srcfile[0])
+		free(he->srcfile);
 	free_callchain(he->callchain);
 	free(he);
 }
tools/perf/util/hist.h +1 -0
index 5ed8d9c..3be8087 100644
@@ -30,6 +30,7 @@ enum hist_column {
 	HISTC_PARENT,
 	HISTC_CPU,
 	HISTC_SRCLINE,
+	HISTC_SRCFILE,
 	HISTC_MISPREDICT,
 	HISTC_IN_TX,
 	HISTC_ABORT,
tools/perf/util/sort.c +52 -0
index 4c65a14..e3e8b13 100644
@@ -319,6 +319,57 @@ struct sort_entry sort_srcline = {
 	.se_width_idx	= HISTC_SRCLINE,
 };
 
+/* --sort srcfile */
+
+static char no_srcfile[1];
+
+static char *get_srcfile(struct hist_entry *e)
+{
+	char *sf, *p;
+	struct map *map = e->ms.map;
+
+	sf = get_srcline(map->dso, map__rip_2objdump(map, e->ip),
+			 e->ms.sym, true);
+	p = strchr(sf, ':');
+	if (p && *sf) {
+		*p = 0;
+		return sf;
+	}
+	free(sf);
+	return no_srcfile;
+}
+
+static int64_t
+sort__srcfile_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+	if (!left->srcfile) {
+		if (!left->ms.map)
+			left->srcfile = no_srcfile;
+		else
+			left->srcfile = get_srcfile(left);
+	}
+	if (!right->srcfile) {
+		if (!right->ms.map)
+			right->srcfile = no_srcfile;
+		else
+			right->srcfile = get_srcfile(right);
+	}
+	return strcmp(right->srcfile, left->srcfile);
+}
+
+static int hist_entry__srcfile_snprintf(struct hist_entry *he, char *bf,
+					size_t size, unsigned int width)
+{
+	return repsep_snprintf(bf, size, "%-*.*s", width, width, he->srcfile);
+}
+
+struct sort_entry sort_srcfile = {
+	.se_header	= "Source File",
+	.se_cmp		= sort__srcfile_cmp,
+	.se_snprintf	= hist_entry__srcfile_snprintf,
+	.se_width_idx	= HISTC_SRCFILE,
+};
+
 /* --sort parent */
 
 static int64_t
@@ -1173,6 +1224,7 @@ static struct sort_dimension common_sort_dimensions[] = {
 	DIM(SORT_PARENT, "parent", sort_parent),
 	DIM(SORT_CPU, "cpu", sort_cpu),
 	DIM(SORT_SRCLINE, "srcline", sort_srcline),
+	DIM(SORT_SRCFILE, "srcfile", sort_srcfile),
 	DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight),
 	DIM(SORT_GLOBAL_WEIGHT, "weight", sort_global_weight),
 	DIM(SORT_TRANSACTION, "transaction", sort_transaction),
tools/perf/util/sort.h +2 -0
index e97cd47..13705b2 100644
@@ -114,6 +114,7 @@ struct hist_entry {
 		};
 	};
 	char			*srcline;
+	char			*srcfile;
 	struct symbol		*parent;
 	struct rb_root		sorted_chain;
 	struct branch_info	*branch_info;
@@ -172,6 +173,7 @@ enum sort_type {
 	SORT_PARENT,
 	SORT_CPU,
 	SORT_SRCLINE,
+	SORT_SRCFILE,
 	SORT_LOCAL_WEIGHT,
 	SORT_GLOBAL_WEIGHT,
 	SORT_TRANSACTION,
Signature · 1 line
2.4.3
#2 lore raw

Em Fri, Aug 07, 2015 at 08:51:45PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 11 lines

Em Fri, Aug 07, 2015 at 03:54:24PM -0700, Andi Kleen escreveu:

Quoted 8 lines

From: Andi Kleen <[email protected]>

In some cases it's useful to characterize samples by file. This is useful to get a higher level categorization, for example to map cost to subsystems.

Add a srcfile sort key to perf report. It builds on top of the existing srcline support.

Applied

Humm, holding this up a bit, further testing showed some oddities, fedora21, the width of the column is being limited to the lenght of the header and there are some DWARF errors, have you noticed those?

[root@zoo ~]# rpm -q binutils-devel
binutils-devel-2.24-32.fc21.x86_64

# perf report --stdio -s srcfile
Failed to open /tmp/perf-2268.map, continuing without symbols
# To display the perf.data header info, please use --header/--header-only options.
#
BFD: Dwarf Error: Offset (124839) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (111062) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (111062) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (124839) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (124839) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (124839) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (124839) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (22876).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (58106).
BFD: Dwarf Error: Offset (113124) greater than or equal to .debug_str size (58106).
BFD: Dwarf Error: Offset (58380) greater than or equal to .debug_str size (17648).
BFD: Dwarf Error: Offset (124839) greater than or equal to .debug_str size (58106).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (58106).
BFD: Dwarf Error: Offset (124839) greater than or equal to .debug_str size (58106).
BFD: Dwarf Error: Offset (124839) greater than or equal to .debug_str size (58106).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (58106).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (58106).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (58106).
BFD: Dwarf Error: Offset (124839) greater than or equal to .debug_str size (58106).
BFD: Dwarf Error: Offset (70405) greater than or equal to .debug_str size (58106).
BFD: Dwarf Error: Offset (124839) greater than or equal to .debug_str size (58106).
#
# Total Lost Samples: 0
#
# Samples: 7K of event 'cycles'
# Event count (approx.): 1770111576
#
# Overhead  Source File
# ........  ...........
#
    31.99%             
     7.97%  .          
     6.79%  processor.h
     3.69%  fair.c     
     2.74%  gmain.c    
     1.73%  gtype.c    
     1.40%  core.c     
     1.23%  atomic64_64
     1.22%  qspinlock.h
     1.16%  i915_gem.c 
     1.09%  ghash.c    
     1.07%  gthread-pos
     1.06%  bitops.h   
     1.06%  malloc.c   
     1.06%  af_unix.c  
     1.03%  select.c   
     0.99%  gslice.c   
     0.80%  hrtimer.c  
     0.78%  socket.c   
     0.67%  paravirt.h 
     0.66%  entry_64.S 
     0.62%  hooks.c    
     0.61%  gsignal.c  
     0.57%  intel_ringb
     0.55%  timekeeping
     0.54%  slub.c     
     0.53%  timerqueue.
     0.52%  menu.c     
     0.52%  file.c     
     0.50%  tree.c     
     0.47%  compiler.h 
     0.46%  tick-sched.
     0.46%  msr.h      
     0.39%  busy_poll.h
     0.39%  int_sqrt.c 
     0.36%  atomic.h   
     0.35%  gobject.c  
     0.35%  read_write.
     0.33%  garray.c   
     0.32%  xcb_io.c   
     0.32%  wait.c     
     0.31%  copy_user_6
     0.30%  dbus-marsha
     0.29%  rbtree.c   
     0.29%  skbuff.c   
     0.28%  dbus-marsha
     0.27%  spinlock.c 
     0.27%  iov_iter.c 
     0.26%  avc.c      
     0.26%  list_debug.
     0.26%  giochannel.
     0.24%  cairo-gstat
     0.24%  dbus-string
     0.23%  cpuidle.c  
     0.23%  page_alloc.
     0.22%  tsc.c      
     0.21%  gvariant-co
     0.20%  process_64.
     0.19%  gbsearcharr
     0.18%  sock.c     
     0.18%  timer.c    
     0.18%  dbus-connec
     0.18%  dbus-marsha
     0.17%  fsnotify.c 
     0.17%  iomap.c    
     0.17%  gutf8.c    
     0.17%  dbus-list.c
     0.16%  cairo-path-
     0.16%  gbitlock.c 
     0.16%  srcu.c     
     0.16%  gdataset.c 
     0.16%  intel_uncor
     0.16%  gvarianttyp
     0.15%  futex.c    
     0.15%  sched.h    
     0.15%  gslist.c   
     0.15%  clock.c    
     0.15%  XlibInt.c  
     0.15%  gclosure.c 
     0.14%  gmem.c     
     0.14%  n_tty.c    
     0.14%  eventfd.c  
     0.14%  datagram.c 
     0.14%  security.c 
     0.14%  mutex_64.h 
     0.14%  sock.h     
     0.14%  dbus-messag
     0.14%  idle.c     
     0.13%  internal.h 
     0.13%  page_64.h  
     0.12%  current.h  
     0.12%  vmalloc.c  
     0.12%  notifier.c 
     0.12%  gvariant.c 
     0.12%  gdbusprivat
     0.11%  i915_drv.h 
     0.11%  intel_idle.
     0.11%  rbtree_augm
     0.11%  mutex.c    
     0.11%  gsimpleasyn
     0.11%  cairo-regio
     0.10%  cairo-hash.
     0.10%  gqueue.c   
     0.10%  input.c    
     0.10%  preempt.h  
     0.10%  mm.h       
     0.10%  cairo-clip-
     0.10%  dbus-mempoo
     0.09%  idle_task.c
     0.09%  rt.c       
     0.09%  dbus-mainlo
     0.09%  tick-onesho
     0.09%  dbus-transp
     0.09%  softirq.c  
     0.09%  cairo-xlib-
     0.09%  workqueue.c
     0.09%  cairo-matri
     0.08%  dbus-marsha
     0.08%  dbus-resour
     0.08%  seqlock.h  
     0.08%  gvaluetypes
     0.08%  cairo-surfa
     0.08%  glist.c    
     0.08%  connection.
     0.08%  giounix.c  
     0.08%  tty_io.c   
     0.08%  stats.h    
     0.08%  i915_cmd_pa
     0.08%  cairo.c    
     0.08%  gvalue.c   
     0.07%  mmzone.h   
     0.07%  apic.c     
     0.07%  gvarianttyp
     0.07%  gdbusmessag
     0.07%  gdbusconnec
     0.07%  ktime.h    
     0.07%  string3.h  
     0.07%  mempolicy.c
     0.07%  list.h     
     0.07%  desc.h     
     0.07%  mmap.c     
     0.06%  loadavg.c  
     0.06%  tree_plugin
     0.06%  gstring.c  
     0.06%  cputime.c  
     0.06%  cairo-scale
     0.06%  perf_event_
     0.06%  mmu_context
     0.06%  FilterEv.c 
     0.06%  signal.c   
     0.06%  eventpoll.c
     0.06%  gparam.c   
     0.06%  locking.c  
     0.06%  garbage.c  
     0.06%  uaccess.h  
     0.06%  irq_work.c 
     0.06%  namei.c    
     0.06%  Pending.c  
     0.06%  cairo-surfa
     0.06%  i915_gem_ex
     0.06%  nmi.c      
     0.06%  dbus-timeou
     0.06%  avtab.c    
     0.05%  fdtable.h  
     0.05%  pango-layou
     0.05%  drm_crtc.c 
     0.05%  cgroup.h   
     0.05%  gquark.c   
     0.05%  kthread.c  
     0.05%  i915_gem_co
     0.05%  driver.c   
     0.05%  i915_irq.c 
     0.05%  rx.c       
     0.05%  smp.c      
     0.05%  scm.h      
     0.05%  dcache.c   
     0.05%  cairo-color
     0.04%  cairo-bentl
     0.04%  skbuff.h   
     0.04%  gapplicatio
     0.04%  clockevents
     0.04%  file.h     
     0.04%  drm_fops.c 
     0.04%  slab_common
     0.04%  cairo-boxes
     0.04%  gwakeup.c  
     0.04%  vmstat.c   
     0.04%  crc32.c    
     0.04%  find_bit.c 
     0.04%  dbus-socket
     0.04%  qspinlock.c
     0.04%  memcpy_64.S
     0.04%  dbus-sysdep
     0.04%  vsprintf.c 
     0.04%  file_table.
     0.04%  poll.h     
     0.04%  cpuacct.c  
     0.04%  stop_task.c
     0.04%  x86.c      
     0.04%  fsnotify.h 
     0.04%  policy.c   
     0.04%  watchdog.c 
     0.04%  math64.h   
     0.04%  gsocket.c  
     0.04%  gdbusinterf
     0.04%  ptthread.c 
     0.04%  mmzone.c   
     0.04%  time.c     
     0.04%  cairoint.h 
     0.04%  gdbusintros
     0.03%  s_sin-avx.c
     0.03%  spinlock.h 
     0.03%  guniprop.c 
     0.03%  unistd.h   
     0.03%  gmarshal.c 
     0.03%  cairo-traps
     0.03%  radix-tree.
     0.03%  signals.c  
     0.03%  main.c     
     0.03%  dbus-creden
     0.03%  hcd.c      
     0.03%  gvariant-se
     0.03%  kernel_stat
     0.03%  bus.c      
     0.03%  cairo-defau
     0.03%  cairo-freed
     0.03%  CrGC.c     
     0.03%  posix-cpu-t
     0.03%  tty_ldsem.c
     0.03%  NextEvent.c
     0.03%  pty.c      
     0.03%  JSAutoCompa
     0.03%  gprintf.c  
     0.03%  poll2.h    
     0.03%  context.h  
     0.03%  pangofc-fon
     0.03%  af_netlink.
     0.03%  vsyscall_gt
     0.03%  hrtimer.h  
     0.03%  printk.c   
     0.03%  cairo-xlib-
     0.03%  seq_file.c 
     0.03%  cairo-patte
     0.03%  process.c  
     0.03%  deadline.c 
     0.03%  intel_displ
     0.03%  jiffies.h  
     0.03%  dl-lookup.c
     0.03%  flex_array.
     0.03%  services.c 
     0.02%  prtpd.c    
     0.02%  cairo-devic
     0.02%  dnotify.c  
     0.02%  scan.c     
     0.02%  cairo-clip.
     0.02%  profile.c  
     0.02%  cairo-array
     0.02%  blkdev.h   
     0.02%  uprobes.c  
     0.02%  gfp.h      
     0.02%  cairo-traps
     0.02%  cairo-strok
     0.02%  FillRect.c 
     0.02%  mutex.h    
     0.02%  ghook.c    
     0.02%  dbus-transp
     0.02%  perf_event.
     0.02%  mprotect.c 
     0.02%  pango-impl-
     0.02%  journal.c  
     0.02%  rbtree.h   
     0.02%  namespace.c
     0.02%  mwait.h    
     0.02%  memset_64.S
     0.02%  gboxed.c   
     0.02%  handle.c   
     0.02%  Xrender.c  
     0.02%  gthread.c  
     0.02%  drm_irq.c  
     0.02%  memory.c   
     0.02%  ehci-hcd.c 
     0.02%  dbus-errors
     0.02%  tlb.c      
     0.02%  tsacct.c   
     0.02%  hid-apple.c
     0.02%  qos.c      
     0.02%  open.c     
     0.02%  ErrHndlr.c 
     0.02%  cpumask.h  
     0.02%  gioerror.c 
     0.02%  urb.c      
     0.02%  pid.c      
     0.02%  blk-core.c 
     0.02%  cairo-bentl
     0.02%  wait.h     
     0.02%  irq_regs.h 
     0.02%  dma.c      
     0.02%  topology.h 
     0.02%  FreePix.c  
     0.02%  selinux.c  
     0.02%  intel_pstat
     0.02%  cairo-slope
     0.02%  pipe.c     
     0.02%  fcntl.c    
     0.02%  ntp.c      
     0.02%  pangocairo-
     0.02%  atkplug.c  
     0.02%  cfq-iosched
     0.02%  shmem.c    
     0.02%  basic-fc.c 
     0.02%  seccomp.c  
     0.02%  ptrace.h   
     0.02%  drm_gem.c  
     0.02%  commoncap.c
     0.02%  cpumask.c  
     0.02%  gtimer.c   
     0.02%  dbus-thread
     0.01%  base.c     
     0.01%  tty_buffer.
     0.01%  sysrq.c    
     0.01%  iommu-helpe
     0.01%  cairo-boxes
     0.01%  drm_modeset
     0.01%  gdbusproxy.
     0.01%  atkobject.c
     0.01%  pgtable.c  
     0.01%  ffi64.c    
     0.01%  mac80211_if
     0.01%  cairo-gstat
     0.01%  cairo-arc.c
     0.01%  cairo-ft-fo
     0.01%  gbytes.c   
     0.01%  hid-core.c 
     0.01%  tick-broadc
     0.01%  scsi.c     
     0.01%  dbus-datasl
     0.01%  page-io.c  
     0.01%  intel_front
     0.01%  swap.c     
     0.01%  XlibAsync.c
     0.01%  intel_pm.c 
     0.01%  intel_ringb
     0.01%  sn-list.c  
     0.01%  locks.c    
     0.01%  putuser.S  
     0.01%  dbus-signat
     0.01%  cairo-xlib-
     0.01%  cairo-misc.
     0.01%  highmem.h  
     0.01%  blk-integri
     0.01%  random.c   
     0.01%  cairo-recta
     0.01%  memmove_64.
     0.01%  gdk-pixbuf.
     0.01%  Picture.c  
     0.01%  pango-attri
     0.01%  usercopy_64
     0.01%  hid-input.c
     0.01%  tty_ldisc.c
     0.01%  perf_event_
     0.01%  blk-throttl
     0.01%  time.h     
     0.01%  gsourceclos
     0.01%  physaddr.c 
     0.01%  drm_ioctl.c
     0.01%  pango-conte
     0.01%  drm_modes.c
     0.01%  avc.h      
     0.01%  qrwlock.h  
     0.01%  apic.h     
     0.01%  spinlock_ap
     0.01%  crc16.c    
     0.01%  i915_drv.c 
     0.01%  cpufeature.
     0.01%  dbus-sysdep
     0.01%  mount.h    
     0.01%  jump_label.
     0.01%  revoke.c   
     0.01%  blk.h      
     0.01%  signal.h   
     0.01%  ehci-q.c   
     0.01%  tlbflush.h 
     0.01%  list.cc    
     0.01%  dbus-gmain.
     0.01%  scsi_lib.c 
     0.01%  dbus-hash.c
     0.01%  GetEventDat
     0.01%  mlme.c     
     0.01%  iface.c    
     0.01%  io.h       
     0.01%  dbus-watch.
     0.01%  page-flags.
     0.01%  sn-monitor.
     0.01%  task_work.c
     0.01%  evdev.c    
     0.01%  cairo-obser
     0.01%  Macros.c   
     0.01%  drm_atomic_
     0.01%  dbus-socket
     0.01%  itimer.c   
     0.01%  gtestutils.
     0.01%  spurious.c 
     0.01%  super.c    
     0.01%  inode.c    
     0.01%  rtnetlink.c
     0.01%  physaddr.h 
     0.01%  unix64.S   
author
#3 lore raw
Quoted 8 lines · Arnaldo Carvalho de Melo

Em Fri, Aug 07, 2015 at 08:51:45PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 7 lines

Em Fri, Aug 07, 2015 at 03:54:24PM -0700, Andi Kleen escreveu:

Quoted 6 lines

From: Andi Kleen <[email protected]>

In some cases it's useful to characterize samples by file. This is useful to get a higher level categorization, for example to map cost to subsystems.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Add a srcfile sort key to perf report. It builds on top of the existing srcline support.

Applied

Humm, holding this up a bit, further testing showed some oddities, fedora21, the width of the column is being limited to the lenght of the header

Yes I've seen that, I just use -w normally. It also happens with --sort srcline. The column sizing code could probably be somewhat smarter and always allow the last column to become as wide as needed. But that's something that should be done separately; I don't think it belongs into this patch.

Quoted 1 line

and there are some DWARF errors, have you noticed those?

No I didn't. Some generic issue, likely happening with srcline and perhaps even objdump -S too. Find out with strace what file it is.

-Andi

#4 lore raw

Em Sat, Aug 08, 2015 at 04:27:35AM +0200, Andi Kleen escreveu:

Quoted 14 lines · Arnaldo Carvalho de Melo
Quoted 13 lines

Em Fri, Aug 07, 2015 at 08:51:45PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 11 lines

Em Fri, Aug 07, 2015 at 03:54:24PM -0700, Andi Kleen escreveu:

Quoted 8 lines

From: Andi Kleen <[email protected]>

In some cases it's useful to characterize samples by file. This is useful to get a higher level categorization, for example to map cost to subsystems.

Add a srcfile sort key to perf report. It builds on top of the existing srcline support.

Applied

Quoted 7 lines
Quoted 3 lines

Humm, holding this up a bit, further testing showed some oddities, fedora21, the width of the column is being limited to the lenght of the header

Yes I've seen that, I just use -w normally. It also happens with --sort srcline. The column sizing code could probably be somewhat smarter and always allow the last column to become as wide as needed. But that's

Right, I'll check that, there is code for figuring that out, I'll see what is missing.

Quoted 2 lines

something that should be done separately; I don't think it belongs into this patch.

I can agree with that, will add it, as it provides value as-is.

Quoted 4 lines
Quoted 1 line

and there are some DWARF errors, have you noticed those?

No I didn't. Some generic issue, likely happening with srcline and perhaps even objdump -S too. Find out with strace what file it is.

Ok.

- Arnaldo

maintainer
#5 lore raw
In reply to Andi Kleen

Hi Andi,

Quoted 18 lines · Andi Kleen
Quoted 8 lines · Arnaldo Carvalho de Melo

Em Fri, Aug 07, 2015 at 08:51:45PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 7 lines

Em Fri, Aug 07, 2015 at 03:54:24PM -0700, Andi Kleen escreveu:

Quoted 6 lines

From: Andi Kleen <[email protected]>

In some cases it's useful to characterize samples by file. This is useful to get a higher level categorization, for example to map cost to subsystems.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Add a srcfile sort key to perf report. It builds on top of the existing srcline support.

Applied

Humm, holding this up a bit, further testing showed some oddities, fedora21, the width of the column is being limited to the lenght of the header

Quoted 5 lines

Yes I've seen that, I just use -w normally. It also happens with --sort srcline. The column sizing code could probably be somewhat smarter and always allow the last column to become as wide as needed. But that's something that should be done separately; I don't think it belongs into this patch.

Maybe something like this?

Quoted 1 line

From c052d17ae45ac08a381192191473ed3c4308c0c5 Mon Sep 17 00:00:00 2001

From: Namhyung Kim <[email protected]>
Date: Sun, 9 Aug 2015 12:28:01 +0900
Subject: [PATCH] perf tools: Update srcline column length

It didn't calculate the column length so the default of header length used only. Update the length when we get the srcline actually.

---
 tools/perf/util/sort.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/perf/util/sort.c +4 -0
index 5177088a71d3..85e7e3e75d39 100644
@@ -291,6 +291,8 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
 			left->srcline = get_srcline(map->dso,
 					   map__rip_2objdump(map, left->ip),
 						    left->ms.sym, true);
+			hists__new_col_len(left->hists, HISTC_SRCLINE,
+					   strlen(left->srcline));
 		}
 	}
 	if (!right->srcline) {
@@ -301,6 +303,8 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
 			right->srcline = get_srcline(map->dso,
 					     map__rip_2objdump(map, right->ip),
 						     right->ms.sym, true);
+			hists__new_col_len(right->hists, HISTC_SRCLINE,
+					   strlen(right->srcline));
 		}
 	}
 	return strcmp(right->srcline, left->srcline);
Signature · 1 line
2.5.0
author
#6 lore raw
Quoted 21 lines · Namhyung Kim

Hi Andi,

Quoted 18 lines · Andi Kleen
Quoted 16 lines · Arnaldo Carvalho de Melo

Em Fri, Aug 07, 2015 at 08:51:45PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 11 lines

Em Fri, Aug 07, 2015 at 03:54:24PM -0700, Andi Kleen escreveu:

Quoted 8 lines

From: Andi Kleen <[email protected]>

In some cases it's useful to characterize samples by file. This is useful to get a higher level categorization, for example to map cost to subsystems.

Add a srcfile sort key to perf report. It builds on top of the existing srcline support.

Applied

Humm, holding this up a bit, further testing showed some oddities, fedora21, the width of the column is being limited to the lenght of the header

Quoted 7 lines
Quoted 5 lines

Yes I've seen that, I just use -w normally. It also happens with --sort srcline. The column sizing code could probably be somewhat smarter and always allow the last column to become as wide as needed. But that's something that should be done separately; I don't think it belongs into this patch.

Maybe something like this?

Thanks. Should do the same thing for srcfile.

One potential issue is that the srclines/files can be potentially very long, so it may be needed to give them a limit if they're not the last column.

-Andi

maintainer Applied
#7 lore raw

Em Sun, Aug 09, 2015 at 06:03:35PM +0200, Andi Kleen escreveu:

Quoted 28 lines · Namhyung Kim
Quoted 27 lines

Hi Andi,

Quoted 23 lines · Andi Kleen
Quoted 8 lines · Arnaldo Carvalho de Melo

Em Fri, Aug 07, 2015 at 08:51:45PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 7 lines

Em Fri, Aug 07, 2015 at 03:54:24PM -0700, Andi Kleen escreveu:

Quoted 6 lines

From: Andi Kleen <[email protected]>

In some cases it's useful to characterize samples by file. This is useful to get a higher level categorization, for example to map cost to subsystems.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Add a srcfile sort key to perf report. It builds on top of the existing srcline support.

Applied

Humm, holding this up a bit, further testing showed some oddities, fedora21, the width of the column is being limited to the lenght of the header

Yes I've seen that, I just use -w normally. It also happens with --sort srcline. The column sizing code could probably be somewhat smarter and always allow the last column to become as wide as needed. But that's something that should be done separately; I don't think it belongs into this patch.

Quoted 3 lines
Quoted 1 line

Maybe something like this?

Thanks. Should do the same thing for srcfile.

Thanks, applied, with Ack from Andi, will fix this with a commiter note on Andi's patch for srcfile when applying it, now.

Quoted 3 lines

One potential issue is that the srclines/files can be potentially very long, so it may be needed to give them a limit if they're not the last column.

That can come later.

- Arnaldo

#8 lore raw
In reply to Namhyung Kim

Em Sun, Aug 09, 2015 at 12:30:49PM +0900, Namhyung Kim escreveu:

Quoted 21 lines

Hi Andi,

Quoted 18 lines · Andi Kleen
Quoted 16 lines · Arnaldo Carvalho de Melo

Em Fri, Aug 07, 2015 at 08:51:45PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 11 lines

Em Fri, Aug 07, 2015 at 03:54:24PM -0700, Andi Kleen escreveu:

Quoted 8 lines

From: Andi Kleen <[email protected]>

In some cases it's useful to characterize samples by file. This is useful to get a higher level categorization, for example to map cost to subsystems.

Add a srcfile sort key to perf report. It builds on top of the existing srcline support.

Applied

Humm, holding this up a bit, further testing showed some oddities, fedora21, the width of the column is being limited to the lenght of the header

Quoted 7 lines
Quoted 5 lines

Yes I've seen that, I just use -w normally. It also happens with --sort srcline. The column sizing code could probably be somewhat smarter and always allow the last column to become as wide as needed. But that's something that should be done separately; I don't think it belongs into this patch.

Maybe something like this?

Maybe, but it crashes when right->hists == NULL, perhaps that is some sort of placeholder? See the value of right (0x7fffffffc0a0)? looks like some static guard for something, will continue after lunch...

(gdb) fr 2
#2 0x00000000004bb812 in sort__srcline_cmp (left=0x1bfa090, right=0x7fffffffc0a0) at util/sort.c:306
306 hists__new_col_len(right->hists, HISTC_SRCLINE,
(gdb) p right->hists
$7 = (struct hists *) 0x0
(gdb) p left->hists
$8 = (struct hists *) 0x18d66e0
(gdb)

Due to this both "-s srcline" and "-s srcfile" crashes here.

- Arnaldo

Quoted 40 lines
Quoted 3 lines

From c052d17ae45ac08a381192191473ed3c4308c0c5 Mon Sep 17 00:00:00 2001

From: Namhyung Kim <[email protected]>
Date: Sun, 9 Aug 2015 12:28:01 +0900
Subject: [PATCH] perf tools: Update srcline column length

It didn't calculate the column length so the default of header length used only. Update the length when we get the srcline actually.

---
 tools/perf/util/sort.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/perf/util/sort.c +4 -0
index 5177088a71d3..85e7e3e75d39 100644
@@ -291,6 +291,8 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
 			left->srcline = get_srcline(map->dso,
 					   map__rip_2objdump(map, left->ip),
 						    left->ms.sym, true);
+			hists__new_col_len(left->hists, HISTC_SRCLINE,
+					   strlen(left->srcline));
 		}
 	}
 	if (!right->srcline) {
@@ -301,6 +303,8 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
 			right->srcline = get_srcline(map->dso,
 					     map__rip_2objdump(map, right->ip),
 						     right->ms.sym, true);
+			hists__new_col_len(right->hists, HISTC_SRCLINE,
+					   strlen(right->srcline));
 		}
 	}
 	return strcmp(right->srcline, left->srcline);
Signature · 1 line
2.5.0
#9 lore raw

Em Mon, Aug 10, 2015 at 01:12:41PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 43 lines

Em Sun, Aug 09, 2015 at 12:30:49PM +0900, Namhyung Kim escreveu:

Quoted 21 lines

Hi Andi,

Quoted 18 lines · Andi Kleen
Quoted 16 lines · Arnaldo Carvalho de Melo

Em Fri, Aug 07, 2015 at 08:51:45PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 11 lines

Em Fri, Aug 07, 2015 at 03:54:24PM -0700, Andi Kleen escreveu:

Quoted 8 lines

From: Andi Kleen <[email protected]>

In some cases it's useful to characterize samples by file. This is useful to get a higher level categorization, for example to map cost to subsystems.

Add a srcfile sort key to perf report. It builds on top of the existing srcline support.

Applied

Humm, holding this up a bit, further testing showed some oddities, fedora21, the width of the column is being limited to the lenght of the header

Quoted 7 lines
Quoted 5 lines

Yes I've seen that, I just use -w normally. It also happens with --sort srcline. The column sizing code could probably be somewhat smarter and always allow the last column to become as wide as needed. But that's something that should be done separately; I don't think it belongs into this patch.

Maybe something like this?

Maybe, but it crashes when right->hists == NULL, perhaps that is some sort of placeholder? See the value of right (0x7fffffffc0a0)? looks like some static guard for something, will continue after lunch...

(gdb) fr 2
#2 0x00000000004bb812 in sort__srcline_cmp (left=0x1bfa090, right=0x7fffffffc0a0) at util/sort.c:306
306 hists__new_col_len(right->hists, HISTC_SRCLINE,
(gdb) p right->hists
$7 = (struct hists *) 0x0
(gdb) p left->hists
$8 = (struct hists *) 0x18d66e0
(gdb)

Quoted 3 lines

Due to this both "-s srcline" and "-s srcfile" crashes here.

- Arnaldo

Ok, this one needs to be applied before yours and Andi's:

tools/perf/util/hist.c +1 -0
index 137f6a92e5d0..c29c333609fe 100644
@@ -761,6 +761,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
 	struct hist_entry **he_cache = iter->priv;
 	struct hist_entry *he;
 	struct hist_entry he_tmp = {
+		.hists = evsel__hists(evsel),
 		.cpu = al->cpu,
 		.thread = al->thread,
 		.comm = thread__comm(al->thread),

---------

Because you will use that stack synthesized he_tmp entry as a parameter to the cmp() function, that will end up trying to access he_tmp->hists, that was NULL, b00m.

- Arnaldo

Quoted 40 lines
Quoted 40 lines
Quoted 3 lines

From c052d17ae45ac08a381192191473ed3c4308c0c5 Mon Sep 17 00:00:00 2001

From: Namhyung Kim <[email protected]>
Date: Sun, 9 Aug 2015 12:28:01 +0900
Subject: [PATCH] perf tools: Update srcline column length

It didn't calculate the column length so the default of header length used only. Update the length when we get the srcline actually.

---
 tools/perf/util/sort.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/perf/util/sort.c +4 -0
index 5177088a71d3..85e7e3e75d39 100644
@@ -291,6 +291,8 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
 			left->srcline = get_srcline(map->dso,
 					   map__rip_2objdump(map, left->ip),
 						    left->ms.sym, true);
+			hists__new_col_len(left->hists, HISTC_SRCLINE,
+					   strlen(left->srcline));
 		}
 	}
 	if (!right->srcline) {
@@ -301,6 +303,8 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
 			right->srcline = get_srcline(map->dso,
 					     map__rip_2objdump(map, right->ip),
 						     right->ms.sym, true);
+			hists__new_col_len(right->hists, HISTC_SRCLINE,
+					   strlen(right->srcline));
 		}
 	}
 	return strcmp(right->srcline, left->srcline);
Signature · 1 line
2.5.0
#10 lore raw

Em Mon, Aug 10, 2015 at 03:32:47PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 22 lines

Em Mon, Aug 10, 2015 at 01:12:41PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 9 lines

(gdb) fr 2
#2 0x00000000004bb812 in sort__srcline_cmp (left=0x1bfa090, right=0x7fffffffc0a0) at util/sort.c:306
306 hists__new_col_len(right->hists, HISTC_SRCLINE,
(gdb) p right->hists
$7 = (struct hists *) 0x0
(gdb) p left->hists
$8 = (struct hists *) 0x18d66e0

Due to this both "-s srcline" and "-s srcfile" crashes here.

Ok, this one needs to be applied before yours and Andi's:

+++ b/tools/perf/util/hist.c

tools/perf/util/hist.c +1 -1
@@ -761,6 +761,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
 	struct hist_entry **he_cache = iter->priv;
 	struct hist_entry *he;
 	struct hist_entry he_tmp = {
+		.hists = evsel__hists(evsel),
 		.cpu = al->cpu,
---------
 
Quoted 3 lines

Because you will use that stack synthesized he_tmp entry as a parameter to the cmp() function, that will end up trying to access he_tmp->hists, that was NULL, b00m.

all this is moot, as we need to update that column length elsewhere, together with all the other fileds, please see:

://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=e8e6d37e73e6b950c891c780745460b87f4755b6

And now, with it really updating the width, we get to another problem, in one case I got a line like:

0.00% JS_GetInstancePrivate(JSContext*, JSObject*, JSClass*, JS /usr/lib64/libmozjs-24.so 0x1a0bd1 d [.] JS_GetInstancePrivate(JSContext*, JSObject*, JSClass*, JS::Value*)

Which is really strange, i.e. it mixed up demangled stuff with the srcfile, i.e. normal lines for:

perf report -v -s srcfile,dso,symbol --stdio

Look like:

     1.94%  malloc.c    /usr/lib64/libc-2.20.so   0x80f91 d [.] _int_malloc

Anyway, will continue this later, together with checking why it doesn't resolve many things, that one may be related, in some cases, to functions in assembly source files, for now it updates correctly the column width for "srcline" and "srcfile".

- Arnaldo

Quoted 42 lines

- Arnaldo

Quoted 40 lines
Quoted 40 lines
Quoted 3 lines

From c052d17ae45ac08a381192191473ed3c4308c0c5 Mon Sep 17 00:00:00 2001

From: Namhyung Kim <[email protected]>
Date: Sun, 9 Aug 2015 12:28:01 +0900
Subject: [PATCH] perf tools: Update srcline column length

It didn't calculate the column length so the default of header length used only. Update the length when we get the srcline actually.

---
 tools/perf/util/sort.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/perf/util/sort.c +4 -0
index 5177088a71d3..85e7e3e75d39 100644
@@ -291,6 +291,8 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
 			left->srcline = get_srcline(map->dso,
 					   map__rip_2objdump(map, left->ip),
 						    left->ms.sym, true);
+			hists__new_col_len(left->hists, HISTC_SRCLINE,
+					   strlen(left->srcline));
 		}
 	}
 	if (!right->srcline) {
@@ -301,6 +303,8 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
 			right->srcline = get_srcline(map->dso,
 					     map__rip_2objdump(map, right->ip),
 						     right->ms.sym, true);
+			hists__new_col_len(right->hists, HISTC_SRCLINE,
+					   strlen(right->srcline));
 		}
 	}
 	return strcmp(right->srcline, left->srcline);
Signature · 1 line
2.5.0
maintainer
#11 lore raw
Quoted 23 lines · Arnaldo Carvalho de Melo

Em Mon, Aug 10, 2015 at 03:32:47PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 21 lines

Em Mon, Aug 10, 2015 at 01:12:41PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 9 lines

(gdb) fr 2
#2 0x00000000004bb812 in sort__srcline_cmp (left=0x1bfa090, right=0x7fffffffc0a0) at util/sort.c:306
306 hists__new_col_len(right->hists, HISTC_SRCLINE,
(gdb) p right->hists
$7 = (struct hists *) 0x0
(gdb) p left->hists
$8 = (struct hists *) 0x18d66e0

Due to this both "-s srcline" and "-s srcfile" crashes here.

Ok, this one needs to be applied before yours and Andi's:

+++ b/tools/perf/util/hist.c

tools/perf/util/hist.c +1 -1
@@ -761,6 +761,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
 	struct hist_entry **he_cache = iter->priv;
 	struct hist_entry *he;
 	struct hist_entry he_tmp = {
+		.hists = evsel__hists(evsel),
 		.cpu = al->cpu,
---------
Quoted 8 lines
Quoted 3 lines

Because you will use that stack synthesized he_tmp entry as a parameter to the cmp() function, that will end up trying to access he_tmp->hists, that was NULL, b00m.

all this is moot, as we need to update that column length elsewhere, together with all the other fileds, please see:

://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=e8e6d37e73e6b950c891c780745460b87f4755b6

Looks good to me.

Quoted 5 lines

And now, with it really updating the width, we get to another problem, in one case I got a line like:

0.00% JS_GetInstancePrivate(JSContext*, JSObject*, JSClass*, JS /usr/lib64/libmozjs-24.so 0x1a0bd1 d [.] JS_GetInstancePrivate(JSContext*, JSObject*, JSClass*, JS::Value*)

It seems like ':' character in the symbol name affects the result for some reason.

Thanks,
Namhyung

Quoted 16 lines

Which is really strange, i.e. it mixed up demangled stuff with the srcfile, i.e. normal lines for:

perf report -v -s srcfile,dso,symbol --stdio

Look like:

     1.94%  malloc.c    /usr/lib64/libc-2.20.so   0x80f91 d [.] _int_malloc

Anyway, will continue this later, together with checking why it doesn't resolve many things, that one may be related, in some cases, to functions in assembly source files, for now it updates correctly the column width for "srcline" and "srcfile".

- Arnaldo

#12 lore raw

[tip:perf/core] perf report: Add support for srcfile sort key

In reply to Andi Kleen
perf report: Add support for srcfile sort key
Commit-ID:  31191a85fb875cf123cea56bbfd34f4b941f3c79
Gitweb:     http://git.kernel.org/tip/31191a85fb875cf123cea56bbfd34f4b941f3c79
Author:     Andi Kleen <[email protected]>
AuthorDate: Fri, 7 Aug 2015 15:54:24 -0700
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 10 Aug 2015 17:20:25 -0300

perf report: Add support for srcfile sort key

In some cases it's useful to characterize samples by file. This is useful to get a higher level categorization, for example to map cost to subsystems.

Add a srcfile sort key to perf report. It builds on top of the existing srcline support.

Commiter notes:

E.g.:

  # perf record -F 10000 usleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.016 MB perf.data (13 samples) ]
  [root@zoo ~]# perf report -s srcfile --stdio
  # Total Lost Samples: 0
  #
  # Samples: 13  of event 'cycles'
  # Event count (approx.): 869878
  #
  # Overhead  Source File
  # ........  ...........
      60.99%  .
      20.62%  paravirt.h
      14.23%  rmap.c
       4.04%  signal.c
       0.11%  msr.h

#

The first line is collecting all the files for which srcfiles couldn't somehow get resolved to:

  # perf report -s srcfile,dso --stdio
  # Total Lost Samples: 0
  #
  # Samples: 13  of event 'cycles'
  # Event count (approx.): 869878
  #
  # Overhead  Source File  Shared Object
  # ........  ...........  ................
      40.97%  .            ld-2.20.so
      20.62%  paravirt.h   [kernel.vmlinux]
      20.02%  .            libc-2.20.so
      14.23%  rmap.c       [kernel.vmlinux]
       4.04%  signal.c     [kernel.vmlinux]
       0.11%  msr.h        [kernel.vmlinux]

#

XXX: Investigate why that is not resolving on Fedora 21, Andi says he hasn't
seen this on Fedora 22.

Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
[ Added column length update, from 0e65bdb3f90f ('perf hists: Update the column width for the "srcline" sort key') ]
---
 tools/perf/Documentation/perf-report.txt |  2 ++
 tools/perf/util/hist.c                   |  5 +++
 tools/perf/util/hist.h                   |  1 +
 tools/perf/util/sort.c                   | 52 ++++++++++++++++++++++++++++++++
 tools/perf/util/sort.h                   |  2 ++
 5 files changed, 62 insertions(+)
tools/perf/Documentation/perf-report.txt +2 -0
index 1a782ef..7b07d19 100644
@@ -81,6 +81,8 @@ OPTIONS
 	- cpu: cpu number the task ran at the time of sample
 	- srcline: filename and line number executed at the time of sample.  The
 	DWARF debugging info must be provided.
+	- srcfile: file name of the source file of the same. Requires dwarf
+	information.
 	- weight: Event specific weight, e.g. memory latency or transaction
 	abort cost. This is the global weight.
 	- local_weight: Local weight version of the weight above.
tools/perf/util/hist.c +5 -0
index 608c0a7..6bccfae 100644
@@ -154,6 +154,9 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
 	if (h->srcline)
 		hists__new_col_len(hists, HISTC_SRCLINE, strlen(h->srcline));
 
+	if (h->srcfile)
+		hists__new_col_len(hists, HISTC_SRCFILE, strlen(h->srcfile));
+
 	if (h->transaction)
 		hists__new_col_len(hists, HISTC_TRANSACTION,
 				   hist_entry__transaction_len());
@@ -949,6 +952,8 @@ void hist_entry__delete(struct hist_entry *he)
 
 	zfree(&he->stat_acc);
 	free_srcline(he->srcline);
+	if (he->srcfile && he->srcfile[0])
+		free(he->srcfile);
 	free_callchain(he->callchain);
 	free(he);
 }
tools/perf/util/hist.h +1 -0
index e2f712f..bc528d5 100644
@@ -30,6 +30,7 @@ enum hist_column {
 	HISTC_PARENT,
 	HISTC_CPU,
 	HISTC_SRCLINE,
+	HISTC_SRCFILE,
 	HISTC_MISPREDICT,
 	HISTC_IN_TX,
 	HISTC_ABORT,
tools/perf/util/sort.c +52 -0

64 lines not on this page · raw message

tools/perf/util/sort.h +2 -0
index bc6c87a..3c2a399 100644
@@ -114,6 +114,7 @@ struct hist_entry {
 		};
 	};
 	char			*srcline;
+	char			*srcfile;
 	struct symbol		*parent;
 	struct rb_root		sorted_chain;
 	struct branch_info	*branch_info;
@@ -172,6 +173,7 @@ enum sort_type {
 	SORT_PARENT,
 	SORT_CPU,
 	SORT_SRCLINE,
+	SORT_SRCFILE,
 	SORT_LOCAL_WEIGHT,
 	SORT_GLOBAL_WEIGHT,
 	SORT_TRANSACTION,