Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1202261 > unrolled thread

[PATCH RFC V9 1/3] perf,tools: move callchain option parse code to util.c

Started bykan.liang@intel.com
First post2015-08-07 05:10 +0200
Last post2015-08-12 14:30 +0200
Articles 17 — 6 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH RFC V9 1/3] perf,tools: move callchain option parse code to util.c kan.liang@intel.com - 2015-08-07 05:10 +0200
    [PATCH RFC V9 2/3] perf,tools: per-event callgraph support kan.liang@intel.com - 2015-08-07 05:10 +0200
      Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Jiri Olsa <jolsa@redhat.com> - 2015-08-07 13:00 +0200
      Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-07 17:50 +0200
        Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Jiri Olsa <jolsa@redhat.com> - 2015-08-08 18:50 +0200
          Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-08 19:40 +0200
        RE: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support "Liang, Kan" <kan.liang@intel.com> - 2015-08-10 15:00 +0200
          Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-10 17:40 +0200
            RE: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support "Liang, Kan" <kan.liang@intel.com> - 2015-08-10 21:00 +0200
              Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-10 21:40 +0200
      Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-07 18:00 +0200
        [PATCH] perf tools: Unset perf_event_attr::freq when period term is  set Jiri Olsa <jolsa@redhat.com> - 2015-08-08 19:20 +0200
          [tip:perf/core] perf tools: Unset perf_event_attr::  freq when period term is set tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-08-12 14:40 +0200
    [PATCH] perf tools: Move perf_counts struct and functions into  separate object Jiri Olsa <jolsa@redhat.com> - 2015-08-07 13:00 +0200
      Re: [PATCH] perf tools: Move perf_counts struct and functions into  separate object Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-07 15:20 +0200
      [tip:perf/core] perf stat:   Move perf_counts struct and functions into separate object tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-08-12 14:30 +0200
    [tip:perf/core] perf callchain:   Move option parsing code to util.c tip-bot for Kan Liang <tipbot@zytor.com> - 2015-08-12 14:30 +0200

#1202261 — [PATCH RFC V9 1/3] perf,tools: move callchain option parse code to util.c

Fromkan.liang@intel.com
Date2015-08-07 05:10 +0200
Subject[PATCH RFC V9 1/3] perf,tools: move callchain option parse code to util.c
Message-ID<pUGcG-3xm-7@gated-at.bofh.it>
From: Kan Liang <kan.liang@intel.com>

Move callchain option parse related code to util.c

Signed-off-by: Kan Liang <kan.liang@intel.com>
---

Changes since V8:
 - Fix the link problems found by perf python test case.
   Introduce the patch to move callchain option parse related code to util.c
   
 tools/perf/util/callchain.c | 89 +-------------------------------------------
 tools/perf/util/callchain.h |  1 +
 tools/perf/util/util.c      | 90 +++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/util.h      |  2 +
 4 files changed, 94 insertions(+), 88 deletions(-)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 931cca8..773fe13 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -25,96 +25,9 @@
 
 __thread struct callchain_cursor callchain_cursor;
 
-#ifdef HAVE_DWARF_UNWIND_SUPPORT
-static int get_stack_size(const char *str, unsigned long *_size)
-{
-	char *endptr;
-	unsigned long size;
-	unsigned long max_size = round_down(USHRT_MAX, sizeof(u64));
-
-	size = strtoul(str, &endptr, 0);
-
-	do {
-		if (*endptr)
-			break;
-
-		size = round_up(size, sizeof(u64));
-		if (!size || size > max_size)
-			break;
-
-		*_size = size;
-		return 0;
-
-	} while (0);
-
-	pr_err("callchain: Incorrect stack dump size (max %ld): %s\n",
-	       max_size, str);
-	return -1;
-}
-#endif /* HAVE_DWARF_UNWIND_SUPPORT */
-
 int parse_callchain_record_opt(const char *arg, struct callchain_param *param)
 {
-	char *tok, *name, *saveptr = NULL;
-	char *buf;
-	int ret = -1;
-
-	/* We need buffer that we know we can write to. */
-	buf = malloc(strlen(arg) + 1);
-	if (!buf)
-		return -ENOMEM;
-
-	strcpy(buf, arg);
-
-	tok = strtok_r((char *)buf, ",", &saveptr);
-	name = tok ? : (char *)buf;
-
-	do {
-		/* Framepointer style */
-		if (!strncmp(name, "fp", sizeof("fp"))) {
-			if (!strtok_r(NULL, ",", &saveptr)) {
-				param->record_mode = CALLCHAIN_FP;
-				ret = 0;
-			} else
-				pr_err("callchain: No more arguments "
-				       "needed for --call-graph fp\n");
-			break;
-
-#ifdef HAVE_DWARF_UNWIND_SUPPORT
-		/* Dwarf style */
-		} else if (!strncmp(name, "dwarf", sizeof("dwarf"))) {
-			const unsigned long default_stack_dump_size = 8192;
-
-			ret = 0;
-			param->record_mode = CALLCHAIN_DWARF;
-			param->dump_size = default_stack_dump_size;
-
-			tok = strtok_r(NULL, ",", &saveptr);
-			if (tok) {
-				unsigned long size = 0;
-
-				ret = get_stack_size(tok, &size);
-				param->dump_size = size;
-			}
-#endif /* HAVE_DWARF_UNWIND_SUPPORT */
-		} else if (!strncmp(name, "lbr", sizeof("lbr"))) {
-			if (!strtok_r(NULL, ",", &saveptr)) {
-				param->record_mode = CALLCHAIN_LBR;
-				ret = 0;
-			} else
-				pr_err("callchain: No more arguments "
-					"needed for --call-graph lbr\n");
-			break;
-		} else {
-			pr_err("callchain: Unknown --call-graph option "
-			       "value: %s\n", arg);
-			break;
-		}
-
-	} while (0);
-
-	free(buf);
-	return ret;
+	return parse_callchain_record(arg, param);
 }
 
 static int parse_callchain_mode(const char *value)
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 68a32c2..acee2b3 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -177,6 +177,7 @@ int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *
 			bool hide_unresolved);
 
 extern const char record_callchain_help[];
+extern int parse_callchain_record(const char *arg, struct callchain_param *param);
 int parse_callchain_record_opt(const char *arg, struct callchain_param *param);
 int parse_callchain_report_opt(const char *arg);
 int perf_callchain_config(const char *var, const char *value);
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index edc2d63..f7adf12 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -566,6 +566,96 @@ unsigned long parse_tag_value(const char *str, struct parse_tag *tags)
 	return (unsigned long) -1;
 }
 
+int get_stack_size(const char *str, unsigned long *_size)
+{
+	char *endptr;
+	unsigned long size;
+	unsigned long max_size = round_down(USHRT_MAX, sizeof(u64));
+
+	size = strtoul(str, &endptr, 0);
+
+	do {
+		if (*endptr)
+			break;
+
+		size = round_up(size, sizeof(u64));
+		if (!size || size > max_size)
+			break;
+
+		*_size = size;
+		return 0;
+
+	} while (0);
+
+	pr_err("callchain: Incorrect stack dump size (max %ld): %s\n",
+	       max_size, str);
+	return -1;
+}
+
+int parse_callchain_record(const char *arg, struct callchain_param *param)
+{
+	char *tok, *name, *saveptr = NULL;
+	char *buf;
+	int ret = -1;
+
+	/* We need buffer that we know we can write to. */
+	buf = malloc(strlen(arg) + 1);
+	if (!buf)
+		return -ENOMEM;
+
+	strcpy(buf, arg);
+
+	tok = strtok_r((char *)buf, ",", &saveptr);
+	name = tok ? : (char *)buf;
+
+	do {
+		/* Framepointer style */
+		if (!strncmp(name, "fp", sizeof("fp"))) {
+			if (!strtok_r(NULL, ",", &saveptr)) {
+				param->record_mode = CALLCHAIN_FP;
+				ret = 0;
+			} else
+				pr_err("callchain: No more arguments "
+				       "needed for --call-graph fp\n");
+			break;
+
+#ifdef HAVE_DWARF_UNWIND_SUPPORT
+		/* Dwarf style */
+		} else if (!strncmp(name, "dwarf", sizeof("dwarf"))) {
+			const unsigned long default_stack_dump_size = 8192;
+
+			ret = 0;
+			param->record_mode = CALLCHAIN_DWARF;
+			param->dump_size = default_stack_dump_size;
+
+			tok = strtok_r(NULL, ",", &saveptr);
+			if (tok) {
+				unsigned long size = 0;
+
+				ret = get_stack_size(tok, &size);
+				param->dump_size = size;
+			}
+#endif /* HAVE_DWARF_UNWIND_SUPPORT */
+		} else if (!strncmp(name, "lbr", sizeof("lbr"))) {
+			if (!strtok_r(NULL, ",", &saveptr)) {
+				param->record_mode = CALLCHAIN_LBR;
+				ret = 0;
+			} else
+				pr_err("callchain: No more arguments "
+					"needed for --call-graph lbr\n");
+			break;
+		} else {
+			pr_err("callchain: Unknown --call-graph option "
+			       "value: %s\n", arg);
+			break;
+		}
+
+	} while (0);
+
+	free(buf);
+	return ret;
+}
+
 int filename__read_str(const char *filename, char **buf, size_t *sizep)
 {
 	size_t size = 0, alloc_size = 0;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 20d625a..8148703 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -351,4 +351,6 @@ static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int
 	return asprintf_expr_inout_ints(var, false, nints, ints);
 }
 
+int get_stack_size(const char *str, unsigned long *_size);
+
 #endif /* GIT_COMPAT_UTIL_H */
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1202262 — [PATCH RFC V9 2/3] perf,tools: per-event callgraph support

Fromkan.liang@intel.com
Date2015-08-07 05:10 +0200
Subject[PATCH RFC V9 2/3] perf,tools: per-event callgraph support
Message-ID<pUGcG-3xm-11@gated-at.bofh.it>
In reply to#1202261
From: Kan Liang <kan.liang@intel.com>

When multiple events are sampled it may not be needed to collect
callgraphs for all of them. The sample sites are usually nearby, and
it's enough to collect the callgraphs on a reference event (such as
precise cycles or precise instructions).
This patchkit adds the ability to turn off callgraphs and time stamp
per event. This in term can reduce sampling overhead and the size of the
perf.data. Furthermore, it makes collecting back traces and timestamps
possible when PEBS threshold > 1, which significantly reducing the
sampling overhead especially for frequently occurring events
(https://lkml.org/lkml/2015/5/10/196). For example, A slower event with
a larger period collects back traces/timestamps. Other more events run
fast with multi-pebs. The time stamps from the slower events can be used
to order the faster events. Their backtraces can give the user enough
hint to find the right spot.

Here are some examples and test results.

1. Comparing the elapsed time and perf.data size from "kernbench -M -H".

 The test command for FULL callgraph and time support.
   "perf record -e
   '{cpu/cpu-cycles,period=100000/,cpu/instructions,period=20000/p}'
   --call-graph fp --time"

 The test command for PARTIAL callgraph and time support.
   "perf record -e
   '{cpu/cpu-cycles,call-graph=fp,time,period=100000/,
     cpu/instructions,call-graph=no,time=0,period=20000/p}'"

 The elapsed time for FULL is 24.3 Sec, while for PARTIAL is 16.9 Sec.
 The perf.data size for FULL is 22.1 Gb, while for PARTIAL is 12.4 Gb.

