public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, acme@redhat.com, jolsa@kernel.org,
	namhyung@kernel.org, dsahern@gmail.com, mingo@kernel.org,
	hpa@zytor.com, tglx@linutronix.de, a.p.zijlstra@chello.nl
Subject: [tip:perf/core] perf stat: Introduce struct perf_stat_config
Date: Fri, 7 Aug 2015 00:17:17 -0700	[thread overview]
Message-ID: <tip-421a50f3fafaf271bb3293378eaafca71337dfec@git.kernel.org> (raw)
In-Reply-To: <1437481927-29538-3-git-send-email-jolsa@kernel.org>

Commit-ID:  421a50f3fafaf271bb3293378eaafca71337dfec
Gitweb:     http://git.kernel.org/tip/421a50f3fafaf271bb3293378eaafca71337dfec
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Tue, 21 Jul 2015 14:31:22 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 6 Aug 2015 16:02:29 -0300

perf stat: Introduce struct perf_stat_config

Moving 'aggr_mode' into new struct. The point is to centralize the base
stat config so it could be used localy together with other stat routines
in other parts of perf code.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1437481927-29538-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c | 39 ++++++++++++++++++++++-----------------
 tools/perf/util/stat.h    |  4 ++++
 2 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index d99d850..bafb830 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -102,7 +102,6 @@ static struct target target = {
 static int			run_count			=  1;
 static bool			no_inherit			= false;
 static bool			scale				=  true;
-static enum aggr_mode		aggr_mode			= AGGR_GLOBAL;
 static volatile pid_t		child_pid			= -1;
 static bool			null_run			=  false;
 static int			detailed_run			=  0;
@@ -126,6 +125,10 @@ static int			(*aggr_get_id)(struct cpu_map *m, int cpu);
 
 static volatile int done = 0;
 
+static struct perf_stat_config stat_config = {
+	.aggr_mode	= AGGR_GLOBAL,
+};
+
 static inline void diff_timespec(struct timespec *r, struct timespec *a,
 				 struct timespec *b)
 {
@@ -230,7 +233,7 @@ process_counter_values(struct perf_evsel *evsel, int cpu, int thread,
 	if (skip)
 		count = &zero;
 
-	switch (aggr_mode) {
+	switch (stat_config.aggr_mode) {
 	case AGGR_THREAD:
 	case AGGR_CORE:
 	case AGGR_SOCKET:
@@ -238,7 +241,7 @@ process_counter_values(struct perf_evsel *evsel, int cpu, int thread,
 		if (!evsel->snapshot)
 			perf_evsel__compute_deltas(evsel, cpu, thread, count);
 		perf_counts_values__scale(count, scale, NULL);
-		if (aggr_mode == AGGR_NONE)
+		if (stat_config.aggr_mode == AGGR_NONE)
 			perf_stat__update_shadow_stats(evsel, count->values, cpu);
 		break;
 	case AGGR_GLOBAL:
@@ -291,7 +294,7 @@ static int process_counter(struct perf_evsel *counter)
 	if (ret)
 		return ret;
 
-	if (aggr_mode != AGGR_GLOBAL)
+	if (stat_config.aggr_mode != AGGR_GLOBAL)
 		return 0;
 
 	if (!counter->snapshot)
@@ -578,7 +581,7 @@ static void print_noise(struct perf_evsel *evsel, double avg)
 
 static void aggr_printout(struct perf_evsel *evsel, int id, int nr)
 {
-	switch (aggr_mode) {
+	switch (stat_config.aggr_mode) {
 	case AGGR_CORE:
 		fprintf(output, "S%d-C%*d%s%*d%s",
 			cpu_map__id_to_socket(id),
@@ -670,7 +673,7 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
 
 	aggr_printout(evsel, id, nr);
 
-	if (aggr_mode == AGGR_GLOBAL)
+	if (stat_config.aggr_mode == AGGR_GLOBAL)
 		cpu = 0;
 
 	fprintf(output, fmt, avg, csv_sep);
@@ -688,7 +691,8 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
 	if (csv_output || interval)
 		return;
 
-	perf_stat__print_shadow_stats(output, evsel, avg, cpu, aggr_mode);
+	perf_stat__print_shadow_stats(output, evsel, avg, cpu,
+				      stat_config.aggr_mode);
 }
 
 static void print_aggr(char *prefix)
@@ -909,7 +913,7 @@ static void print_interval(char *prefix, struct timespec *ts)
 	sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep);
 
 	if (num_print_interval == 0 && !csv_output) {
-		switch (aggr_mode) {
+		switch (stat_config.aggr_mode) {
 		case AGGR_SOCKET:
 			fprintf(output, "#           time socket cpus             counts %*s events\n", unit_width, "unit");
 			break;
@@ -985,7 +989,7 @@ static void print_counters(struct timespec *ts, int argc, const char **argv)
 	else
 		print_header(argc, argv);
 
-	switch (aggr_mode) {
+	switch (stat_config.aggr_mode) {
 	case AGGR_CORE:
 	case AGGR_SOCKET:
 		print_aggr(prefix);
@@ -1064,7 +1068,7 @@ static int stat__set_big_num(const struct option *opt __maybe_unused,
 
 static int perf_stat_init_aggr_mode(void)
 {
-	switch (aggr_mode) {
+	switch (stat_config.aggr_mode) {
 	case AGGR_SOCKET:
 		if (cpu_map__build_socket_map(evsel_list->cpus, &aggr_map)) {
 			perror("cannot build socket map");
@@ -1286,7 +1290,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 			   stat__set_big_num),
 	OPT_STRING('C', "cpu", &target.cpu_list, "cpu",
 		    "list of cpus to monitor in system-wide"),
-	OPT_SET_UINT('A', "no-aggr", &aggr_mode,
+	OPT_SET_UINT('A', "no-aggr", &stat_config.aggr_mode,
 		    "disable CPU count aggregation", AGGR_NONE),
 	OPT_STRING('x', "field-separator", &csv_sep, "separator",
 		   "print counts with custom separator"),
@@ -1302,11 +1306,11 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 			"command to run after to the measured command"),
 	OPT_UINTEGER('I', "interval-print", &interval,
 		    "print counts at regular interval in ms (>= 100)"),
-	OPT_SET_UINT(0, "per-socket", &aggr_mode,
+	OPT_SET_UINT(0, "per-socket", &stat_config.aggr_mode,
 		     "aggregate counts per processor socket", AGGR_SOCKET),
-	OPT_SET_UINT(0, "per-core", &aggr_mode,
+	OPT_SET_UINT(0, "per-core", &stat_config.aggr_mode,
 		     "aggregate counts per physical processor core", AGGR_CORE),
-	OPT_SET_UINT(0, "per-thread", &aggr_mode,
+	OPT_SET_UINT(0, "per-thread", &stat_config.aggr_mode,
 		     "aggregate counts per thread", AGGR_THREAD),
 	OPT_UINTEGER('D', "delay", &initial_delay,
 		     "ms to wait before starting measurement after program start"),
@@ -1399,7 +1403,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 		run_count = 1;
 	}
 
-	if ((aggr_mode == AGGR_THREAD) && !target__has_task(&target)) {
+	if ((stat_config.aggr_mode == AGGR_THREAD) && !target__has_task(&target)) {
 		fprintf(stderr, "The --per-thread option is only available "
 			"when monitoring via -p -t options.\n");
 		parse_options_usage(NULL, options, "p", 1);
@@ -1411,7 +1415,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 	 * no_aggr, cgroup are for system-wide only
 	 * --per-thread is aggregated per thread, we dont mix it with cpu mode
 	 */
-	if (((aggr_mode != AGGR_GLOBAL && aggr_mode != AGGR_THREAD) || nr_cgroups) &&
+	if (((stat_config.aggr_mode != AGGR_GLOBAL &&
+	      stat_config.aggr_mode != AGGR_THREAD) || nr_cgroups) &&
 	    !target__has_cpu(&target)) {
 		fprintf(stderr, "both cgroup and no-aggregation "
 			"modes only available in system-wide mode\n");
@@ -1444,7 +1449,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 	 * Initialize thread_map with comm names,
 	 * so we could print it out on output.
 	 */
-	if (aggr_mode == AGGR_THREAD)
+	if (stat_config.aggr_mode == AGGR_THREAD)
 		thread_map__read_comms(evsel_list->threads);
 
 	if (interval && interval < 100) {
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 1cfbe0a..078bee4 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -50,6 +50,10 @@ struct perf_counts {
 	struct xyarray		  *values;
 };
 
+struct perf_stat_config {
+	enum aggr_mode	aggr_mode;
+};
+
 static inline struct perf_counts_values*
 perf_counts(struct perf_counts *counts, int cpu, int thread)
 {

  parent reply	other threads:[~2015-08-07  7:17 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-21 12:31 [RFC 00/47] perf stat: Add scripting support Jiri Olsa
2015-07-21 12:31 ` [PATCH 01/47] perf test: Check for refcnt in thread_map test Jiri Olsa
2015-07-21 17:26   ` Arnaldo Carvalho de Melo
2015-07-29  8:10   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-07-21 12:31 ` [PATCH 02/47] perf stat: Introduce struct perf_stat_config Jiri Olsa
2015-07-21 17:24   ` Arnaldo Carvalho de Melo
2015-07-21 17:37     ` Arnaldo Carvalho de Melo
2015-07-22  8:38       ` Jiri Olsa
2015-08-07  7:17   ` tip-bot for Jiri Olsa [this message]
2015-07-21 12:31 ` [PATCH 03/47] perf stat: Move scale into " Jiri Olsa
2015-08-07  7:17   ` [tip:perf/core] perf stat: Move 'scale' " tip-bot for Jiri Olsa
2015-07-21 12:31 ` [PATCH 04/47] perf stat: Move output " Jiri Olsa
2015-08-07  7:17   ` [tip:perf/core] perf stat: Move 'output' " tip-bot for Jiri Olsa
2015-07-21 12:31 ` [PATCH 05/47] perf stat: Move interval " Jiri Olsa
2015-08-07  7:18   ` [tip:perf/core] perf stat: Move 'interval' " tip-bot for Jiri Olsa
2015-07-21 12:31 ` [PATCH 06/47] perf stat: Pass struct perf_stat_config into process_counter Jiri Olsa
2015-08-07  7:18   ` [tip:perf/core] perf stat: Pass 'struct perf_stat_config' into process_counter() tip-bot for Jiri Olsa
2015-07-21 12:31 ` [PATCH 07/47] perf stat: Move counter processing code into stat object Jiri Olsa
2015-08-07  7:18   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-07-21 12:31 ` [PATCH 08/47] perf tools: Use bool instead of target argument in perf_evlist__propagate_maps Jiri Olsa
2015-07-29  8:10   ` [tip:perf/core] perf evlist: Use bool instead of target argument in propagate_maps() tip-bot for Jiri Olsa
2015-07-21 12:31 ` [PATCH 09/47] perf tools: Tolerate NULL maps in perf_evlist__propagate_maps Jiri Olsa
2015-07-21 17:31   ` Arnaldo Carvalho de Melo
2015-07-29  8:11   ` [tip:perf/core] perf evlist: Tolerate NULL maps in propagate_maps tip-bot for Jiri Olsa
2015-07-21 12:31 ` [PATCH 10/47] perf tools: Force perf_evlist__set_maps to propagate maps through events Jiri Olsa
2015-07-21 17:25   ` Arnaldo Carvalho de Melo
2015-07-29  8:10   ` [tip:perf/core] perf evlist: " tip-bot for Jiri Olsa
2015-07-21 12:31 ` [PATCH 11/47] perf tools: Use argv style storage for cmdline feature data Jiri Olsa
2015-07-21 17:29   ` Arnaldo Carvalho de Melo
2015-07-29  8:11   ` [tip:perf/core] perf header: " tip-bot for Jiri Olsa
2015-07-21 12:31 ` [PATCH 12/47] perf tools: Add thread_map event Jiri Olsa
2015-07-21 12:31 ` [PATCH 13/47] perf tools: Add thread_map event sythesize function Jiri Olsa
2015-07-21 12:31 ` [PATCH 14/47] perf tools: Add thread_map__new_event function Jiri Olsa
2015-07-21 12:31 ` [PATCH 15/47] perf tools: Add cpu_map event Jiri Olsa
2015-07-21 12:31 ` [PATCH 16/47] perf tools: Add cpu_map event synthesize function Jiri Olsa
2015-07-21 12:31 ` [PATCH 17/47] perf tools: Add cpu_map__new_event function Jiri Olsa
2015-07-21 12:31 ` [PATCH 18/47] perf tools: Add stat config event Jiri Olsa
2015-07-21 12:31 ` [PATCH 19/47] perf tools: Add stat config event synthesize function Jiri Olsa
2015-07-21 12:31 ` [PATCH 20/47] perf tools: Add stat config event read function Jiri Olsa
2015-07-21 12:31 ` [PATCH 21/47] perf tools: Add stat event Jiri Olsa
2015-07-21 12:31 ` [PATCH 22/47] perf tools: Add stat event synthesize function Jiri Olsa
2015-07-21 12:31 ` [PATCH 23/47] perf tools: Add stat event read function Jiri Olsa
2015-07-21 12:31 ` [PATCH 24/47] perf tools: Add stat round event Jiri Olsa
2015-07-21 12:31 ` [PATCH 25/47] perf tools: Add stat round event synthesize function Jiri Olsa
2015-07-21 12:31 ` [PATCH 26/47] perf tools: Introduce stat feature Jiri Olsa
2015-07-21 12:31 ` [PATCH 27/47] perf tools: Move id_offset out of struct perf_evsel union Jiri Olsa
2015-07-21 12:31 ` [PATCH 28/47] perf stat record: Add record command Jiri Olsa
2015-07-21 12:31 ` [PATCH 29/47] perf stat record: Initialize record features Jiri Olsa
2015-07-21 12:31 ` [PATCH 30/47] perf stat record: Synthesize stat record data Jiri Olsa
2015-07-21 12:31 ` [PATCH 31/47] perf stat record: Store events IDs in perf data file Jiri Olsa
2015-07-21 12:31 ` [PATCH 32/47] perf stat record: Add pipe support for record command Jiri Olsa
2015-07-21 12:31 ` [PATCH 33/47] perf stat record: Write stat events on record Jiri Olsa
2015-07-21 12:31 ` [PATCH 34/47] perf stat record: Write stat round " Jiri Olsa
2015-07-21 12:31 ` [PATCH 35/47] perf stat report: Add report command Jiri Olsa
2015-07-21 12:31 ` [PATCH 36/47] perf stat report: Process cpu/threads maps Jiri Olsa
2015-07-21 12:31 ` [PATCH 37/47] perf stat report: Process stat config event Jiri Olsa
2015-07-21 12:31 ` [PATCH 38/47] perf stat report: Process stat and stat round events Jiri Olsa
2015-07-21 12:31 ` [PATCH 39/47] perf stat report: Move csv_sep initialization before report command Jiri Olsa
2015-07-21 12:32 ` [PATCH 40/47] perf script: Check output fields only for samples Jiri Olsa
2015-07-21 12:32 ` [PATCH 41/47] perf script: Process cpu/threads maps Jiri Olsa
2015-07-21 12:32 ` [PATCH 42/47] perf script: Process stat config event Jiri Olsa
2015-07-21 12:32 ` [PATCH 43/47] perf script: Add process_stat/process_stat_interval scripting interface Jiri Olsa
2015-07-21 12:32 ` [PATCH 44/47] perf script: Add stat default handlers Jiri Olsa
2015-07-21 12:32 ` [PATCH 45/47] perf script: Display stat events by default Jiri Olsa
2015-07-21 12:32 ` [PATCH 46/47] perf script: Add python support for stat events Jiri Olsa
2015-07-21 12:32 ` [PATCH 47/47] perf script: Add stat-cpi.py script Jiri Olsa
2015-07-21 14:43 ` [RFC 00/47] perf stat: Add scripting support Andi Kleen
2015-07-26 13:51   ` Jiri Olsa
2015-07-27 12:46     ` Liang, Kan
2015-08-06 19:27 ` Arnaldo Carvalho de Melo
2015-08-07  7:45   ` Jiri Olsa
2015-08-07 13:10     ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-421a50f3fafaf271bb3293378eaafca71337dfec@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox