Skip to contentSkip to conversation

perf top: Move hard coded list to /etc/perfconfig/symbols.skip

PATCH Applied Arnaldo Carvalho de Melo 5 participants 9 messages Jul 28, 2009 – Aug 2, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf top: Move hard coded list to /etc/perfconfig/symbols.skip

This also paves the way to add more symbol lists to be filtered out, spinlock anyone?

Cc Frederic Weisbecker <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc H. Peter Anvin <[email protected]>
---
 tools/perf/Makefile       |    6 ++++--
 tools/perf/builtin-top.c  |   26 +++++++-------------------
 tools/perf/util/strlist.c |   10 ++++++++--
 3 files changed, 19 insertions(+), 23 deletions(-)
tools/perf/Makefile +4 -2
index a5e9b87..385a1bc 100644
@@ -193,11 +193,10 @@ template_dir = share/perf-core/templates
 htmldir = share/doc/perf-doc
 ifeq ($(prefix),/usr)
 sysconfdir = /etc
-ETC_PERFCONFIG = $(sysconfdir)/perfconfig
 else
 sysconfdir = $(prefix)/etc
-ETC_PERFCONFIG = etc/perfconfig
 endif
+ETC_PERFCONFIG = $(sysconfdir)/perfconfig
 lib = lib
 # DESTDIR=
 
@@ -596,6 +595,7 @@ PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 LIBS = $(PERFLIBS) $(EXTLIBS)
 
 BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
+		-DPERF_ETC_PATH='"$(ETC_PERFCONFIG)"' \
 	$(COMPAT_CFLAGS)
 LIB_OBJS += $(COMPAT_OBJS)
 
@@ -804,6 +804,8 @@ export perfexec_instdir
 install: all
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
 	$(INSTALL) perf$X '$(DESTDIR_SQ)$(bindir_SQ)'
+	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(ETC_PERFCONFIG_SQ)'
+	$(INSTALL) symbols.skip '$(DESTDIR_SQ)$(ETC_PERFCONFIG_SQ)'
 ifdef BUILT_INS
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
 	$(INSTALL) $(BUILT_INS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
tools/perf/builtin-top.c +7 -19
index f139f1a..628ef29 100644
@@ -20,6 +20,7 @@
 
 #include "perf.h"
 
+#include "util/strlist.h"
 #include "util/symbol.h"
 #include "util/color.h"
 #include "util/util.h"
@@ -279,24 +280,12 @@ static void *display_thread(void *arg __used)
 }
 
 /* Tag samples to be skipped. */