2. Comparing the perf.data size and callgraph results.

 The test command for FULL callgraph and time support.
   "perf record -e
   '{cpu/cpu-cycles,period=100000/pp,cpu/instructions,period=20000/p}'
   --call-graph fp -- ./tchain_edit"

 The test command for PARTIAL callgraph and time support.
   "perf record -e
   '{cpu/cpu-cycles,call-graph=fp,time,period=100000/pp,
     cpu/instructions,call-graph=no,time=0,period=20000/p}'
   -- ./tchain_edit"

 The perf.data size for FULL is 43.2 MB, while for PARTIAL is 21.1 MB.
 The callgraph is roughly the same.

 The callgraph from FULL
 # Samples: 87K of event
 'cpu/cpu-cycles,call-graph=fp,time,period=100000/pp'
 # Event count (approx.): 8760000000
 #
 # Children      Self  Command      Shared Object       Symbol
 # ........  ........  ...........  ..................
..........................................
 #
    99.98%     0.00%  tchain_edit  libc-2.15.so        [.]
__libc_start_main
            |
            ---__libc_start_main

    99.97%     0.00%  tchain_edit  tchain_edit         [.] main
            |
            ---main
               __libc_start_main

    99.97%     0.00%  tchain_edit  tchain_edit         [.] f1
            |
            ---f1
               main
               __libc_start_main

    99.85%    87.01%  tchain_edit  tchain_edit         [.] f3
            |
            ---f3
               |
               |--99.74%-- f2
               |          f1
               |          main
               |          __libc_start_main
                --0.26%-- [...]
    99.71%     0.12%  tchain_edit  tchain_edit         [.] f2
            |
            ---f2
               f1
               main
               __libc_start_main

 The callgraph from PARTIAL
 # Samples: 417K of event
 'cpu/instructions,call-graph=no,time=0,period=20000/p'
 # Event count (approx.): 8346980000
 #
 # Children      Self  Command      Shared Object     Symbol
 # ........  ........  ...........  ................
..........................................
 #
    98.82%     0.00%  tchain_edit  libc-2.15.so      [.]
__libc_start_main
            |
            ---__libc_start_main

    98.82%     0.00%  tchain_edit  tchain_edit       [.] main
            |
            ---main
               __libc_start_main

    98.82%     0.00%  tchain_edit  tchain_edit       [.] f1
            |
            ---f1
               main
               __libc_start_main

    98.82%    98.28%  tchain_edit  tchain_edit       [.] f3
            |
            ---f3
               |
               |--0.53%-- f2
               |          f1
               |          main
               |          __libc_start_main
               |
               |--0.01%-- f1
               |          main
               |          __libc_start_main
                --99.46%-- [...]
    97.63%     0.03%  tchain_edit  tchain_edit       [.] f2
            |
            ---f2
               f1
               main
               __libc_start_main

     7.13%     0.03%  tchain_edit  [kernel.vmlinux]  [k] do_nmi
            |
            ---do_nmi
               end_repeat_nmi
               f3
               f2
               f1
               main
               __libc_start_main

Signed-off-by: Kan Liang <kan.liang@intel.com>
---

Changes since V8:
 - Same as global dump_size caculation, round_up dump_size for per-event dump_size.

 tools/perf/Documentation/perf-record.txt |  4 ++
 tools/perf/util/evsel.c                  | 67 +++++++++++++++++++++++++++++++-
 tools/perf/util/evsel.h                  |  4 ++
 tools/perf/util/parse-events.c           | 12 ++++++
 tools/perf/util/parse-events.h           |  2 +
 tools/perf/util/parse-events.l           |  2 +
 tools/perf/util/pmu.c                    |  3 +-
 7 files changed, 91 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 0d852d1..e633711 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -52,6 +52,10 @@ OPTIONS
 	  - 'time': Disable/enable time stamping. Acceptable values are 1 for
 		    enabling time stamping. 0 for disabling time stamping.
 		    The default is 1.
+	  - 'call-graph': Disable/enable callgraph. Acceptable str are "fp" for
+			 FP mode, "dwarf" for DWARF mode, "lbr" for LBR mode and
+			 "no" for disable callgraph.
+	  - 'stack-size': user stack size for dwarf mode
 	  Note: If user explicitly sets options which conflict with the params,
 	  the value set by the params will be overridden.
 
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index f572f46..d902cad 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -588,11 +588,36 @@ perf_evsel__config_callgraph(struct perf_evsel *evsel,
 	}
 }
 
-static void apply_config_terms(struct perf_evsel *evsel)
+static void
+perf_evsel__reset_callgraph(struct perf_evsel *evsel,
+			    struct callchain_param *param)
+{
+	struct perf_event_attr *attr = &evsel->attr;
+
+	perf_evsel__reset_sample_bit(evsel, CALLCHAIN);
+	if (param->record_mode == CALLCHAIN_LBR) {
+		perf_evsel__reset_sample_bit(evsel, BRANCH_STACK);
+		attr->branch_sample_type &= ~(PERF_SAMPLE_BRANCH_USER |
+					      PERF_SAMPLE_BRANCH_CALL_STACK);
+	}
+	if (param->record_mode == CALLCHAIN_DWARF) {
+		perf_evsel__reset_sample_bit(evsel, REGS_USER);
+		perf_evsel__reset_sample_bit(evsel, STACK_USER);
+	}
+}
+
+static void apply_config_terms(struct perf_evsel *evsel,
+			       struct record_opts *opts)
 {
 	struct perf_evsel_config_term *term;
 	struct list_head *config_terms = &evsel->config_terms;
 	struct perf_event_attr *attr = &evsel->attr;
+	struct callchain_param param;
+	u32 dump_size = 0;
+	char *callgraph_buf = NULL;
+
+	/* callgraph default */
+	param.record_mode = callchain_param.record_mode;
 
 	list_for_each_entry(term, config_terms, list) {
 		switch (term->type) {
@@ -605,10 +630,48 @@ static void apply_config_terms(struct perf_evsel *evsel)
 			else
 				perf_evsel__reset_sample_bit(evsel, TIME);
 			break;
+		case PERF_EVSEL__CONFIG_TERM_CALLGRAPH:
+			callgraph_buf = term->val.callgraph;
+			break;
+		case PERF_EVSEL__CONFIG_TERM_STACK_USER:
+			dump_size = term->val.stack_user;
+			break;
 		default:
 			break;
 		}
 	}
+
+	/* User explicitly set per-event callgraph, clear the old setting and reset. */
+	if ((callgraph_buf != NULL) || (dump_size > 0)) {
+
+		/* parse callgraph parameters */
+		if (callgraph_buf != NULL) {
+			if (!strcmp(callgraph_buf, "no")) {
+				param.enabled = false;
+				param.record_mode = CALLCHAIN_NONE;
+			} else {
+				param.enabled = true;
+				if (parse_callchain_record(callgraph_buf, &param)) {
+					pr_err("per-event callgraph setting for %s failed. "
+					       "Apply callgraph global setting for it\n",
+					       evsel->name);
+					return;
+				}
+			}
+		}
+		if (dump_size > 0) {
+			dump_size = round_up(dump_size, sizeof(u64));
+			param.dump_size = dump_size;
+		}
+
+		/* If global callgraph set, clear it */
+		if (callchain_param.enabled)
+			perf_evsel__reset_callgraph(evsel, &callchain_param);
+
+		/* set perf-event callgraph */
+		if (param.enabled)
+			perf_evsel__config_callgraph(evsel, opts, &param);
+	}
 }
 
 /*
@@ -807,7 +870,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
 	 * Apply event specific term settings,
 	 * it overloads any global configuration.
 	 */
-	apply_config_terms(evsel);
+	apply_config_terms(evsel, opts);
 }
 
 static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 6a12908..09a3022 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -40,6 +40,8 @@ struct cgroup_sel;
 enum {
 	PERF_EVSEL__CONFIG_TERM_PERIOD,
 	PERF_EVSEL__CONFIG_TERM_TIME,
+	PERF_EVSEL__CONFIG_TERM_CALLGRAPH,
+	PERF_EVSEL__CONFIG_TERM_STACK_USER,
 	PERF_EVSEL__CONFIG_TERM_MAX,
 };
 
@@ -49,6 +51,8 @@ struct perf_evsel_config_term {
 	union {
 		u64	period;
 		bool	time;
+		char	*callgraph;
+		u64	stack_user;
 	} val;
 };
 
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 828936d..773fe8b 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -611,6 +611,12 @@ do {									   \
 			return -EINVAL;
 		}
 		break;
+	case PARSE_EVENTS__TERM_TYPE_CALLGRAPH:
+		CHECK_TYPE_VAL(STR);
+		break;
+	case PARSE_EVENTS__TERM_TYPE_STACKSIZE:
+		CHECK_TYPE_VAL(NUM);
+		break;
 	case PARSE_EVENTS__TERM_TYPE_NAME:
 		CHECK_TYPE_VAL(STR);
 		break;
@@ -662,6 +668,12 @@ do {								\
 		case PARSE_EVENTS__TERM_TYPE_TIME:
 			ADD_CONFIG_TERM(TIME, time, term->val.num);
 			break;
+		case PARSE_EVENTS__TERM_TYPE_CALLGRAPH:
+			ADD_CONFIG_TERM(CALLGRAPH, callgraph, term->val.str);
+			break;
+		case PARSE_EVENTS__TERM_TYPE_STACKSIZE:
+			ADD_CONFIG_TERM(STACK_USER, stack_user, term->val.num);
+			break;
 		default:
 			break;
 		}
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index e6f9aacc..87dc9f6 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -64,6 +64,8 @@ enum {
 	PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD,
 	PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE,
 	PARSE_EVENTS__TERM_TYPE_TIME,
+	PARSE_EVENTS__TERM_TYPE_CALLGRAPH,
+	PARSE_EVENTS__TERM_TYPE_STACKSIZE,
 };
 
 struct parse_events_term {
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index f542750..1665497 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -184,6 +184,8 @@ name			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); }
 period			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
 branch_type		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
 time			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); }
