Commit 8897a891 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf stat: Move ru_* data to 'struct perf_stat_config'

Move the 'ru_*' global variables to 'struct perf_stat_config', so that
it can be passed around and used outside the 'perf stat' command.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180830063252.23729-36-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 3b3cd9a4
...@@ -171,8 +171,6 @@ static bool interval_count; ...@@ -171,8 +171,6 @@ static bool interval_count;
static const char *output_name; static const char *output_name;
static int output_fd; static int output_fd;
static u64 *walltime_run; static u64 *walltime_run;
static bool ru_display = false;
static struct rusage ru_data;
struct perf_stat { struct perf_stat {
bool record; bool record;
...@@ -583,7 +581,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) ...@@ -583,7 +581,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
break; break;
} }
} }
wait4(child_pid, &status, 0, &ru_data); wait4(child_pid, &status, 0, &stat_config.ru_data);
if (workload_exec_errno) { if (workload_exec_errno) {
const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg)); const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg));
...@@ -1679,9 +1677,9 @@ static void print_footer(struct perf_stat_config *config) ...@@ -1679,9 +1677,9 @@ static void print_footer(struct perf_stat_config *config)
if (config->run_count == 1) { if (config->run_count == 1) {
fprintf(output, " %17.9f seconds time elapsed", avg); fprintf(output, " %17.9f seconds time elapsed", avg);
if (ru_display) { if (config->ru_display) {
double ru_utime = timeval2double(&ru_data.ru_utime); double ru_utime = timeval2double(&config->ru_data.ru_utime);
double ru_stime = timeval2double(&ru_data.ru_stime); double ru_stime = timeval2double(&config->ru_data.ru_stime);
fprintf(output, "\n\n"); fprintf(output, "\n\n");
fprintf(output, " %17.9f seconds user\n", ru_utime); fprintf(output, " %17.9f seconds user\n", ru_utime);
...@@ -2855,7 +2853,7 @@ int cmd_stat(int argc, const char **argv) ...@@ -2855,7 +2853,7 @@ int cmd_stat(int argc, const char **argv)
* run and when there's specified tracee. * run and when there's specified tracee.
*/ */
if ((stat_config.run_count == 1) && target__none(&target)) if ((stat_config.run_count == 1) && target__none(&target))
ru_display = true; stat_config.ru_display = true;
if (stat_config.run_count < 0) { if (stat_config.run_count < 0) {
pr_err("Run count must be a positive number\n"); pr_err("Run count must be a positive number\n");
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
#include <linux/types.h> #include <linux/types.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include "xyarray.h" #include "xyarray.h"
#include "rblist.h" #include "rblist.h"
#include "perf.h" #include "perf.h"
...@@ -95,6 +99,7 @@ struct perf_stat_config { ...@@ -95,6 +99,7 @@ struct perf_stat_config {
bool interval_clear; bool interval_clear;
bool metric_only; bool metric_only;
bool null_run; bool null_run;
bool ru_display;
FILE *output; FILE *output;
unsigned int interval; unsigned int interval;
unsigned int timeout; unsigned int timeout;
...@@ -109,6 +114,7 @@ struct perf_stat_config { ...@@ -109,6 +114,7 @@ struct perf_stat_config {
int stats_num; int stats_num;
const char *csv_sep; const char *csv_sep;
struct stats *walltime_nsecs_stats; struct stats *walltime_nsecs_stats;
struct rusage ru_data;
}; };
void update_stats(struct stats *stats, u64 val); void update_stats(struct stats *stats, u64 val);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment