[PATCH 09/26] perf stat: Move 'interval' into struct perf_stat_config

2015-08-06 Thread Arnaldo Carvalho de Melo
From: Jiri Olsa 

Moving 'interval' into struct perf_stat_config. 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 
Cc: David Ahern 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1437481927-29538-6-git-send-email-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-stat.c | 14 +-
 tools/perf/util/stat.h|  1 +
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index e3ea8b67703d..1bdfec8f5fe6 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -113,7 +113,6 @@ static bool group   
= false;
 static const char  *pre_cmd= NULL;
 static const char  *post_cmd   = NULL;
 static boolsync_run= false;
-static unsigned intinterval= 0;
 static unsigned intinitial_delay   = 0;
 static unsigned intunit_width  = 4; /* 
strlen("unit") */
 static boolforever = false;
@@ -404,6 +403,7 @@ static void workload_exec_failed_signal(int signo 
__maybe_unused, siginfo_t *inf
 
 static int __run_perf_stat(int argc, const char **argv)
 {
+   int interval = stat_config.interval;
char msg[512];
unsigned long long t0, t1;
struct perf_evsel *counter;
@@ -646,7 +646,7 @@ static void nsec_printout(int id, int nr, struct perf_evsel 
*evsel, double avg)
if (evsel->cgrp)
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
 
-   if (csv_output || interval)
+   if (csv_output || stat_config.interval)
return;
 
if (perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK))
@@ -689,7 +689,7 @@ static void abs_printout(int id, int nr, struct perf_evsel 
*evsel, double avg)
if (evsel->cgrp)
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
 
-   if (csv_output || interval)
+   if (csv_output || stat_config.interval)
return;
 
perf_stat__print_shadow_stats(output, evsel, avg, cpu,
@@ -990,6 +990,7 @@ static void print_footer(void)
 
 static void print_counters(struct timespec *ts, int argc, const char **argv)
 {
+   int interval = stat_config.interval;
struct perf_evsel *counter;
char buf[64], *prefix = NULL;
 
@@ -1029,7 +1030,7 @@ static volatile int signr = -1;
 
 static void skip_signal(int signo)
 {
-   if ((child_pid == -1) || interval)
+   if ((child_pid == -1) || stat_config.interval)
done = 1;
 
signr = signo;
@@ -1313,7 +1314,7 @@ int cmd_stat(int argc, const char **argv, const char 
*prefix __maybe_unused)
"command to run prior to the measured command"),
OPT_STRING(0, "post", _cmd, "command",
"command to run after to the measured command"),
-   OPT_UINTEGER('I', "interval-print", ,
+   OPT_UINTEGER('I', "interval-print", _config.interval,
"print counts at regular interval in ms (>= 100)"),
OPT_SET_UINT(0, "per-socket", _config.aggr_mode,
 "aggregate counts per processor socket", AGGR_SOCKET),
@@ -1332,6 +1333,7 @@ int cmd_stat(int argc, const char **argv, const char 
*prefix __maybe_unused)
int status = -EINVAL, run_idx;
const char *mode;
FILE *output = stderr;
+   unsigned int interval;
 
setlocale(LC_ALL, "");
 
@@ -1342,6 +1344,8 @@ int cmd_stat(int argc, const char **argv, const char 
*prefix __maybe_unused)
argc = parse_options(argc, argv, options, stat_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
 
+   interval = stat_config.interval;
+
if (output_name && strcmp(output_name, "-"))
output = NULL;
 
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index ed0e05829cb0..1da706d848fb 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -54,6 +54,7 @@ struct perf_stat_config {
enum aggr_mode  aggr_mode;
boolscale;
FILE*output;
+   unsigned intinterval;
 };
 
 static inline struct perf_counts_values*
-- 
2.1.0

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


[PATCH 09/26] perf stat: Move 'interval' into struct perf_stat_config

2015-08-06 Thread Arnaldo Carvalho de Melo
From: Jiri Olsa jo...@kernel.org

Moving 'interval' into struct perf_stat_config. 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 jo...@kernel.org
Cc: David Ahern dsah...@gmail.com
Cc: Namhyung Kim namhy...@kernel.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Link: 
http://lkml.kernel.org/r/1437481927-29538-6-git-send-email-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/builtin-stat.c | 14 +-
 tools/perf/util/stat.h|  1 +
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index e3ea8b67703d..1bdfec8f5fe6 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -113,7 +113,6 @@ static bool group   
= false;
 static const char  *pre_cmd= NULL;
 static const char  *post_cmd   = NULL;
 static boolsync_run= false;
-static unsigned intinterval= 0;
 static unsigned intinitial_delay   = 0;
 static unsigned intunit_width  = 4; /* 
strlen(unit) */
 static boolforever = false;
@@ -404,6 +403,7 @@ static void workload_exec_failed_signal(int signo 
__maybe_unused, siginfo_t *inf
 
 static int __run_perf_stat(int argc, const char **argv)
 {
+   int interval = stat_config.interval;
char msg[512];
unsigned long long t0, t1;
struct perf_evsel *counter;
@@ -646,7 +646,7 @@ static void nsec_printout(int id, int nr, struct perf_evsel 
*evsel, double avg)
if (evsel-cgrp)
fprintf(output, %s%s, csv_sep, evsel-cgrp-name);
 
-   if (csv_output || interval)
+   if (csv_output || stat_config.interval)
return;
 
if (perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK))
@@ -689,7 +689,7 @@ static void abs_printout(int id, int nr, struct perf_evsel 
*evsel, double avg)
if (evsel-cgrp)
fprintf(output, %s%s, csv_sep, evsel-cgrp-name);
 
-   if (csv_output || interval)
+   if (csv_output || stat_config.interval)
return;
 
perf_stat__print_shadow_stats(output, evsel, avg, cpu,
@@ -990,6 +990,7 @@ static void print_footer(void)
 
 static void print_counters(struct timespec *ts, int argc, const char **argv)
 {
+   int interval = stat_config.interval;
struct perf_evsel *counter;
char buf[64], *prefix = NULL;
 
@@ -1029,7 +1030,7 @@ static volatile int signr = -1;
 
 static void skip_signal(int signo)
 {
-   if ((child_pid == -1) || interval)
+   if ((child_pid == -1) || stat_config.interval)
done = 1;
 
signr = signo;
@@ -1313,7 +1314,7 @@ int cmd_stat(int argc, const char **argv, const char 
*prefix __maybe_unused)
command to run prior to the measured command),
OPT_STRING(0, post, post_cmd, command,
command to run after to the measured command),
-   OPT_UINTEGER('I', interval-print, interval,
+   OPT_UINTEGER('I', interval-print, stat_config.interval,
print counts at regular interval in ms (= 100)),
OPT_SET_UINT(0, per-socket, stat_config.aggr_mode,
 aggregate counts per processor socket, AGGR_SOCKET),
@@ -1332,6 +1333,7 @@ int cmd_stat(int argc, const char **argv, const char 
*prefix __maybe_unused)
int status = -EINVAL, run_idx;
const char *mode;
FILE *output = stderr;
+   unsigned int interval;
 
setlocale(LC_ALL, );
 
@@ -1342,6 +1344,8 @@ int cmd_stat(int argc, const char **argv, const char 
*prefix __maybe_unused)
argc = parse_options(argc, argv, options, stat_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
 
+   interval = stat_config.interval;
+
if (output_name  strcmp(output_name, -))
output = NULL;
 
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index ed0e05829cb0..1da706d848fb 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -54,6 +54,7 @@ struct perf_stat_config {
enum aggr_mode  aggr_mode;
boolscale;
FILE*output;
+   unsigned intinterval;
 };
 
 static inline struct perf_counts_values*
-- 
2.1.0

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