+call-graph		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CALLGRAPH); }
+stack-size		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_STACKSIZE); }
 ,			{ return ','; }
 "/"			{ BEGIN(INITIAL); return '/'; }
 {name_minus}		{ return str(yyscanner, PE_NAME); }
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index d4b0e64..239a653 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -634,7 +634,8 @@ static char *formats_error_string(struct list_head *formats)
 {
 	struct perf_pmu_format *format;
 	char *err, *str;
-	static const char *static_terms = "config,config1,config2,name,period,branch_type,time\n";
+	static const char *static_terms = "config,config1,config2,name,period,"
+					  "branch_type,time,call-graph,stack-size\n";
 	unsigned i = 0;
 
 	if (!asprintf(&str, "valid terms:"))
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1202580 — Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support

FromJiri Olsa <jolsa@redhat.com>
Date2015-08-07 13:00 +0200
SubjectRe: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support
Message-ID<pUNxw-5E5-35@gated-at.bofh.it>
In reply to#1202262
On Thu, Aug 06, 2015 at 03:44:53PM -0400, kan.liang@intel.com wrote:

SNIP

>             |
>             ---f3
>                |
>                |--0.53%-- f2
>                |          f1
>                |          main
>                |          __libc_start_main
>                |
>                |--0.01%-- f1
>                |          main
>                |          __libc_start_main
>                 --99.46%-- [...]
>     97.63%     0.03%  tchain_edit  tchain_edit       [.] f2
>             |
>             ---f2
>                f1
>                main
>                __libc_start_main
> 
>      7.13%     0.03%  tchain_edit  [kernel.vmlinux]  [k] do_nmi
>             |
>             ---do_nmi
>                end_repeat_nmi
>                f3
>                f2
>                f1
>                main
>                __libc_start_main
> 
> Signed-off-by: Kan Liang <kan.liang@intel.com>
> ---
> 
> Changes since V8:
>  - Same as global dump_size caculation, round_up dump_size for per-event dump_size.

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1202841 — Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-08-07 17:50 +0200
SubjectRe: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support
Message-ID<pUS4a-3Sp-13@gated-at.bofh.it>
In reply to#1202262
Em Fri, Aug 07, 2015 at 12:38:43PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Thu, Aug 06, 2015 at 03:44:53PM -0400, kan.liang@intel.com escreveu:
> > From: Kan Liang <kan.liang@intel.com>
> > Here are some examples and test results.
> > 
> > 1. Comparing the elapsed time and perf.data size from "kernbench -M -H".
> > 
> >  The test command for FULL callgraph and time support.
> >    "perf record -e
> >    '{cpu/cpu-cycles,period=100000/,cpu/instructions,period=20000/p}'
> >    --call-graph fp --time"

Some other oddity I noticed while testing:

For:

[root@zoo ~]# perf report --header-only
# ========
# captured on: Fri Aug  7 12:39:13 2015
# hostname : zoo
# os release : 4.2.0-rc5+
# perf version : 4.2.rc4.g1cd951
# arch : x86_64
# nrcpus online : 4
# nrcpus avail : 4
# cpudesc : Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz
# cpuid : GenuineIntel,6,58,9
# total memory : 8080692 kB
# cmdline : /home/acme/bin/perf record -e {cpu/cpu-cycles,call-graph=fp,time,period=10000/pp,cpu/instructions,call-graph=no,time=0,period=20000/p} -a 
# event : name = cpu/cpu-cycles,call-graph=fp,time,period=10000/pp, , id = { 38537, 38538, 38539, 38540 }, type = 4, size = 112, config = 0x3c, { sample_perio
# event : name = cpu/instructions,call-graph=no,time=0,period=20000/p, , id = { 38541, 38542, 38543, 38544 }, type = 4, size = 112, config = 0xc0, { sample_pe
# HEADER_CPU_TOPOLOGY info available, use -I to display
# HEADER_NUMA_TOPOLOGY info available, use -I to display
# pmu mappings: cpu = 4, software = 1, power = 7, uncore_imc = 8, tracepoint = 2, uncore_cbox_0 = 9, uncore_cbox_1 = 10, breakpoint = 5
# group: {cpu/cpu-cycles,call-graph=fp,time,period=10000/pp,cpu/instructions,call-graph=no,time=0,period=20000/p}
# ========
#

I get:

Samples: 2K of event 'cpu/instructions,call-graph=no,time=0,period=20000/p', Event count (approx.): 46956518
  Children      Self  Command          Shared Object Symbol                  ◆
-   67.56%     0.00%  qemu-system-x86  [unknown]     [.] 0xad5e258d4c544155  ▒
     0xad5e258d4c544155                                                      ▒
-   67.56%     0.00%  qemu-system-x86  libc-2.20.so  [.] __libc_start_main   ▒
     __libc_start_main                                                       ▒
     0xad5e258d4c544155                                                      ▒
-   67.56%     0.00%  qemu-system-x86  perf          [.] main                ▒
     main                                                                    ▒
     __libc_start_main                                                       ▒
     0xad5e258d4c544155                                                      ▒
-   67.56%     0.00%  qemu-system-x86  perf          [.] run_builtin         ▒
     run_builtin                                                             ▒
     main                                                                    ▒
     __libc_start_main                                                       ▒

This is in the 'perf report' TUI, why, for an event with 'callgraph=no', we
get callchains? How come?

If I try it with the --stdio, well, its there as well:

# Samples: 2K of event 'cpu/instructions,call-graph=no,time=0,period=20000/p'
# Event count (approx.): 46956518
#
# Children      Self  Command          Shared Object               Symbol                                        
# ........  ........  ...............  ..........................  ..............................................
#
    67.56%     0.00%  qemu-system-x86  [unknown]                   [.] 0xad5e258d4c544155                        
            |
            ---0xad5e258d4c544155

    67.56%     0.00%  qemu-system-x86  libc-2.20.so                [.] __libc_start_main                         
            |
            ---__libc_start_main
               0xad5e258d4c544155

    67.56%     0.00%  qemu-system-x86  perf                        [.] main                                      
            |
            ---main
               __libc_start_main
               0xad5e258d4c544155

    67.56%     0.00%  qemu-system-x86  perf                        [.] run_builtin                               
            |
            ---run_builtin
               main
               __libc_start_main
               0xad5e258d4c544155

Can you take a look? What I have, i.e. the patches from Jiri and Kan
moving stuff out of the way of the python binding and this patch is at
the tmp.perf/core branch in my git tree:

  git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git

- Arnaldo

 
> Jiri, while testing this I noticed that the message for EINVAL when
> using the cpu// syntax (per-event settings) is cryptic:
> 
>   [root@zoo ~]# perf record -e 'cpu/cpu-cycles,call-graph=fp,time,period=100000/p' ls
>   Error:
>   The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cpu/cpu-cycles,call-graph=fp,time,period=100000/p).
>   /bin/dmesg may provide additional information.
>   No CONFIG_PERF_EVENTS=y kernel support configured?
> 
> Whereas if we use -F, it is much, much clearer, telling the user exactly
> what is failing and what needs to be done to make it work:
> 
>   [root@zoo ~]# perf record -F 100000 -e cpu/cpu-cycles/ usleep 1
>   Maximum frequency rate (25000) reached.
>   Please use -F freq option with lower value or consider
>   tweaking /proc/sys/kernel/perf_event_max_sample_rate.
>   [root@zoo ~]# 
> 
> Hope this is something easy to wire up, given your event parsing kung foo
> skillz...
> 
> ;-)
> 
> - Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1203325 — Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support

FromJiri Olsa <jolsa@redhat.com>
Date2015-08-08 18:50 +0200
SubjectRe: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support
Message-ID<pVftM-4oL-17@gated-at.bofh.it>
In reply to#1202841

[Multipart message — attachments visible in raw view] — view raw

On Fri, Aug 07, 2015 at 12:49:38PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Fri, Aug 07, 2015 at 12:38:43PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Thu, Aug 06, 2015 at 03:44:53PM -0400, kan.liang@intel.com escreveu:
> > > From: Kan Liang <kan.liang@intel.com>
> > > Here are some examples and test results.
> > > 
> > > 1. Comparing the elapsed time and perf.data size from "kernbench -M -H".
> > > 
> > >  The test command for FULL callgraph and time support.
> > >    "perf record -e
> > >    '{cpu/cpu-cycles,period=100000/,cpu/instructions,period=20000/p}'
> > >    --call-graph fp --time"
> 
> Some other oddity I noticed while testing:
> 

SNIP

> This is in the 'perf report' TUI, why, for an event with 'callgraph=no', we
> get callchains? How come?
> 
> If I try it with the --stdio, well, its there as well:
> 
> # Samples: 2K of event 'cpu/instructions,call-graph=no,time=0,period=20000/p'
> # Event count (approx.): 46956518
> #
> # Children      Self  Command          Shared Object               Symbol                                        
> # ........  ........  ...............  ..........................  ..............................................
> #
>     67.56%     0.00%  qemu-system-x86  [unknown]                   [.] 0xad5e258d4c544155                        
>             |
>             ---0xad5e258d4c544155
> 
>     67.56%     0.00%  qemu-system-x86  libc-2.20.so                [.] __libc_start_main                         
>             |
>             ---__libc_start_main
>                0xad5e258d4c544155
> 
>     67.56%     0.00%  qemu-system-x86  perf                        [.] main                                      
>             |
>             ---main
>                __libc_start_main
>                0xad5e258d4c544155
> 
>     67.56%     0.00%  qemu-system-x86  perf                        [.] run_builtin                               
>             |
>             ---run_builtin
>                main
>                __libc_start_main
>                0xad5e258d4c544155
> 
> Can you take a look? What I have, i.e. the patches from Jiri and Kan
> moving stuff out of the way of the python binding and this patch is at
> the tmp.perf/core branch in my git tree:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git

hum, tried this branch and got proper behaviour for both stdio and TUI,
attaching stdio output

the record command was:
  $ ./perf record -e 'cpu/cpu-cycles,call-graph=fp,time,period=10000/pp,cpu/instructions,call-graph=no,time=0,period=20000/p' ls

got the events strings from your report output.. what was different in your record command?

jirka

[toc] | [prev] | [next] | [standalone]


