Skip to contentSkip to conversation

more perf updates for v3.6

GIT PULL Ingo Molnar 3 participants 5 messages Jul 31, 2012 – Aug 1, 2012

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest perf-core-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-core-for-linus

HEAD: 194f8dcbe9629d8e9346cf96345a9c0bbf0e67ae uprobes: __replace_page() needs munlock_vma_page()

These are some late-coming changes for v3.6.

The biggest changes are Intel Nehalem-EX PMU uncore support, uprobes updates/cleanups/fixes from Oleg and diverse tooling updates (mostly fixes) now that Arnaldo is back from vacation.

Thanks,

Ingo

------------------>
Andrew Vagin (1):
sched: Deliver sched_switch events to the current task

Cody Schafer (1):
perf annotate: Prevent overflow in size calculation

David Ahern (6):
perf symbols: Add machine id to modules debug message
perf kvm: Set name for VM process in guest machine
perf kvm: Guest userspace samples should not be lumped with host uspace perf kvm: Fix bug resolving guest kernel syms
perf kvm: Limit repetitive guestmount message to once per directory perf tools: Dump exclude_{guest,host}, precise_ip header info too

Frederic Weisbecker (3):
perf hists: Return correct number of characters printed in callchain perf tools: Fix trace events storms due to weight demux perf hists: Print newline between hists callchains

Jiri Olsa (4):
perf symbols: Factor DSO symtab types to generic binary types perf symbols: Add interface to read DSO image data perf symbols: Add dso data caching
perf test: Add dso data caching tests

Jovi Zhang (2):
perf tools: Make the breakpoint events sample period default to 1 perf/x86: Fix missing struct before structure name

Kirill A. Shutemov (2):
perf tools: use XSI-complaint version of strerror_r() instead of GNU-specific perf tools: Fix build error with bison 2.6

Namhyung Kim (2):
tools lib traceevent: Detect build environment changes tools lib traceevent: Ignore TRACEEVENT-CFLAGS file

Oleg Nesterov (14):
uprobes: Don't recheck vma/f_mapping in write_opcode()
uprobes: __replace_page() should not use page_address_in_vma()
uprobes: Kill write_opcode()->lock_page(new_page)
uprobes: Clean up and document write_opcode()->lock_page(old_page)
uprobes: Uprobe_mmap/munmap needs list_for_each_entry_safe()
uprobes: Suppress uprobe_munmap() from mmput()
uprobes: Fix overflow in vma_address()/find_active_uprobe()
uprobes: Remove copy_vma()->uprobe_mmap()
uprobes: Remove insert_vm_struct()->uprobe_mmap()
uprobes: Teach build_probe_list() to consider the range
uprobes: Introduce vaddr_to_offset(vma, vaddr)
uprobes: Fix register_for_each_vma()->vma_address() check
uprobes: Rename vma_address() and make it return "unsigned long"
uprobes: __replace_page() needs munlock_vma_page()

Peter Zijlstra (1):
perf/x86: Make bitfield unsigned

Yan, Zheng (4):
perf/x86: Fix typo in format definition of uncore PCU filter perf/x86: Add Intel Nehalem-EX uncore support perf/x86: Fix LLC-* and node-* events on Intel SandyBridge perf/x86: Fix format definition of SNB-EP uncore QPI box

 arch/x86/include/asm/perf_event.h             |    2 +-
 arch/x86/kernel/cpu/perf_event.h              |    2 +-
 arch/x86/kernel/cpu/perf_event_intel.c        |   92 +-
 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 1522 +++++++++++++++++++++----
 arch/x86/kernel/cpu/perf_event_intel_uncore.h |  207 +++-
 kernel/events/uprobes.c                       |  213 ++--
 kernel/sched/core.c                           |    2 +-
 mm/mmap.c                                     |    6 -
 tools/lib/traceevent/.gitignore               |    1 +
 tools/lib/traceevent/Makefile                 |   14 +-
 tools/perf/Makefile                           |    4 +
 tools/perf/builtin-test.c                     |    4 +
 tools/perf/builtin-top.c                      |    2 +-
 tools/perf/ui/browsers/hists.c                |    4 +-
 tools/perf/util/annotate.c                    |   15 +-
 tools/perf/util/dso-test-data.c               |  153 +++
 tools/perf/util/evlist.c                      |    2 +-
 tools/perf/util/header.c                      |    6 +
 tools/perf/util/hist.c                        |    7 +-
 tools/perf/util/map.c                         |   41 +-
 tools/perf/util/map.h                         |    1 +
 tools/perf/util/parse-events.c                |    2 +
 tools/perf/util/session.c                     |    5 +-
 tools/perf/util/symbol.c                      |  447 ++++++--
 tools/perf/util/symbol.h                      |   54 +-
 tools/perf/util/target.c                      |   11 +-
 26 files changed, 2331 insertions(+), 488 deletions(-)
 create mode 100644 tools/lib/traceevent/.gitignore
 create mode 100644 tools/perf/util/dso-test-data.c