-static const char *skip_symbols[] = {
-	"default_idle",
-	"cpu_idle",
-	"enter_idle",
-	"exit_idle",
-	"mwait_idle",
-	"mwait_idle_with_hints",
-	"ppc64_runlatch_off",
-	"pseries_dedicated_idle_sleep",
-	NULL
-};
+static struct strlist *skip_symbols;
 
 static int symbol_filter(struct dso *self, struct symbol *sym)
 {
 	static int filter_match;
-	struct sym_entry *syme;
 	const char *name = sym->name;
-	int i;
 
 	/*
 	 * ppc64 uses function descriptors and appends a '.' to the
@@ -314,12 +303,9 @@ static int symbol_filter(struct dso *self, struct symbol *sym)
 	    strstr(name, "_text_end"))
 		return 1;
 
-	syme = dso__sym_priv(self, sym);
-	for (i = 0; skip_symbols[i]; i++) {
-		if (!strcmp(skip_symbols[i], name)) {
-			syme->skip = 1;
-			break;
-		}
+	if (strlist__has_entry(skip_symbols, name)) {
+		struct sym_entry *syme = dso__sym_priv(self, sym);
+		syme->skip = 1;
 	}
 
 	if (filter_match == 1) {
@@ -733,6 +719,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
 	if (delay_secs < 1)
 		delay_secs = 1;
 
+	skip_symbols = strlist__new(true, "file://" PERF_ETC_PATH "/symbols.skip");
+
 	parse_symbols();
 
 	/*
tools/perf/util/strlist.c +8 -2
index 7ad3817..d1d63f7 100644
@@ -104,8 +104,14 @@ void strlist__remove(struct strlist *self, struct str_node *sn)
 
 bool strlist__has_entry(struct strlist *self, const char *entry)
 {
-	struct rb_node **p = &self->entries.rb_node;
-	struct rb_node *parent = NULL;
+	struct rb_node **p;
+	struct rb_node *parent;
+
+	if (self == NULL)
+		return false;
+
+	p = &self->entries.rb_node;
+	parent = NULL;
 
 	while (*p != NULL) {
 		struct str_node *sn;
Signature · 1 line
1.6.2.5
#1 lore raw
Quoted 10 lines · Arnaldo Carvalho de Melo

This also paves the way to add more symbol lists to be filtered out, spinlock anyone?

Cc Frederic Weisbecker <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc H. Peter Anvin <[email protected]>

---

I guess it would be nice to also provide a way for non-privileged users to tune it.

May be /etc/perfconfig/ and also ~/perfconfig/ ?

Quoted 126 lines
 tools/perf/Makefile       |    6 ++++--
 tools/perf/builtin-top.c  |   26 +++++++-------------------
 tools/perf/util/strlist.c |   10 ++++++++--
 3 files changed, 19 insertions(+), 23 deletions(-)
tools/perf/Makefile +4 -2
index a5e9b87..385a1bc 100644
@@ -193,11 +193,10 @@ template_dir = share/perf-core/templates
 htmldir = share/doc/perf-doc
 ifeq ($(prefix),/usr)
 sysconfdir = /etc
-ETC_PERFCONFIG = $(sysconfdir)/perfconfig
 else
 sysconfdir = $(prefix)/etc
-ETC_PERFCONFIG = etc/perfconfig
 endif
+ETC_PERFCONFIG = $(sysconfdir)/perfconfig
 lib = lib
 # DESTDIR=
 
@@ -596,6 +595,7 @@ PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 LIBS = $(PERFLIBS) $(EXTLIBS)
 
 BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
+		-DPERF_ETC_PATH='"$(ETC_PERFCONFIG)"' \
 	$(COMPAT_CFLAGS)
 LIB_OBJS += $(COMPAT_OBJS)
 
@@ -804,6 +804,8 @@ export perfexec_instdir
 install: all
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
 	$(INSTALL) perf$X '$(DESTDIR_SQ)$(bindir_SQ)'
+	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(ETC_PERFCONFIG_SQ)'
+	$(INSTALL) symbols.skip '$(DESTDIR_SQ)$(ETC_PERFCONFIG_SQ)'
 ifdef BUILT_INS
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
 	$(INSTALL) $(BUILT_INS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
tools/perf/builtin-top.c +7 -19
index f139f1a..628ef29 100644
@@ -20,6 +20,7 @@
 
 #include "perf.h"
 
+#include "util/strlist.h"
 #include "util/symbol.h"
 #include "util/color.h"
 #include "util/util.h"
@@ -279,24 +280,12 @@ static void *display_thread(void *arg __used)
 }
 
 /* Tag samples to be skipped. */
-static const char *skip_symbols[] = {
-	"default_idle",
-	"cpu_idle",
-	"enter_idle",
-	"exit_idle",
-	"mwait_idle",
-	"mwait_idle_with_hints",
-	"ppc64_runlatch_off",
-	"pseries_dedicated_idle_sleep",
-	NULL
-};
+static struct strlist *skip_symbols;
 
 static int symbol_filter(struct dso *self, struct symbol *sym)
 {
 	static int filter_match;
-	struct sym_entry *syme;
 	const char *name = sym->name;
-	int i;
 
 	/*
 	 * ppc64 uses function descriptors and appends a '.' to the
@@ -314,12 +303,9 @@ static int symbol_filter(struct dso *self, struct symbol *sym)
 	    strstr(name, "_text_end"))
 		return 1;
 
-	syme = dso__sym_priv(self, sym);
-	for (i = 0; skip_symbols[i]; i++) {
-		if (!strcmp(skip_symbols[i], name)) {
-			syme->skip = 1;
-			break;
-		}
+	if (strlist__has_entry(skip_symbols, name)) {
+		struct sym_entry *syme = dso__sym_priv(self, sym);
+		syme->skip = 1;
 	}
 
 	if (filter_match == 1) {
@@ -733,6 +719,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
 	if (delay_secs < 1)
 		delay_secs = 1;
 
+	skip_symbols = strlist__new(true, "file://" PERF_ETC_PATH "/symbols.skip");
+
 	parse_symbols();
 
 	/*
tools/perf/util/strlist.c +8 -2
index 7ad3817..d1d63f7 100644
@@ -104,8 +104,14 @@ void strlist__remove(struct strlist *self, struct str_node *sn)
 
 bool strlist__has_entry(struct strlist *self, const char *entry)
 {
-	struct rb_node **p = &self->entries.rb_node;
-	struct rb_node *parent = NULL;
+	struct rb_node **p;
+	struct rb_node *parent;
+
+	if (self == NULL)
+		return false;
+
+	p = &self->entries.rb_node;
+	parent = NULL;
 
 	while (*p != NULL) {
 		struct str_node *sn;
Signature · 1 line
1.6.2.5
#2 lore raw

Em Tue, Jul 28, 2009 at 05:18:21AM +0200, Frederic Weisbecker escreveu:

Quoted 8 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

This also paves the way to add more symbol lists to be filtered out, spinlock anyone?

I guess it would be nice to also provide a way for non-privileged users to tune it.

May be /etc/perfconfig/ and also ~/perfconfig/ ?

perf will have the same configuration system that git has, so the answer is yes, your suggestion will be implemented soon.

- Arnaldo

#3 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 2 lines · Arnaldo Carvalho de Melo

This also paves the way to add more symbol lists to be filtered out, spinlock anyone?

Generally, the way I've found is best to handle things like this is to either:

A. Have a fall-back list to use if the file isn't found, or B. Start with the fall-back list of symbols to filter, then add to them via /etc/... and ~/.perf/...

I like approaching things from the 'everything works even in a broken/hasty installation' point of view, and it's paid off for me. Sane defaults are a wonderfully useful thing.

#4 lore raw

Em Mon, Jul 27, 2009 at 08:58:08PM -0700, Ray Lee escreveu:

Quoted 7 lines
Quoted 2 lines · Arnaldo Carvalho de Melo

This also paves the way to add more symbol lists to be filtered out, spinlock anyone?

Generally, the way I've found is best to handle things like this is to either:

Quoted 7 lines

A. Have a fall-back list to use if the file isn't found, or B. Start with the fall-back list of symbols to filter, then add to them via /etc/... and ~/.perf/...

I like approaching things from the 'everything works even in a broken/hasty installation' point of view, and it's paid off for me. Sane defaults are a wonderfully useful thing.

While in general we agree with you, in this case the only problem would be that we would see a few functions on idle systems, i.e. not something catastrophic.

- Arnaldo

#5 lore raw
Quoted 7 lines · Arnaldo Carvalho de Melo
Quoted 3 lines

I like approaching things from the 'everything works even in a broken/hasty installation' point of view, and it's paid off for me. Sane defaults are a wonderfully useful thing.

While in general we agree with you, in this case the only problem would be that we would see a few functions on idle systems, i.e. not something catastrophic.

This is userspace we're talking about here. Where's the harm in getting things right by default?

#6 lore raw
In reply to Ray Lee
Quoted 7 lines · Ray Lee
Quoted 2 lines · Arnaldo Carvalho de Melo

This also paves the way to add more symbol lists to be filtered out, spinlock anyone?

Generally, the way I've found is best to handle things like this is to either:

Quoted 7 lines

A. Have a fall-back list to use if the file isn't found, or B. Start with the fall-back list of symbols to filter, then add to them via /etc/... and ~/.perf/...

I like approaching things from the 'everything works even in a broken/hasty installation' point of view, and it's paid off for me. Sane defaults are a wonderfully useful thing.

Agreed.

Also, i'd not pollute /etc just yet, please lets define a good default built-in list like we have now, and perhaps enable the extension of it via .perf/config.

Tools should work well by default.

Ingo

#7 lore raw

Em Sun, Aug 02, 2009 at 09:55:33PM +0200, Ingo Molnar escreveu:

Quoted 18 lines · Ray Lee
Quoted 8 lines
Quoted 2 lines · Arnaldo Carvalho de Melo

This also paves the way to add more symbol lists to be filtered out, spinlock anyone?

Generally, the way I've found is best to handle things like this is to either:

Quoted 7 lines

A. Have a fall-back list to use if the file isn't found, or B. Start with the fall-back list of symbols to filter, then add to them via /etc/... and ~/.perf/...

I like approaching things from the 'everything works even in a broken/hasty installation' point of view, and it's paid off for me. Sane defaults are a wonderfully useful thing.

Quoted 7 lines

Agreed.

Also, i'd not pollute /etc just yet, please lets define a good default built-in list like we have now, and perhaps enable the extension of it via .perf/config.

Tools should work well by default.

OK, I'll rework the patch and resubmit it.

- Arnaldo

#8 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 2 lines · Arnaldo Carvalho de Melo

This also paves the way to add more symbol lists to be filtered out, spinlock anyone?

Doesn't seem like a good idea to filter out symbols that actually affect performance -- such as spinlocks.

But yeah, the patch makes sense and allows people to mess up their own environments :-)

Queued this and the previous one, Thanks!