#1203340 — Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-08-08 19:40 +0200
SubjectRe: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support
Message-ID<pVgga-5yS-41@gated-at.bofh.it>
In reply to#1203325
Em Sat, Aug 08, 2015 at 06:45:39PM +0200, Jiri Olsa escreveu:
> On Fri, Aug 07, 2015 at 12:49:38PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Fri, Aug 07, 2015 at 12:38:43PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Thu, Aug 06, 2015 at 03:44:53PM -0400, kan.liang@intel.com escreveu:
> > > > From: Kan Liang <kan.liang@intel.com>
> > > > Here are some examples and test results.
> > > > 
> > > > 1. Comparing the elapsed time and perf.data size from "kernbench -M -H".
> > > > 
> > > >  The test command for FULL callgraph and time support.
> > > >    "perf record -e
> > > >    '{cpu/cpu-cycles,period=100000/,cpu/instructions,period=20000/p}'
> > > >    --call-graph fp --time"
> > 
> > Some other oddity I noticed while testing:
> > 
> 
> SNIP
> 
> > This is in the 'perf report' TUI, why, for an event with 'callgraph=no', we
> > get callchains? How come?
> > 
> > If I try it with the --stdio, well, its there as well:
> > 
> > # Samples: 2K of event 'cpu/instructions,call-graph=no,time=0,period=20000/p'
> > # Event count (approx.): 46956518
> > #
> > # Children      Self  Command          Shared Object               Symbol                                        
> > # ........  ........  ...............  ..........................  ..............................................
> > #
> >     67.56%     0.00%  qemu-system-x86  [unknown]                   [.] 0xad5e258d4c544155                        
> >             |
> >             ---0xad5e258d4c544155
> > 
> >     67.56%     0.00%  qemu-system-x86  libc-2.20.so                [.] __libc_start_main                         
> >             |
> >             ---__libc_start_main
> >                0xad5e258d4c544155
> > 
> >     67.56%     0.00%  qemu-system-x86  perf                        [.] main                                      
> >             |
> >             ---main
> >                __libc_start_main
> >                0xad5e258d4c544155
> > 
> >     67.56%     0.00%  qemu-system-x86  perf                        [.] run_builtin                               
> >             |
> >             ---run_builtin
> >                main
> >                __libc_start_main
> >                0xad5e258d4c544155
> > 
> > Can you take a look? What I have, i.e. the patches from Jiri and Kan
> > moving stuff out of the way of the python binding and this patch is at
> > the tmp.perf/core branch in my git tree:
> > 
> >   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
> 
> hum, tried this branch and got proper behaviour for both stdio and TUI,
> attaching stdio output
> 
> the record command was:
>   $ ./perf record -e 'cpu/cpu-cycles,call-graph=fp,time,period=10000/pp,cpu/instructions,call-graph=no,time=0,period=20000/p' ls
> 
> got the events strings from your report output.. what was different in your record command?

Was in my message, here it is:

# cmdline : /home/acme/bin/perf record -e {cpu/cpu-cycles,call-graph=fp,time,period=10000/pp,cpu/instructions,call-graph=no,time=0,period=20000/p}
-a

I'll try this again later.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1204236 — RE: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support

From"Liang, Kan" <kan.liang@intel.com>
Date2015-08-10 15:00 +0200
SubjectRE: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support
Message-ID<pVUQi-6Mt-3@gated-at.bofh.it>
In reply to#1202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WJjX3N0YXJ0X21haW4gICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg4paSDQo+ICAgICAgMHhhZDVlMjU4
ZDRjNTQ0MTU1ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAg4paSDQo+IC0gICA2Ny41NiUgICAgIDAuMDAlICBxZW11LXN5c3RlbS14ODYgIHBlcmYg
ICAgICAgICAgWy5dIG1haW4gICAgICAgICAgICAgICAg4paSDQo+ICAgICAgbWFpbiAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAg4paSDQo+ICAgICAgX19saWJjX3N0YXJ0X21haW4gICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg4paSDQo+ICAgICAgMHhhZDVlMjU4ZDRjNTQ0
MTU1ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
4paSDQo+IC0gICA2Ny41NiUgICAgIDAuMDAlICBxZW11LXN5c3RlbS14ODYgIHBlcmYgICAgICAg
ICAgWy5dIHJ1bl9idWlsdGluICAgICAgICAg4paSDQo+ICAgICAgcnVuX2J1aWx0aW4gICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg4paS
DQo+ICAgICAgbWFpbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAg4paSDQo+ICAgICAgX19saWJjX3N0YXJ0X21haW4gICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg4paSDQo+
IA0KPiBUaGlzIGlzIGluIHRoZSAncGVyZiByZXBvcnQnIFRVSSwgd2h5LCBmb3IgYW4gZXZlbnQg
d2l0aCAnY2FsbGdy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VyLCB0ZWxsaW5nIHRoZSB1c2VyDQo+ID4gZXhhY3RseSB3aGF0IGlzIGZhaWxpbmcgYW5kIHdo
YXQgbmVlZHMgdG8gYmUgZG9uZSB0byBtYWtlIGl0IHdvcms6DQo+ID4NCj4gPiAgIFtyb290QHpv
byB+XSMgcGVyZiByZWNvcmQgLUYgMTAwMDAwIC1lIGNwdS9jcHUtY3ljbGVzLyB1c2xlZXAgMQ0K
PiA+ICAgTWF4aW11bSBmcmVxdWVuY3kgcmF0ZSAoMjUwMDApIHJlYWNoZWQuDQo+ID4gICBQbGVh
c2UgdXNlIC1GIGZyZXEgb3B0aW9uIHdpdGggbG93ZXIgdmFsdWUgb3IgY29uc2lkZXINCj4gPiAg
IHR3ZWFraW5nIC9wcm9jL3N5cy9rZXJuZWwvcGVyZl9ldmVudF9tYXhfc2FtcGxlX3JhdGUuDQo+
ID4gICBbcm9vdEB6b28gfl0jDQo+ID4NCj4gPiBIb3BlIHRoaXMgaXMgc29tZXRoaW5nIGVhc3kg
dG8gd2lyZSB1cCwgZ2l2ZW4geW91ciBldmVudCBwYXJzaW5nIGt1bmcNCj4gPiBmb28gc2tpbGx6
Li4uDQo+ID4NCj4gPiA7LSkNCj4gPg0KPiA+IC0gQXJuYWxkbw0K
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1204368 — Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-08-10 17:40 +0200
SubjectRe: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support
Message-ID<pVXl8-21m-15@gated-at.bofh.it>
In reply to#1204236
Em Mon, Aug 10, 2015 at 12:56:04PM +0000, Liang, Kan escreveu:
> > Em Fri, Aug 07, 2015 at 12:38:43PM -0300, Arnaldo Carvalho de Melo escreveu:
> > [root@zoo ~]# perf report --header-only
> > # cmdline :
> > /home/acme/bin/perf record -e {cpu/cpu-cycles,call-
> > graph=fp,time,period=10000/pp,cpu/instructions,call-
> > graph=no,time=0,period=20000/p} -a
<SNIP>

> > I get:

> > Samples: 2K of event 'cpu/instructions,call-
> > graph=no,time=0,period=20000/p', Event count (approx.): 46956518
> >   Children      Self  Command          Shared Object Symbol                  ◆
> > -   67.56%     0.00%  qemu-system-x86  [unknown]     [.]
> > 0xad5e258d4c544155  ▒
> >      0xad5e258d4c544155                                                      ▒
> > -   67.56%     0.00%  qemu-system-x86  libc-2.20.so  [.] __libc_start_main   ▒
> >      __libc_start_main                                                       ▒
> >      0xad5e258d4c544155                                                      ▒

> > This is in the 'perf report' TUI, why, for an event with 'callgraph=no', we get
> > callchains? How come?
 
> That's the design.
> For sampling multiple events, it may not be needed to collect callgraphs for
> all of them. Because the sample sites are usually nearby. It's enough to collect
> the callgraphs on a reference event. For other events, it can still show callgraphs
> according to the callgraphs on a reference event.

So, "call-graph=no" doesn't mean you don't want callchains for a
particular events _if_ there is another event in the group for which
callchains is available.

But if "call-graph=no" for all events, then, yes, "no" means really
"no". :-)

I think we should use "call-graph=ref" to mean that no callchains should
be requested to the kernel infrastructure for that particular event, but
that when doing the report, use callchains available in some other event
(perhaps would be good to specify which one), while "call-graph=no"
really means "no", i.e. no callchains asked from the kernel for this
event, and _no_ callchains to appear on report.

If "ref" is used and no callchains are available anywhere, that is a bug
as well, i.e. I asked for callchains up to a event to be used, by
getting that info from another event, but no event has callchains:
error.

- Arnaldo

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1204485 — RE: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support

From"Liang, Kan" <kan.liang@intel.com>
Date2015-08-10 21:00 +0200
SubjectRE: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support
Message-ID<pW0sH-6qA-31@gated-at.bofh.it>
In reply to#1204368
DQoNCj4gPFNOSVA+DQo+IA0KPiA+ID4gSSBnZXQ6DQo+IA0KPiA+ID4gU2FtcGxlczogMksgb2Yg
ZXZlbnQgJ2NwdS9pbnN0cnVjdGlvbnMsY2FsbC0NCj4gPiA+IGdyYXBoPW5vLHRpbWU9MCxwZXJp
b2Q9MjAwMDAvcCcsIEV2ZW50IGNvdW50IChhcHByb3guKTogNDY5NTY1MTgNCj4gPiA+ICAgQ2hp
bGRyZW4gICAgICBTZWxmICBDb21tYW5kICAgICAgICAgIFNoYXJlZCBPYmplY3QgU3ltYm9sICAg
ICAgICAgICAgICAgICAg4peGDQo+ID4gPiAtICAgNjcuNTYlICAgICAwLjAwJSAgcWVtdS1zeXN0
ZW0teDg2ICBbdW5rbm93bl0gICAgIFsuXQ0KPiA+ID4gMHhhZDVlMjU4ZDRjNTQ0MTU1ICDilpIN
Cj4gPiA+ICAgICAgMHhhZDVlMjU4ZDRjNTQ0MTU1ICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAg4paSDQo+ID4gPiAtICAgNjcuNTYlICAgICAwLjAw
JSAgcWVtdS1zeXN0ZW0teDg2ICBsaWJjLTIuMjAuc28gIFsuXSBfX2xpYmNfc3RhcnRfbWFpbg0K
PiDilpINCj4gPiA+ICAgICAgX19saWJjX3N0YXJ0X21haW4gICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg4paSDQo+ID4gPiAgICAgIDB4YWQ1ZTI1
OGQ0YzU0NDE1NSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgIOKWkg0KPiANCj4gPiA+IFRoaXMgaXMgaW4gdGhlICdwZXJmIHJlcG9ydCcgVFVJLCB3
aHksIGZvciBhbiBldmVudCB3aXRoDQo+ID4gPiAnY2FsbGd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hdGlvbiBmcm9tIG90aGVyIGV2ZW50IHdpbGwgYmUNCnByaW50ZWQgZm9yICJjYWxsLWdy
YXBoPW5vIiBldmVudC4NCklmIG5vdCwgbm8gY2FsbGNoYWluIGluZm9ybWF0aW9uIGlzIHByaW50
ZWQgZm9yICJjYWxsLWdyYXBoPW5vIiBldmVudC4NClRoZSBkZWZhdWx0IGlzIG5vIHByaW50Lg0K
SXMgaXQgT0s/DQoNClRoYW5rcywNCkthbg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1204513 — Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-08-10 21:40 +0200
SubjectRe: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support
Message-ID<pW15n-7pB-3@gated-at.bofh.it>
In reply to#1204485
Em Mon, Aug 10, 2015 at 06:57:20PM +0000, Liang, Kan escreveu:
> > <SNIP>