arch/x86/include/asm/perf_event.h +1 -1
index c78f14a..dab3935 100644
@@ -234,7 +234,7 @@ extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr);
 extern void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap);
 extern void perf_check_microcode(void);
 #else
-static inline perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
+static inline struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
 {
 	*nr = 0;
 	return NULL;
arch/x86/kernel/cpu/perf_event.h +1 -1
index a15df4b..821d53b 100644
@@ -374,7 +374,7 @@ struct x86_pmu {
 	/*
 	 * Intel DebugStore bits
 	 */
-	int		bts		:1,
+	unsigned int	bts		:1,
 			bts_active	:1,
 			pebs		:1,
 			pebs_active	:1,
arch/x86/kernel/cpu/perf_event_intel.c +86 -6

114 lines not on this page · raw message

arch/x86/kernel/cpu/perf_event_intel_uncore.c +1286 -236

1,769 lines not on this page · raw message

arch/x86/kernel/cpu/perf_event_intel_uncore.h +202 -5

252 lines not on this page · raw message

kernel/events/uprobes.c +97 -116

365 lines not on this page · raw message

kernel/sched/core.c +1 -1
index 468bdd4..ad732b5 100644
@@ -1910,12 +1910,12 @@ static inline void
 prepare_task_switch(struct rq *rq, struct task_struct *prev,
 		    struct task_struct *next)
 {
+	trace_sched_switch(prev, next);
 	sched_info_switch(prev, next);
 	perf_event_task_sched_out(prev, next);
 	fire_sched_out_preempt_notifiers(prev, next);
 	prepare_lock_switch(rq, next);
 	prepare_arch_switch(next);
-	trace_sched_switch(prev, next);
 }
 
 /**
mm/mmap.c +0 -6
index 3edfcdf..4fe2697 100644
@@ -2345,9 +2345,6 @@ int insert_vm_struct(struct mm_struct * mm, struct vm_area_struct * vma)
 	     security_vm_enough_memory_mm(mm, vma_pages(vma)))
 		return -ENOMEM;
 
-	if (vma->vm_file && uprobe_mmap(vma))
-		return -EINVAL;
-
 	vma_link(mm, vma, prev, rb_link, rb_parent);
 	return 0;
 }
@@ -2418,9 +2415,6 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
 			if (new_vma->vm_file) {
 				get_file(new_vma->vm_file);
 
-				if (uprobe_mmap(new_vma))
-					goto out_free_mempol;
-
 				if (vma->vm_flags & VM_EXECUTABLE)
 					added_exe_file_vma(mm);
 			}
tools/lib/traceevent/.gitignore new file +1 -0
new file mode 100644
index 0000000..35f56be
@@ -0,0 +1 @@
+TRACEEVENT-CFLAGS
tools/lib/traceevent/Makefile +12 -2
index 46c2f6b..14131cb 100644
@@ -207,7 +207,7 @@ libtraceevent.so: $(PEVENT_LIB_OBJS)
 libtraceevent.a: $(PEVENT_LIB_OBJS)
 	$(Q)$(do_build_static_lib)
 
-$(PEVENT_LIB_OBJS): %.o: $(src)/%.c
+$(PEVENT_LIB_OBJS): %.o: $(src)/%.c TRACEEVENT-CFLAGS
 	$(Q)$(do_fpic_compile)
 
 define make_version.h
@@ -272,6 +272,16 @@ ifneq ($(dep_includes),)
  include $(dep_includes)
 endif
 
+### Detect environment changes
+TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):$(ARCH):$(CROSS_COMPILE)
+
+TRACEEVENT-CFLAGS: force
+	@FLAGS='$(TRACK_CFLAGS)'; \
+	    if test x"$$FLAGS" != x"`cat TRACEEVENT-CFLAGS 2>/dev/null`" ; then \
+		echo 1>&2 "    * new build flags or cross compiler"; \
+		echo "$$FLAGS" >TRACEEVENT-CFLAGS; \
+            fi
+
 tags:	force
 	$(RM) tags
 	find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
@@ -297,7 +307,7 @@ install: install_lib
 
 clean:
 	$(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d
-	$(RM) tags TAGS
+	$(RM) TRACEEVENT-CFLAGS tags TAGS
 
 endif # skip-makefile
 
tools/perf/Makefile +4 -0
index 75d74e5..77f124f 100644
@@ -354,6 +354,7 @@ LIB_OBJS += $(OUTPUT)util/usage.o
 LIB_OBJS += $(OUTPUT)util/wrapper.o
 LIB_OBJS += $(OUTPUT)util/sigchain.o
 LIB_OBJS += $(OUTPUT)util/symbol.o
+LIB_OBJS += $(OUTPUT)util/dso-test-data.o
 LIB_OBJS += $(OUTPUT)util/color.o
 LIB_OBJS += $(OUTPUT)util/pager.o
 LIB_OBJS += $(OUTPUT)util/header.o
@@ -803,6 +804,9 @@ $(OUTPUT)ui/browsers/map.o: ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
 $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
 	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
 
+$(OUTPUT)util/parse-events.o: util/parse-events.c $(OUTPUT)PERF-CFLAGS
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls $<
+
 $(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
 	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
 
tools/perf/builtin-test.c +4 -0
index 5ce3030..d909eb7 100644
@@ -1142,6 +1142,10 @@ static struct test {
 		.func = test__perf_pmu,
 	},
 	{
+		.desc = "Test dso data interface",
+		.func = dso__test_data,
+	},
+	{
 		.func = NULL,
 	},
 };
tools/perf/builtin-top.c +1 -1
index e3cab5f..35e86c6 100644
@@ -125,7 +125,7 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
 	/*
 	 * We can't annotate with just /proc/kallsyms
 	 */
-	if (map->dso->symtab_type == SYMTAB__KALLSYMS) {
+	if (map->dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS) {
 		pr_err("Can't annotate %s: No vmlinux file was found in the "
 		       "path\n", sym->name);
 		sleep(1);
tools/perf/ui/browsers/hists.c +2 -2
index 482f051..413bd62 100644
@@ -978,8 +978,8 @@ static int hist_browser__dump(struct hist_browser *browser)
 	fp = fopen(filename, "w");
 	if (fp == NULL) {
 		char bf[64];
-		strerror_r(errno, bf, sizeof(bf));
-		ui_helpline__fpush("Couldn't write to %s: %s", filename, bf);
+		const char *err = strerror_r(errno, bf, sizeof(bf));
+		ui_helpline__fpush("Couldn't write to %s: %s", filename, err);
 		return -1;
 	}
 
tools/perf/util/annotate.c +13 -2
index 8069dfb..3a282c0 100644
@@ -426,7 +426,18 @@ int symbol__alloc_hist(struct symbol *sym)
 {
 	struct annotation *notes = symbol__annotation(sym);
 	const size_t size = symbol__size(sym);
-	size_t sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(u64));
+	size_t sizeof_sym_hist;
+
+	/* Check for overflow when calculating sizeof_sym_hist */
+	if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(u64))
+		return -1;
+
+	sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(u64));
+
+	/* Check for overflow in zalloc argument */
+	if (sizeof_sym_hist > (SIZE_MAX - sizeof(*notes->src))
+				/ symbol_conf.nr_events)
+		return -1;
 
 	notes->src = zalloc(sizeof(*notes->src) + symbol_conf.nr_events * sizeof_sym_hist);
 	if (notes->src == NULL)
@@ -777,7 +788,7 @@ fallback:
 		free_filename = false;
 	}
 
-	if (dso->symtab_type == SYMTAB__KALLSYMS) {
+	if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS) {
 		char bf[BUILD_ID_SIZE * 2 + 16] = " with build id ";
 		char *build_id_msg = NULL;
 
tools/perf/util/dso-test-data.c new file +153 -0

153 lines not on this page · raw message

tools/perf/util/evlist.c +1 -1
index f74e956..3edfd34 100644
@@ -214,7 +214,7 @@ int perf_evlist__add_tracepoints(struct perf_evlist *evlist,
 		attrs[i].type	       = PERF_TYPE_TRACEPOINT;
 		attrs[i].config	       = err;
 	        attrs[i].sample_type   = (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME |
-					  PERF_SAMPLE_CPU);
+					  PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD);
 		attrs[i].sample_period = 1;
 	}
 
tools/perf/util/header.c +6 -0
index 5a47aba..3a6d204 100644
@@ -1212,6 +1212,12 @@ static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)
 				attr.exclude_user,
 				attr.exclude_kernel);
 
+		fprintf(fp, ", excl_host = %d, excl_guest = %d",
+				attr.exclude_host,
+				attr.exclude_guest);
+
+		fprintf(fp, ", precise_ip = %d", attr.precise_ip);
+
 		if (nr)
 			fprintf(fp, ", id = {");
 
tools/perf/util/hist.c +5 -2
index 514e2a4..f247ef2 100644
@@ -708,7 +708,7 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
 	bool printed = false;
 	struct rb_node *node;
 	int i = 0;
-	int ret;
+	int ret = 0;
 
 	/*
 	 * If have one single callchain root, don't bother printing
@@ -747,8 +747,11 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
 		root = &cnode->rb_root;
 	}
 
-	return __callchain__fprintf_graph(fp, root, total_samples,
+	ret += __callchain__fprintf_graph(fp, root, total_samples,
 					  1, 1, left_margin);
+	ret += fprintf(fp, "\n");
+
+	return ret;
 }
 
 static size_t __callchain__fprintf_flat(FILE *fp,
tools/perf/util/map.c +39 -2

62 lines not on this page · raw message

tools/perf/util/map.h +1 -0
index c14c665..03a1e9b 100644
@@ -151,6 +151,7 @@ struct machine *machines__add(struct rb_root *self, pid_t pid,
 struct machine *machines__find_host(struct rb_root *self);
 struct machine *machines__find(struct rb_root *self, pid_t pid);
 struct machine *machines__findnew(struct rb_root *self, pid_t pid);
+void machines__set_id_hdr_size(struct rb_root *self, u16 id_hdr_size);
 char *machine__mmap_name(struct machine *self, char *bf, size_t size);
 int machine__init(struct machine *self, const char *root_dir, pid_t pid);
 void machine__exit(struct machine *self);
tools/perf/util/parse-events.c +2 -0
index 1aa721d..74a5af4 100644
@@ -377,6 +377,7 @@ static int add_tracepoint(struct list_head **list, int *idx,
 	attr.sample_type |= PERF_SAMPLE_RAW;
 	attr.sample_type |= PERF_SAMPLE_TIME;
 	attr.sample_type |= PERF_SAMPLE_CPU;
+	attr.sample_type |= PERF_SAMPLE_PERIOD;
 	attr.sample_period = 1;
 
 	snprintf(name, MAX_NAME_LEN, "%s:%s", sys_name, evt_name);
@@ -489,6 +490,7 @@ int parse_events_add_breakpoint(struct list_head **list, int *idx,
 		attr.bp_len = HW_BREAKPOINT_LEN_4;
 
 	attr.type = PERF_TYPE_BREAKPOINT;
+	attr.sample_period = 1;
 
 	return add_event(list, idx, &attr, NULL);
 }
tools/perf/util/session.c +4 -1
index 8e48559..8e4f075 100644
@@ -87,6 +87,7 @@ void perf_session__update_sample_type(struct perf_session *self)
 	self->sample_id_all = perf_evlist__sample_id_all(self->evlist);
 	self->id_hdr_size = perf_evlist__id_hdr_size(self->evlist);
 	self->host_machine.id_hdr_size = self->id_hdr_size;
+	machines__set_id_hdr_size(&self->machines, self->id_hdr_size);
 }
 
 int perf_session__create_kernel_maps(struct perf_session *self)
@@ -918,7 +919,9 @@ static struct machine *
 {
 	const u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
 
-	if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) {
+	if (perf_guest &&
+	    ((cpumode == PERF_RECORD_MISC_GUEST_KERNEL) ||
+	     (cpumode == PERF_RECORD_MISC_GUEST_USER))) {
 		u32 pid;
 
 		if (event->header.type == PERF_RECORD_MMAP)
tools/perf/util/symbol.c +361 -86

56 lines not on this page · raw message

tools/perf/util/symbol.h +38 -16

54 lines not on this page · raw message

tools/perf/util/target.c +10 -1
index 1064d5b..3f59c49 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#1 lore raw

Re: perf: commit 44f24cb3156a1e (Factor DSO symtab types) causes segfaults

Quoted 2 lines · Ingo Molnar

Jiri Olsa (4):
perf symbols: Factor DSO symtab types to generic binary types

The commit above causes perf segfaults on my machine (running glibc trunk):

(gdb) run top --stdio
Starting program: /usr/src/linux/tools/perf/perf top --stdio
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000 [Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
dso__load (dso=0x6661d0, map=map@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/symbol.c:1833
1833 dso->symtab_type = binary_type_symtab[i];
(gdb) bt

#0  dso__load (dso=0x6661d0, map=map@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/symbol.c:1833
#1  0x000000000045fe87 in map__load (self=self@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/map.c:124
#2  0x000000000045ffbd in map__find_symbol (self=0x666170, addr=11008, filter=filter@entry=0x426840 <symbol_filter>) at util/map.c:168
#3  0x000000000043b5df in perf_event__preprocess_sample (event=event@entry=0x7ffff44c8720, machine=machine@entry=0x647730, 
    al=al@entry=0x7fffffffb030, sample=sample@entry=0x7fffffffb060, filter=filter@entry=0x426840 <symbol_filter>) at util/event.c:886
#4  0x0000000000426d8e in perf_event__process_sample (machine=0x647730, sample=0x7fffffffb060, evsel=<optimized out>, event=0x7ffff44c8720, 
    tool=0x7fffffffb2c0) at builtin-top.c:723
#5  perf_top__mmap_read_idx (top=top@entry=0x7fffffffb2c0, idx=idx@entry=3) at builtin-top.c:858
#6  0x00000000004291c3 in perf_top__mmap_read (top=<optimized out>) at builtin-top.c:873
#7  __cmd_top (top=0x7fffffffb2c0) at builtin-top.c:1040
#8  cmd_top (argc=<optimized out>, argv=<optimized out>, prefix=<optimized out>) at builtin-top.c:1348
#9  0x0000000000414d03 in run_builtin (p=p@entry=0x4dc888, argc=argc@entry=2, argv=argv@entry=0x7fffffffe0b0) at perf.c:273

#10 0x0000000000415487 in handle_internal_command (argv=0x7fffffffe0b0, argc=2) at perf.c:345 #11 run_argv (argv=0x7fffffffdeb0, argcp=0x7fffffffdebc) at perf.c:389
#12 main (argc=2, argv=0x7fffffffe0b0) at perf.c:487
(gdb)

44f24cb3156a1e7d2b6bb501b7f6153aed08994c is the first bad commit commit 44f24cb3156a1e7d2b6bb501b7f6153aed08994c

Author: Jiri Olsa <[email protected]>
Date:   Sun Jul 22 14:14:32 2012 +0200

perf symbols: Factor DSO symtab types to generic binary types

Signature · 1 line
Markus
#2 lore raw

Re: perf: commit 44f24cb3156a1e (Factor DSO symtab types) causes segfaults

Quoted 28 lines · Markus Trippelsdorf
Quoted 2 lines · Ingo Molnar

Jiri Olsa (4):
perf symbols: Factor DSO symtab types to generic binary types

The commit above causes perf segfaults on my machine (running glibc trunk):

(gdb) run top --stdio
Starting program: /usr/src/linux/tools/perf/perf top --stdio
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000 [Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
dso__load (dso=0x6661d0, map=map@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/symbol.c:1833
1833 dso->symtab_type = binary_type_symtab[i];
(gdb) bt

#0  dso__load (dso=0x6661d0, map=map@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/symbol.c:1833
#1  0x000000000045fe87 in map__load (self=self@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/map.c:124
#2  0x000000000045ffbd in map__find_symbol (self=0x666170, addr=11008, filter=filter@entry=0x426840 <symbol_filter>) at util/map.c:168
#3  0x000000000043b5df in perf_event__preprocess_sample (event=event@entry=0x7ffff44c8720, machine=machine@entry=0x647730, 
    al=al@entry=0x7fffffffb030, sample=sample@entry=0x7fffffffb060, filter=filter@entry=0x426840 <symbol_filter>) at util/event.c:886
#4  0x0000000000426d8e in perf_event__process_sample (machine=0x647730, sample=0x7fffffffb060, evsel=<optimized out>, event=0x7ffff44c8720, 
    tool=0x7fffffffb2c0) at builtin-top.c:723
#5  perf_top__mmap_read_idx (top=top@entry=0x7fffffffb2c0, idx=idx@entry=3) at builtin-top.c:858
#6  0x00000000004291c3 in perf_top__mmap_read (top=<optimized out>) at builtin-top.c:873
#7  __cmd_top (top=0x7fffffffb2c0) at builtin-top.c:1040
#8  cmd_top (argc=<optimized out>, argv=<optimized out>, prefix=<optimized out>) at builtin-top.c:1348
#9  0x0000000000414d03 in run_builtin (p=p@entry=0x4dc888, argc=argc@entry=2, argv=argv@entry=0x7fffffffe0b0) at perf.c:273
Quoted 4 lines

#10 0x0000000000415487 in handle_internal_command (argv=0x7fffffffe0b0, argc=2) at perf.c:345 #11 run_argv (argv=0x7fffffffdeb0, argcp=0x7fffffffdebc) at perf.c:389
#12 main (argc=2, argv=0x7fffffffe0b0) at perf.c:487
(gdb)

hi,
I cannot reproduce, but found one obvious bug,
could you please test?

thanks,
jirka

---
 tools/perf/util/symbol.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/symbol.c +2 -2
index fdad4eee..fe86612 100644
@@ -64,7 +64,7 @@ static enum dso_binary_type binary_type_symtab[] = {
 	DSO_BINARY_TYPE__NOT_FOUND,
 };
 
-#define DSO_BINARY_TYPE__SYMTAB_CNT sizeof(binary_type_symtab)
+#define DSO_BINARY_TYPE__SYMTAB_CNT ARRAY_SIZE(binary_type_symtab)
 
 static enum dso_binary_type binary_type_data[] = {
 	DSO_BINARY_TYPE__BUILD_ID_CACHE,
@@ -72,7 +72,7 @@ static enum dso_binary_type binary_type_data[] = {
 	DSO_BINARY_TYPE__NOT_FOUND,
 };
 
-#define DSO_BINARY_TYPE__DATA_CNT sizeof(binary_type_data)
+#define DSO_BINARY_TYPE__DATA_CNT ARRAY_SIZE(binary_type_data)
 
 int dso__name_len(const struct dso *dso)
 {
Signature · 1 line
1.7.7.6
#3 lore raw

Re: perf: commit 44f24cb3156a1e (Factor DSO symtab types) causes segfaults

Quoted 34 lines · Jiri Olsa
Quoted 28 lines · Markus Trippelsdorf
Quoted 2 lines · Ingo Molnar

Jiri Olsa (4):
perf symbols: Factor DSO symtab types to generic binary types

The commit above causes perf segfaults on my machine (running glibc trunk):

(gdb) run top --stdio
Starting program: /usr/src/linux/tools/perf/perf top --stdio
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000 [Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
dso__load (dso=0x6661d0, map=map@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/symbol.c:1833
1833 dso->symtab_type = binary_type_symtab[i];
(gdb) bt

#0  dso__load (dso=0x6661d0, map=map@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/symbol.c:1833
#1  0x000000000045fe87 in map__load (self=self@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/map.c:124
#2  0x000000000045ffbd in map__find_symbol (self=0x666170, addr=11008, filter=filter@entry=0x426840 <symbol_filter>) at util/map.c:168
#3  0x000000000043b5df in perf_event__preprocess_sample (event=event@entry=0x7ffff44c8720, machine=machine@entry=0x647730, 
    al=al@entry=0x7fffffffb030, sample=sample@entry=0x7fffffffb060, filter=filter@entry=0x426840 <symbol_filter>) at util/event.c:886
#4  0x0000000000426d8e in perf_event__process_sample (machine=0x647730, sample=0x7fffffffb060, evsel=<optimized out>, event=0x7ffff44c8720, 
    tool=0x7fffffffb2c0) at builtin-top.c:723
#5  perf_top__mmap_read_idx (top=top@entry=0x7fffffffb2c0, idx=idx@entry=3) at builtin-top.c:858
#6  0x00000000004291c3 in perf_top__mmap_read (top=<optimized out>) at builtin-top.c:873
#7  __cmd_top (top=0x7fffffffb2c0) at builtin-top.c:1040
#8  cmd_top (argc=<optimized out>, argv=<optimized out>, prefix=<optimized out>) at builtin-top.c:1348
#9  0x0000000000414d03 in run_builtin (p=p@entry=0x4dc888, argc=argc@entry=2, argv=argv@entry=0x7fffffffe0b0) at perf.c:273
Quoted 4 lines

#10 0x0000000000415487 in handle_internal_command (argv=0x7fffffffe0b0, argc=2) at perf.c:345 #11 run_argv (argv=0x7fffffffdeb0, argcp=0x7fffffffdebc) at perf.c:389
#12 main (argc=2, argv=0x7fffffffe0b0) at perf.c:487
(gdb)

Quoted 2 lines

I cannot reproduce, but found one obvious bug,
could you please test?

Your patch fixes the issue.
Thank you.

Signature · 1 line
Markus
#4 lore raw

Re: perf: commit 44f24cb3156a1e (Factor DSO symtab types) causes segfaults

Quoted 35 lines · Markus Trippelsdorf
Quoted 33 lines · Jiri Olsa
Quoted 32 lines · Markus Trippelsdorf
Quoted 2 lines · Ingo Molnar

Jiri Olsa (4):
perf symbols: Factor DSO symtab types to generic binary types

The commit above causes perf segfaults on my machine (running glibc trunk):

(gdb) run top --stdio
Starting program: /usr/src/linux/tools/perf/perf top --stdio
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000 [Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
dso__load (dso=0x6661d0, map=map@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/symbol.c:1833
1833 dso->symtab_type = binary_type_symtab[i];
(gdb) bt

#0  dso__load (dso=0x6661d0, map=map@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/symbol.c:1833
#1  0x000000000045fe87 in map__load (self=self@entry=0x666170, filter=filter@entry=0x426840 <symbol_filter>) at util/map.c:124
#2  0x000000000045ffbd in map__find_symbol (self=0x666170, addr=11008, filter=filter@entry=0x426840 <symbol_filter>) at util/map.c:168
#3  0x000000000043b5df in perf_event__preprocess_sample (event=event@entry=0x7ffff44c8720, machine=machine@entry=0x647730, 
    al=al@entry=0x7fffffffb030, sample=sample@entry=0x7fffffffb060, filter=filter@entry=0x426840 <symbol_filter>) at util/event.c:886
#4  0x0000000000426d8e in perf_event__process_sample (machine=0x647730, sample=0x7fffffffb060, evsel=<optimized out>, event=0x7ffff44c8720, 
    tool=0x7fffffffb2c0) at builtin-top.c:723
#5  perf_top__mmap_read_idx (top=top@entry=0x7fffffffb2c0, idx=idx@entry=3) at builtin-top.c:858
#6  0x00000000004291c3 in perf_top__mmap_read (top=<optimized out>) at builtin-top.c:873
#7  __cmd_top (top=0x7fffffffb2c0) at builtin-top.c:1040
#8  cmd_top (argc=<optimized out>, argv=<optimized out>, prefix=<optimized out>) at builtin-top.c:1348
#9  0x0000000000414d03 in run_builtin (p=p@entry=0x4dc888, argc=argc@entry=2, argv=argv@entry=0x7fffffffe0b0) at perf.c:273

#10 0x0000000000415487 in handle_internal_command (argv=0x7fffffffe0b0, argc=2) at perf.c:345 #11 run_argv (argv=0x7fffffffdeb0, argcp=0x7fffffffdebc) at perf.c:389
#12 main (argc=2, argv=0x7fffffffe0b0) at perf.c:487
(gdb)

Quoted 5 lines
Quoted 2 lines

I cannot reproduce, but found one obvious bug,
could you please test?

Your patch fixes the issue.
Thank you.

thanks, I'll send official patch ASAP

jirka