> > > > I get:

> > > > Samples: 2K of event 'cpu/instructions,call-
> > > > graph=no,time=0,period=20000/p', Event count (approx.): 46956518
> > > >   Children      Self  Command          Shared Object Symbol                  ◆
> > > > -   67.56%     0.00%  qemu-system-x86  [unknown]     [.]
> > > > 0xad5e258d4c544155  ▒
> > > >      0xad5e258d4c544155                                                      ▒
> > > > -   67.56%     0.00%  qemu-system-x86  libc-2.20.so  [.] __libc_start_main
> > > >      __libc_start_main                                                       ▒
> > > >      0xad5e258d4c544155                                                      ▒

> > > > This is in the 'perf report' TUI, why, for an event with
> > > > 'callgraph=no', we get callchains? How come?

> > > That's the design.
> > > For sampling multiple events, it may not be needed to collect
> > > callgraphs for all of them. Because the sample sites are usually
> > > nearby. It's enough to collect the callgraphs on a reference event.
> > > For other events, it can still show callgraphs according to the callgraphs on
> > a reference event.

> > So, "call-graph=no" doesn't mean you don't want callchains for a particular
> > events _if_ there is another event in the group for which callchains is
> > available.

> > But if "call-graph=no" for all events, then, yes, "no" means really "no". :-)

> > I think we should use "call-graph=ref" to mean that no callchains should be
> > requested to the kernel infrastructure for that particular event, but that
> > when doing the report, use callchains available in some other event
> > (perhaps would be good to specify which one), while "call-graph=no"
> > really means "no", i.e. no callchains asked from the kernel for this event,
> > and _no_ callchains to appear on report.

> > If "ref" is used and no callchains are available anywhere, that is a bug as
> > well, i.e. I asked for callchains up to a event to be used, by getting that info
> > from another event, but no event has callchains:
> > error.
 
> If we use " call-graph=ref", it means "ref" is a new callchain mode. But it's not.
> I think the "ref" thing should only impact the perf report.

I don't have much of a problem with that, but using "ref" to make the
intention, i.e. use reference callchains, documented, clear, makes sense to me.

I.e. when you ask for two events, one with callchains and the other without it
doesn't necessarily means we want callchains appearing on the ones we have not
enabled them.

> So we may introduce a new option "--show-callchain-ref" for that purpose.
> If it applied, the available callchain information from other event will be
> printed for "call-graph=no" event.

Ok, if the user explicitely asked for "--show-callchain-ref", then
he/she will not get confused seeing callchains for an event with
"call-graph=no".

Ah, probably --show-ref-call-graph should be better, to keep it consistent with
all the other options dealing with call-graph stuff.

> If not, no callchain information is printed for "call-graph=no" event.
> The default is no print.

Agreed, I think this almost completely reduces the possible source of
confusion.

> Is it OK?

Ok.

One possible improvement to your proposal: When showing callchains in
reference mode, make that extra explicit by adding some marker on the
side of the event name.

I.e. right now we will see callchains, when this is with another event with
callchains:

  Samples: 24  of event 'cpu/instructions,call-graph=no,time=0,period=20000/p', Event count (approx.): 480000
  Overhead  Command  Shared Object     Symbol
    12.50%  usleep   libc-2.20.so      [.] _dl_addr

My suggestion is to have something like:

  Samples: 24  of event 'cpu/instructions,call-graph=no,time=0,period=20000/p', ref cg, Event count (approx.): 480000
  Overhead  Command  Shared Object     Symbol
    12.50%  usleep   libc-2.20.so      [.] _dl_addr

See that ", ref cg"?

But would be just to remove the confusion of seeing, on the same screen,
"call-graph=no" when one _sees_ call graphs.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1202842 — Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-08-07 18:00 +0200
SubjectRe: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support
Message-ID<pUS4a-3Sp-15@gated-at.bofh.it>
In reply to#1202262
Em Thu, Aug 06, 2015 at 03:44:53PM -0400, kan.liang@intel.com escreveu:
> From: Kan Liang <kan.liang@intel.com>
> Here are some examples and test results.
> 
> 1. Comparing the elapsed time and perf.data size from "kernbench -M -H".
> 
>  The test command for FULL callgraph and time support.
>    "perf record -e
>    '{cpu/cpu-cycles,period=100000/,cpu/instructions,period=20000/p}'
>    --call-graph fp --time"

Jiri, while testing this I noticed that the message for EINVAL when
using the cpu// syntax (per-event settings) is cryptic:

  [root@zoo ~]# perf record -e 'cpu/cpu-cycles,call-graph=fp,time,period=100000/p' ls
  Error:
  The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cpu/cpu-cycles,call-graph=fp,time,period=100000/p).
  /bin/dmesg may provide additional information.
  No CONFIG_PERF_EVENTS=y kernel support configured?

Whereas if we use -F, it is much, much clearer, telling the user exactly
what is failing and what needs to be done to make it work:

  [root@zoo ~]# perf record -F 100000 -e cpu/cpu-cycles/ usleep 1
  Maximum frequency rate (25000) reached.
  Please use -F freq option with lower value or consider
  tweaking /proc/sys/kernel/perf_event_max_sample_rate.
  [root@zoo ~]# 

Hope this is something easy to wire up, given your event parsing kung foo
skillz...

;-)

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1203328 — [PATCH] perf tools: Unset perf_event_attr::freq when period term is set

FromJiri Olsa <jolsa@redhat.com>
Date2015-08-08 19:20 +0200
Subject[PATCH] perf tools: Unset perf_event_attr::freq when period term is set
Message-ID<pVfWN-5cg-5@gated-at.bofh.it>
In reply to#1202842
On Fri, Aug 07, 2015 at 12:38:43PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Aug 06, 2015 at 03:44:53PM -0400, kan.liang@intel.com escreveu:
> > From: Kan Liang <kan.liang@intel.com>
> > Here are some examples and test results.
> > 
> > 1. Comparing the elapsed time and perf.data size from "kernbench -M -H".
> > 
> >  The test command for FULL callgraph and time support.
> >    "perf record -e
> >    '{cpu/cpu-cycles,period=100000/,cpu/instructions,period=20000/p}'
> >    --call-graph fp --time"
> 
> Jiri, while testing this I noticed that the message for EINVAL when
> using the cpu// syntax (per-event settings) is cryptic:
> 
>   [root@zoo ~]# perf record -e 'cpu/cpu-cycles,call-graph=fp,time,period=100000/p' ls
>   Error:
>   The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cpu/cpu-cycles,call-graph=fp,time,period=100000/p).
>   /bin/dmesg may provide additional information.
>   No CONFIG_PERF_EVENTS=y kernel support configured?
> 
> Whereas if we use -F, it is much, much clearer, telling the user exactly
> what is failing and what needs to be done to make it work:
> 
>   [root@zoo ~]# perf record -F 100000 -e cpu/cpu-cycles/ usleep 1
>   Maximum frequency rate (25000) reached.
>   Please use -F freq option with lower value or consider
>   tweaking /proc/sys/kernel/perf_event_max_sample_rate.
>   [root@zoo ~]# 
> 
> Hope this is something easy to wire up, given your event parsing kung foo
> skillz...

my kungu foo found there was actually another issue ;-)

we did not clear up attr->freq bit.. so the sample_period
was handled as sample_freq value.. please check the patch
below

anyfoo, now period setup can raise sky high (which is correct)
and once it meets the God it shows:

[jolsa@krava perf]$ ./perf record -e 'cpu/cpu-cycles,call-graph=fp,time,period=1000000000000000000000000/' ls
event syntax error: '..time,period=1000000000000000000000000/'
                                  \___ parser error

I'll check if we could add some default error message when value
crosses the type maximum.. which now falls to parser error

jirka


---
We need to unset 'perf_event_attr::freq' bit (default 1) when
'period' term is specified within event definition like:

  -e 'cpu/cpu-cycles,call-graph=fp,time,period=100000'

otherwise it will handle the period value as frequency
(and fail if it crossed the maximum allowed frequency value).

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/n/tip-7f3gjwbekakhyxr47wvin4zb@git.kernel.org
---
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d902cad4ce10..4c779d23b1d7 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -623,6 +623,7 @@ static void apply_config_terms(struct perf_evsel *evsel,
 		switch (term->type) {
 		case PERF_EVSEL__CONFIG_TERM_PERIOD:
 			attr->sample_period = term->val.period;
+			attr->freq = 0;
 			break;
 		case PERF_EVSEL__CONFIG_TERM_TIME:
 			if (term->val.time)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1206033 — [tip:perf/core] perf tools: Unset perf_event_attr:: freq when period term is set

Fromtip-bot for Jiri Olsa <tipbot@zytor.com>
Date2015-08-12 14:40 +0200
Subject[tip:perf/core] perf tools: Unset perf_event_attr:: freq when period term is set
Message-ID<pWDu4-4ta-45@gated-at.bofh.it>
In reply to#1203328
Commit-ID:  ab35a7d0ee59a36c9c567defe43c1adb72e9240c
Gitweb:     http://git.kernel.org/tip/ab35a7d0ee59a36c9c567defe43c1adb72e9240c
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Sat, 8 Aug 2015 19:12:10 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 10 Aug 2015 11:58:05 -0300

perf tools: Unset perf_event_attr::freq when period term is set

We need to unset 'perf_event_attr::freq' bit (default 1) when
'period' term is specified within event definition like:

  -e 'cpu/cpu-cycles,call-graph=fp,time,period=100000'

otherwise it will handle the period value as frequency
(and fail if it crossed the maximum allowed frequency value).

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20150808171210.GC17040@krava.brq.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evsel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index f572f46..a59710f 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -598,6 +598,7 @@ static void apply_config_terms(struct perf_evsel *evsel)
 		switch (term->type) {
 		case PERF_EVSEL__CONFIG_TERM_PERIOD:
 			attr->sample_period = term->val.period;
+			attr->freq = 0;
 			break;
 		case PERF_EVSEL__CONFIG_TERM_TIME:
 			if (term->val.time)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1202583 — [PATCH] perf tools: Move perf_counts struct and functions into separate object

FromJiri Olsa <jolsa@redhat.com>
Date2015-08-07 13:00 +0200
Subject[PATCH] perf tools: Move perf_counts struct and functions into separate object
Message-ID<pUNxx-5E5-41@gated-at.bofh.it>
In reply to#1202261
On Thu, Aug 06, 2015 at 03:44:52PM -0400, kan.liang@intel.com wrote:
> From: Kan Liang <kan.liang@intel.com>
> 
> Move callchain option parse related code to util.c

little nore about the reason would be nice ;-)

looks ok, but the python test is still failing,
the reason is the perf_counts struct objects and functions
bindings to util/stat.c object

Arnaldo,
I separated the 'struct perf_counts' into util/counts.c,
because I recall you did not want them in evsel.c,
please check attached patch.. it makes the python test
pass again (on top of Kan's change).

thanks,
jirka


---
Moving perf_counts struct and functions into separate object,
so we could remove stat.c object dependency from python build.

It makes the python code to be built properly, because now it
fails to load due to missing stat-shadow.c object dependency.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index a054ddc0b2a0..7aa039bd379a 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -58,6 +58,7 @@
 #include "util/cpumap.h"
 #include "util/thread.h"
 #include "util/thread_map.h"
+#include "util/counts.h"
 
 #include <stdlib.h>
 #include <sys/prctl.h>
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index a1e5168dc1fb..4ca481cd38e6 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -67,6 +67,7 @@ libperf-y += target.o
 libperf-y += rblist.o
 libperf-y += intlist.o
 libperf-y += vdso.o
+libperf-y += counts.o
 libperf-y += stat.o
 libperf-y += stat-shadow.o
 libperf-y += record.o
diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c
new file mode 100644
index 000000000000..e3fde313deb2
--- /dev/null
+++ b/tools/perf/util/counts.c
@@ -0,0 +1,52 @@
+#include <stdlib.h>
+#include "evsel.h"
+#include "counts.h"
+
+struct perf_counts *perf_counts__new(int ncpus, int nthreads)
+{
+	struct perf_counts *counts = zalloc(sizeof(*counts));
+
+	if (counts) {
+		struct xyarray *values;
+
+		values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values));
+		if (!values) {
+			free(counts);
+			return NULL;
+		}
+
+		counts->values = values;
+	}
+
+	return counts;
+}
+
+void perf_counts__delete(struct perf_counts *counts)
+{
+	if (counts) {
+		xyarray__delete(counts->values);
+		free(counts);
+	}
+}
+
+static void perf_counts__reset(struct perf_counts *counts)
+{
+	xyarray__reset(counts->values);
+}
+
+void perf_evsel__reset_counts(struct perf_evsel *evsel)
+{
+	perf_counts__reset(evsel->counts);
+}
+
+int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads)
+{
+	evsel->counts = perf_counts__new(ncpus, nthreads);
+	return evsel->counts != NULL ? 0 : -ENOMEM;
+}
+
+void perf_evsel__free_counts(struct perf_evsel *evsel)
+{
+	perf_counts__delete(evsel->counts);
+	evsel->counts = NULL;
+}
diff --git a/tools/perf/util/counts.h b/tools/perf/util/counts.h
new file mode 100644
index 000000000000..34d8baaf558a
--- /dev/null
+++ b/tools/perf/util/counts.h
@@ -0,0 +1,37 @@
+#ifndef __PERF_COUNTS_H
+#define __PERF_COUNTS_H
+
+#include "xyarray.h"
+
+struct perf_counts_values {
+	union {
+		struct {
+			u64 val;
+			u64 ena;
+			u64 run;
+		};
+		u64 values[3];
+	};
+};
+
+struct perf_counts {
+	s8			  scaled;
+	struct perf_counts_values aggr;
+	struct xyarray		  *values;
+};
+
+
+static inline struct perf_counts_values*
+perf_counts(struct perf_counts *counts, int cpu, int thread)
+{
+	return xyarray__entry(counts->values, cpu, thread);
+}
+
+struct perf_counts *perf_counts__new(int ncpus, int nthreads);
+void perf_counts__delete(struct perf_counts *counts);
+
+void perf_evsel__reset_counts(struct perf_evsel *evsel);
+int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads);
+void perf_evsel__free_counts(struct perf_evsel *evsel);
+
+#endif /* __PERF_COUNTS_H */
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 09a3022fa2c6..0ca0002db99a 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -9,7 +9,7 @@
 #include "xyarray.h"
 #include "symbol.h"
 #include "cpumap.h"
-#include "stat.h"
+#include "counts.h"
 
 struct perf_evsel;
 
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources
index 0766d98c5da5..51be28b1bca2 100644
--- a/tools/perf/util/python-ext-sources
+++ b/tools/perf/util/python-ext-sources
@@ -16,7 +16,7 @@ util/util.c
 util/xyarray.c
 util/cgroup.c
 util/rblist.c
-util/stat.c
+util/counts.c
 util/strlist.c
 util/trace-event.c
 ../lib/rbtree.c
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index c5c709cdc3ce..415c359de465 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -97,55 +97,6 @@ void perf_stat_evsel_id_init(struct perf_evsel *evsel)
 	}
 }
 
-struct perf_counts *perf_counts__new(int ncpus, int nthreads)
-{
-	struct perf_counts *counts = zalloc(sizeof(*counts));
-
-	if (counts) {
-		struct xyarray *values;
-
-		values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values));
-		if (!values) {
-			free(counts);
-			return NULL;
-		}
-
-		counts->values = values;
-	}
-
-	return counts;
-}
-
-void perf_counts__delete(struct perf_counts *counts)
-{
-	if (counts) {
-		xyarray__delete(counts->values);
-		free(counts);
-	}
-}
-
-static void perf_counts__reset(struct perf_counts *counts)
-{
-	xyarray__reset(counts->values);
-}
-
-void perf_evsel__reset_counts(struct perf_evsel *evsel)
-{
-	perf_counts__reset(evsel->counts);
-}
-
-int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads)
-{
-	evsel->counts = perf_counts__new(ncpus, nthreads);
-	return evsel->counts != NULL ? 0 : -ENOMEM;
-}
-
-void perf_evsel__free_counts(struct perf_evsel *evsel)
-{
-	perf_counts__delete(evsel->counts);
-	evsel->counts = NULL;
-}
-
 void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)
 {
 	int i;
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 0b897b083682..62448c8175d3 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -33,23 +33,6 @@ enum aggr_mode {
 	AGGR_THREAD,
 };
 
-struct perf_counts_values {
-	union {
-		struct {
-			u64 val;
-			u64 ena;
-			u64 run;
-		};
-		u64 values[3];
-	};
-};
-
-struct perf_counts {
-	s8			  scaled;
-	struct perf_counts_values aggr;
-	struct xyarray		  *values;
-};
-
 struct perf_stat_config {
 	enum aggr_mode	aggr_mode;
 	bool		scale;
@@ -57,12 +40,6 @@ struct perf_stat_config {
 	unsigned int	interval;
 };
 
-static inline struct perf_counts_values*
-perf_counts(struct perf_counts *counts, int cpu, int thread)
-{
-	return xyarray__entry(counts->values, cpu, thread);
-}
-
 void update_stats(struct stats *stats, u64 val);
 double avg_stats(struct stats *stats);
 double stddev_stats(struct stats *stats);
@@ -96,13 +73,6 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,
 void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel,
 				   double avg, int cpu, enum aggr_mode aggr);
 
-struct perf_counts *perf_counts__new(int ncpus, int nthreads);
-void perf_counts__delete(struct perf_counts *counts);
-
-void perf_evsel__reset_counts(struct perf_evsel *evsel);
-int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads);
-void perf_evsel__free_counts(struct perf_evsel *evsel);
-
 void perf_evsel__reset_stat_priv(struct perf_evsel *evsel);
 int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel);
 void perf_evsel__free_stat_priv(struct perf_evsel *evsel);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1202678 — Re: [PATCH] perf tools: Move perf_counts struct and functions into separate object

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-08-07 15:20 +0200
SubjectRe: [PATCH] perf tools: Move perf_counts struct and functions into separate object
Message-ID<pUPJ0-x3-33@gated-at.bofh.it>
In reply to#1202583
Em Fri, Aug 07, 2015 at 12:51:03PM +0200, Jiri Olsa escreveu:
> On Thu, Aug 06, 2015 at 03:44:52PM -0400, kan.liang@intel.com wrote:
> > From: Kan Liang <kan.liang@intel.com>
> > 
> > Move callchain option parse related code to util.c
> 
> little nore about the reason would be nice ;-)
> 
> looks ok, but the python test is still failing,
> the reason is the perf_counts struct objects and functions
> bindings to util/stat.c object
> 
> Arnaldo,
> I separated the 'struct perf_counts' into util/counts.c,
> because I recall you did not want them in evsel.c,
> please check attached patch.. it makes the python test
> pass again (on top of Kan's change).

Ok, will apply, try Kan's patch, add the extra comments about why the
move from callchain to util.c is needed, test the whole shebang, ship to
Ingo...

- Arnaldo
 
> thanks,
> jirka
> 
> 
> ---
> Moving perf_counts struct and functions into separate object,
> so we could remove stat.c object dependency from python build.
> 
> It makes the python code to be built properly, because now it
> fails to load due to missing stat-shadow.c object dependency.
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index a054ddc0b2a0..7aa039bd379a 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -58,6 +58,7 @@
>  #include "util/cpumap.h"
>  #include "util/thread.h"
>  #include "util/thread_map.h"
> +#include "util/counts.h"
>  
>  #include <stdlib.h>
>  #include <sys/prctl.h>
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index a1e5168dc1fb..4ca481cd38e6 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -67,6 +67,7 @@ libperf-y += target.o
>  libperf-y += rblist.o
>  libperf-y += intlist.o
>  libperf-y += vdso.o
> +libperf-y += counts.o
>  libperf-y += stat.o
>  libperf-y += stat-shadow.o
>  libperf-y += record.o
> diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c
> new file mode 100644
> index 000000000000..e3fde313deb2
> --- /dev/null
> +++ b/tools/perf/util/counts.c
> @@ -0,0 +1,52 @@
> +#include <stdlib.h>
> +#include "evsel.h"
> +#include "counts.h"
> +
> +struct perf_counts *perf_counts__new(int ncpus, int nthreads)
> +{
> +	struct perf_counts *counts = zalloc(sizeof(*counts));
> +
> +	if (counts) {
> +		struct xyarray *values;
> +
> +		values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values));
> +		if (!values) {
> +			free(counts);
> +			return NULL;
> +		}
> +
> +		counts->values = values;
> +	}
> +
> +	return counts;
> +}
> +
> +void perf_counts__delete(struct perf_counts *counts)
> +{
> +	if (counts) {
> +		xyarray__delete(counts->values);
> +		free(counts);
> +	}
> +}
> +
> +static void perf_counts__reset(struct perf_counts *counts)
> +{
> +	xyarray__reset(counts->values);
> +}
> +
> +void perf_evsel__reset_counts(struct perf_evsel *evsel)
> +{
> +	perf_counts__reset(evsel->counts);
> +}
> +
> +int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads)
> +{
> +	evsel->counts = perf_counts__new(ncpus, nthreads);
> +	return evsel->counts != NULL ? 0 : -ENOMEM;
> +}
> +
> +void perf_evsel__free_counts(struct perf_evsel *evsel)
> +{
> +	perf_counts__delete(evsel->counts);
> +	evsel->counts = NULL;
> +}
> diff --git a/tools/perf/util/counts.h b/tools/perf/util/counts.h
> new file mode 100644
> index 000000000000..34d8baaf558a
> --- /dev/null
> +++ b/tools/perf/util/counts.h
> @@ -0,0 +1,37 @@
> +#ifndef __PERF_COUNTS_H
> +#define __PERF_COUNTS_H
> +
> +#include "xyarray.h"
> +
> +struct perf_counts_values {
> +	union {
> +		struct {
> +			u64 val;
> +			u64 ena;
> +			u64 run;
> +		};
> +		u64 values[3];
> +	};
> +};
> +
> +struct perf_counts {
> +	s8			  scaled;
> +	struct perf_counts_values aggr;
> +	struct xyarray		  *values;
> +};
> +
> +
> +static inline struct perf_counts_values*
> +perf_counts(struct perf_counts *counts, int cpu, int thread)
> +{
> +	return xyarray__entry(counts->values, cpu, thread);
> +}
> +
> +struct perf_counts *perf_counts__new(int ncpus, int nthreads);
> +void perf_counts__delete(struct perf_counts *counts);
> +
> +void perf_evsel__reset_counts(struct perf_evsel *evsel);
> +int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads);
> +void perf_evsel__free_counts(struct perf_evsel *evsel);
> +
> +#endif /* __PERF_COUNTS_H */
> diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> index 09a3022fa2c6..0ca0002db99a 100644
> --- a/tools/perf/util/evsel.h
> +++ b/tools/perf/util/evsel.h
> @@ -9,7 +9,7 @@
>  #include "xyarray.h"
>  #include "symbol.h"
>  #include "cpumap.h"
> -#include "stat.h"
> +#include "counts.h"
>  
>  struct perf_evsel;
>  
> diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources
> index 0766d98c5da5..51be28b1bca2 100644
> --- a/tools/perf/util/python-ext-sources
> +++ b/tools/perf/util/python-ext-sources
> @@ -16,7 +16,7 @@ util/util.c
>  util/xyarray.c
>  util/cgroup.c
>  util/rblist.c
> -util/stat.c
> +util/counts.c
>  util/strlist.c
>  util/trace-event.c
>  ../lib/rbtree.c
> diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
> index c5c709cdc3ce..415c359de465 100644
> --- a/tools/perf/util/stat.c
> +++ b/tools/perf/util/stat.c
> @@ -97,55 +97,6 @@ void perf_stat_evsel_id_init(struct perf_evsel *evsel)
>  	}
>  }
>  
> -struct perf_counts *perf_counts__new(int ncpus, int nthreads)
> -{
> -	struct perf_counts *counts = zalloc(sizeof(*counts));
> -
> -	if (counts) {
> -		struct xyarray *values;
> -
> -		values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values));
> -		if (!values) {
> -			free(counts);
> -			return NULL;
> -		}
> -
> -		counts->values = values;
> -	}
> -
> -	return counts;
> -}
> -
> -void perf_counts__delete(struct perf_counts *counts)
> -{
> -	if (counts) {
> -		xyarray__delete(counts->values);
> -		free(counts);
> -	}
> -}
> -
> -static void perf_counts__reset(struct perf_counts *counts)
> -{
> -	xyarray__reset(counts->values);
> -}
> -
> -void perf_evsel__reset_counts(struct perf_evsel *evsel)
> -{
> -	perf_counts__reset(evsel->counts);
> -}
> -
> -int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads)
> -{
> -	evsel->counts = perf_counts__new(ncpus, nthreads);
> -	return evsel->counts != NULL ? 0 : -ENOMEM;
> -}
> -
> -void perf_evsel__free_counts(struct perf_evsel *evsel)
> -{
> -	perf_counts__delete(evsel->counts);
> -	evsel->counts = NULL;
> -}
> -
>  void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)
>  {
>  	int i;
> diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
> index 0b897b083682..62448c8175d3 100644
> --- a/tools/perf/util/stat.h
> +++ b/tools/perf/util/stat.h
> @@ -33,23 +33,6 @@ enum aggr_mode {
>  	AGGR_THREAD,
>  };
>  
> -struct perf_counts_values {
> -	union {
> -		struct {
> -			u64 val;
> -			u64 ena;
> -			u64 run;
> -		};
> -		u64 values[3];
> -	};
> -};
> -
> -struct perf_counts {
> -	s8			  scaled;
> -	struct perf_counts_values aggr;
> -	struct xyarray		  *values;
> -};
> -
>  struct perf_stat_config {
>  	enum aggr_mode	aggr_mode;
>  	bool		scale;
> @@ -57,12 +40,6 @@ struct perf_stat_config {
>  	unsigned int	interval;
>  };
>  
> -static inline struct perf_counts_values*
> -perf_counts(struct perf_counts *counts, int cpu, int thread)
> -{
> -	return xyarray__entry(counts->values, cpu, thread);
> -}
> -
>  void update_stats(struct stats *stats, u64 val);
>  double avg_stats(struct stats *stats);
>  double stddev_stats(struct stats *stats);
> @@ -96,13 +73,6 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,
>  void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel,
>  				   double avg, int cpu, enum aggr_mode aggr);
>  
> -struct perf_counts *perf_counts__new(int ncpus, int nthreads);
> -void perf_counts__delete(struct perf_counts *counts);
> -
> -void perf_evsel__reset_counts(struct perf_evsel *evsel);
> -int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads);
> -void perf_evsel__free_counts(struct perf_evsel *evsel);
> -
>  void perf_evsel__reset_stat_priv(struct perf_evsel *evsel);
>  int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel);
>  void perf_evsel__free_stat_priv(struct perf_evsel *evsel);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1206004 — [tip:perf/core] perf stat: Move perf_counts struct and functions into separate object

Fromtip-bot for Jiri Olsa <tipbot@zytor.com>
Date2015-08-12 14:30 +0200
Subject[tip:perf/core] perf stat: Move perf_counts struct and functions into separate object
Message-ID<pWDkm-4hj-11@gated-at.bofh.it>
In reply to#1202583
Commit-ID:  d809560b36a7ed31fbaf3719fdf79ddcbd30950b
Gitweb:     http://git.kernel.org/tip/d809560b36a7ed31fbaf3719fdf79ddcbd30950b
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Fri, 7 Aug 2015 12:51:03 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Sat, 8 Aug 2015 14:16:49 -0300

perf stat: Move perf_counts struct and functions into separate object

Moving 'struct perf_counts' and associated functions into separate
object, so we could remove stat.c object dependency from python build.

It makes the python code to build properly, because it fails to load due
to missing stat-shadow.c object dependency if some patches from Kan
Liang are applied.

So apply this one, then Kan's.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20150807105103.GB8624@krava.brq.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c          |  1 +
 tools/perf/util/Build              |  1 +
 tools/perf/util/counts.c           | 52 ++++++++++++++++++++++++++++++++++++++
 tools/perf/util/counts.h           | 37 +++++++++++++++++++++++++++
 tools/perf/util/evsel.h            |  2 +-
 tools/perf/util/python-ext-sources |  2 +-
 tools/perf/util/stat.c             | 49 -----------------------------------
 tools/perf/util/stat.h             | 30 ----------------------
 8 files changed, 93 insertions(+), 81 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index a054ddc..7aa039b 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -58,6 +58,7 @@
 #include "util/cpumap.h"
 #include "util/thread.h"
 #include "util/thread_map.h"
+#include "util/counts.h"
 
 #include <stdlib.h>
 #include <sys/prctl.h>
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 2ee81d7..1ce0adc 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -68,6 +68,7 @@ libperf-y += target.o
 libperf-y += rblist.o
 libperf-y += intlist.o
 libperf-y += vdso.o
+libperf-y += counts.o
 libperf-y += stat.o
 libperf-y += stat-shadow.o
 libperf-y += record.o
diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c
new file mode 100644
index 0000000..e3fde31
--- /dev/null
+++ b/tools/perf/util/counts.c
@@ -0,0 +1,52 @@
+#include <stdlib.h>
+#include "evsel.h"
+#include "counts.h"
+
+struct perf_counts *perf_counts__new(int ncpus, int nthreads)
+{
+	struct perf_counts *counts = zalloc(sizeof(*counts));
+
+	if (counts) {
+		struct xyarray *values;
+
+		values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values));
+		if (!values) {
+			free(counts);
+			return NULL;
+		}
+
+		counts->values = values;
+	}
+
+	return counts;
+}
+
+void perf_counts__delete(struct perf_counts *counts)
+{
+	if (counts) {
+		xyarray__delete(counts->values);
+		free(counts);
+	}
+}
+
+static void perf_counts__reset(struct perf_counts *counts)
+{
+	xyarray__reset(counts->values);
+}
+
+void perf_evsel__reset_counts(struct perf_evsel *evsel)
+{
+	perf_counts__reset(evsel->counts);
+}
+
+int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads)
+{
+	evsel->counts = perf_counts__new(ncpus, nthreads);
+	return evsel->counts != NULL ? 0 : -ENOMEM;
+}
+
+void perf_evsel__free_counts(struct perf_evsel *evsel)
+{
+	perf_counts__delete(evsel->counts);
+	evsel->counts = NULL;
+}
diff --git a/tools/perf/util/counts.h b/tools/perf/util/counts.h
new file mode 100644
index 0000000..34d8baa
--- /dev/null
+++ b/tools/perf/util/counts.h
@@ -0,0 +1,37 @@
+#ifndef __PERF_COUNTS_H
+#define __PERF_COUNTS_H
+
+#include "xyarray.h"
+
+struct perf_counts_values {
+	union {
+		struct {
+			u64 val;
+			u64 ena;
+			u64 run;
+		};
+		u64 values[3];
+	};
+};
+
+struct perf_counts {
+	s8			  scaled;
+	struct perf_counts_values aggr;
+	struct xyarray		  *values;
+};
+
+
+static inline struct perf_counts_values*
+perf_counts(struct perf_counts *counts, int cpu, int thread)
+{
+	return xyarray__entry(counts->values, cpu, thread);
+}
+
+struct perf_counts *perf_counts__new(int ncpus, int nthreads);
+void perf_counts__delete(struct perf_counts *counts);
+
+void perf_evsel__reset_counts(struct perf_evsel *evsel);
+int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads);
+void perf_evsel__free_counts(struct perf_evsel *evsel);
+
+#endif /* __PERF_COUNTS_H */
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 6a12908..b948f69 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -9,7 +9,7 @@
 #include "xyarray.h"
 #include "symbol.h"
 #include "cpumap.h"
-#include "stat.h"
+#include "counts.h"
 
 struct perf_evsel;
 
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources
index 0766d98..51be28b 100644
--- a/tools/perf/util/python-ext-sources
+++ b/tools/perf/util/python-ext-sources
@@ -16,7 +16,7 @@ util/util.c
 util/xyarray.c
 util/cgroup.c
 util/rblist.c
-util/stat.c
+util/counts.c
 util/strlist.c
 util/trace-event.c
 ../lib/rbtree.c
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index c5c709c..415c359 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -97,55 +97,6 @@ void perf_stat_evsel_id_init(struct perf_evsel *evsel)
 	}
 }
 
-struct perf_counts *perf_counts__new(int ncpus, int nthreads)
-{
-	struct perf_counts *counts = zalloc(sizeof(*counts));
-
-	if (counts) {
-		struct xyarray *values;
-
-		values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values));
-		if (!values) {
-			free(counts);
-			return NULL;
-		}
-
-		counts->values = values;
-	}
-
-	return counts;
-}
-
-void perf_counts__delete(struct perf_counts *counts)
-{
-	if (counts) {
-		xyarray__delete(counts->values);
-		free(counts);
-	}
-}
-
-static void perf_counts__reset(struct perf_counts *counts)
-{
-	xyarray__reset(counts->values);
-}
-
-void perf_evsel__reset_counts(struct perf_evsel *evsel)
-{
-	perf_counts__reset(evsel->counts);
-}
-
-int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads)
-{
-	evsel->counts = perf_counts__new(ncpus, nthreads);
-	return evsel->counts != NULL ? 0 : -ENOMEM;
-}
-
-void perf_evsel__free_counts(struct perf_evsel *evsel)
-{
-	perf_counts__delete(evsel->counts);
-	evsel->counts = NULL;
-}
-
 void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)
 {
 	int i;
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 0b897b0..62448c8 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -33,23 +33,6 @@ enum aggr_mode {
 	AGGR_THREAD,
 };
 
-struct perf_counts_values {
-	union {
-		struct {
-			u64 val;
-			u64 ena;
-			u64 run;
-		};
-		u64 values[3];
-	};
-};
-
-struct perf_counts {
-	s8			  scaled;
-	struct perf_counts_values aggr;
-	struct xyarray		  *values;
-};
-
 struct perf_stat_config {
 	enum aggr_mode	aggr_mode;
 	bool		scale;
@@ -57,12 +40,6 @@ struct perf_stat_config {
 	unsigned int	interval;
 };
 
-static inline struct perf_counts_values*
-perf_counts(struct perf_counts *counts, int cpu, int thread)
-{
-	return xyarray__entry(counts->values, cpu, thread);
-}
-
 void update_stats(struct stats *stats, u64 val);
 double avg_stats(struct stats *stats);
 double stddev_stats(struct stats *stats);
@@ -96,13 +73,6 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,
 void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel,
 				   double avg, int cpu, enum aggr_mode aggr);
 
-struct perf_counts *perf_counts__new(int ncpus, int nthreads);
-void perf_counts__delete(struct perf_counts *counts);
-
-void perf_evsel__reset_counts(struct perf_evsel *evsel);
-int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads);
-void perf_evsel__free_counts(struct perf_evsel *evsel);
-
 void perf_evsel__reset_stat_priv(struct perf_evsel *evsel);
 int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel);
 void perf_evsel__free_stat_priv(struct perf_evsel *evsel);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1206006 — [tip:perf/core] perf callchain: Move option parsing code to util.c

Fromtip-bot for Kan Liang <tipbot@zytor.com>
Date2015-08-12 14:30 +0200
Subject[tip:perf/core] perf callchain: Move option parsing code to util.c
Message-ID<pWDkm-4hj-15@gated-at.bofh.it>
In reply to#1202261
Commit-ID:  076a30c411ba2b91a18d44a5a01977035cdd7716
Gitweb:     http://git.kernel.org/tip/076a30c411ba2b91a18d44a5a01977035cdd7716
Author:     Kan Liang <kan.liang@intel.com>
AuthorDate: Thu, 6 Aug 2015 15:44:52 -0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Sat, 8 Aug 2015 14:16:49 -0300

perf callchain: Move option parsing code to util.c

Move callchain option parse related code to util.c, to avoid dragging
more object files into the python binding.

Signed-off-by: Kan Liang <kan.liang@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1438890294-33409-1-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/callchain.c | 89 +-------------------------------------------
 tools/perf/util/callchain.h |  1 +
 tools/perf/util/util.c      | 90 +++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/util.h      |  2 +
 4 files changed, 94 insertions(+), 88 deletions(-)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 931cca8..773fe13 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -25,96 +25,9 @@
 
 __thread struct callchain_cursor callchain_cursor;
 
-#ifdef HAVE_DWARF_UNWIND_SUPPORT
-static int get_stack_size(const char *str, unsigned long *_size)
-{
-	char *endptr;
-	unsigned long size;
-	unsigned long max_size = round_down(USHRT_MAX, sizeof(u64));
-
-	size = strtoul(str, &endptr, 0);
-
-	do {
-		if (*endptr)
-			break;
-
-		size = round_up(size, sizeof(u64));
-		if (!size || size > max_size)
-			break;
-
-		*_size = size;
-		return 0;
-
-	} while (0);
-
-	pr_err("callchain: Incorrect stack dump size (max %ld): %s\n",
-	       max_size, str);
-	return -1;
-}
-#endif /* HAVE_DWARF_UNWIND_SUPPORT */
-
 int parse_callchain_record_opt(const char *arg, struct callchain_param *param)
 {
-	char *tok, *name, *saveptr = NULL;
-	char *buf;
-	int ret = -1;
-
-	/* We need buffer that we know we can write to. */
-	buf = malloc(strlen(arg) + 1);
-	if (!buf)
-		return -ENOMEM;
-
-	strcpy(buf, arg);
-
-	tok = strtok_r((char *)buf, ",", &saveptr);
-	name = tok ? : (char *)buf;
-
-	do {
-		/* Framepointer style */
-		if (!strncmp(name, "fp", sizeof("fp"))) {
-			if (!strtok_r(NULL, ",", &saveptr)) {
-				param->record_mode = CALLCHAIN_FP;
-				ret = 0;
-			} else
-				pr_err("callchain: No more arguments "
-				       "needed for --call-graph fp\n");
-			break;
-
-#ifdef HAVE_DWARF_UNWIND_SUPPORT
-		/* Dwarf style */
-		} else if (!strncmp(name, "dwarf", sizeof("dwarf"))) {
-			const unsigned long default_stack_dump_size = 8192;
-
-			ret = 0;
-			param->record_mode = CALLCHAIN_DWARF;
-			param->dump_size = default_stack_dump_size;
-
-			tok = strtok_r(NULL, ",", &saveptr);
-			if (tok) {
-				unsigned long size = 0;
-
-				ret = get_stack_size(tok, &size);
-				param->dump_size = size;
-			}
-#endif /* HAVE_DWARF_UNWIND_SUPPORT */
-		} else if (!strncmp(name, "lbr", sizeof("lbr"))) {
-			if (!strtok_r(NULL, ",", &saveptr)) {
-				param->record_mode = CALLCHAIN_LBR;
-				ret = 0;
-			} else
-				pr_err("callchain: No more arguments "
-					"needed for --call-graph lbr\n");
-			break;
-		} else {
-			pr_err("callchain: Unknown --call-graph option "
-			       "value: %s\n", arg);
-			break;
-		}
-
-	} while (0);
-
-	free(buf);
-	return ret;
+	return parse_callchain_record(arg, param);
 }
 
 static int parse_callchain_mode(const char *value)
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 68a32c2..acee2b3 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -177,6 +177,7 @@ int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *
 			bool hide_unresolved);
 
 extern const char record_callchain_help[];
+extern int parse_callchain_record(const char *arg, struct callchain_param *param);
 int parse_callchain_record_opt(const char *arg, struct callchain_param *param);
 int parse_callchain_report_opt(const char *arg);
 int perf_callchain_config(const char *var, const char *value);
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index edc2d63..f7adf12 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -566,6 +566,96 @@ unsigned long parse_tag_value(const char *str, struct parse_tag *tags)
 	return (unsigned long) -1;
 }
 
+int get_stack_size(const char *str, unsigned long *_size)
+{
+	char *endptr;
+	unsigned long size;
+	unsigned long max_size = round_down(USHRT_MAX, sizeof(u64));
+
+	size = strtoul(str, &endptr, 0);
+
+	do {
+		if (*endptr)
+			break;
+
+		size = round_up(size, sizeof(u64));
+		if (!size || size > max_size)
+			break;
+
+		*_size = size;
+		return 0;
+
+	} while (0);
+
+	pr_err("callchain: Incorrect stack dump size (max %ld): %s\n",
+	       max_size, str);
+	return -1;
+}
+
+int parse_callchain_record(const char *arg, struct callchain_param *param)
+{
+	char *tok, *name, *saveptr = NULL;
+	char *buf;
+	int ret = -1;
+
+	/* We need buffer that we know we can write to. */
+	buf = malloc(strlen(arg) + 1);
+	if (!buf)
+		return -ENOMEM;
+
+	strcpy(buf, arg);
+
+	tok = strtok_r((char *)buf, ",", &saveptr);
+	name = tok ? : (char *)buf;
+
+	do {
+		/* Framepointer style */
+		if (!strncmp(name, "fp", sizeof("fp"))) {
+			if (!strtok_r(NULL, ",", &saveptr)) {
+				param->record_mode = CALLCHAIN_FP;
+				ret = 0;
+			} else
+				pr_err("callchain: No more arguments "
+				       "needed for --call-graph fp\n");
+			break;
+
+#ifdef HAVE_DWARF_UNWIND_SUPPORT
+		/* Dwarf style */
+		} else if (!strncmp(name, "dwarf", sizeof("dwarf"))) {
+			const unsigned long default_stack_dump_size = 8192;
+
+			ret = 0;
+			param->record_mode = CALLCHAIN_DWARF;
+			param->dump_size = default_stack_dump_size;
+
+			tok = strtok_r(NULL, ",", &saveptr);
+			if (tok) {
+				unsigned long size = 0;
+
+				ret = get_stack_size(tok, &size);
+				param->dump_size = size;
+			}
+#endif /* HAVE_DWARF_UNWIND_SUPPORT */
+		} else if (!strncmp(name, "lbr", sizeof("lbr"))) {
+			if (!strtok_r(NULL, ",", &saveptr)) {
+				param->record_mode = CALLCHAIN_LBR;
+				ret = 0;
+			} else
+				pr_err("callchain: No more arguments "
+					"needed for --call-graph lbr\n");
+			break;
+		} else {
+			pr_err("callchain: Unknown --call-graph option "
+			       "value: %s\n", arg);
+			break;
+		}
+
+	} while (0);
+
+	free(buf);
+	return ret;
+}
+
 int filename__read_str(const char *filename, char **buf, size_t *sizep)
 {
 	size_t size = 0, alloc_size = 0;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 20d625a..8148703 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -351,4 +351,6 @@ static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int
 	return asprintf_expr_inout_ints(var, false, nints, ints);
 }
 
+int get_stack_size(const char *str, unsigned long *_size);
+
 #endif /* GIT_COMPAT_UTIL_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web