lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150730134755.GP9606@krava.brq.redhat.com>
Date:	Thu, 30 Jul 2015 15:47:55 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	Andi Kleen <andi@...stfloor.org>
Cc:	acme@...nel.org, jolsa@...nel.org, eranian@...gle.com,
	linux-kernel@...r.kernel.org, Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH 2/4] perf, tools, stat: Abstract stat metrics printing

On Wed, Jul 29, 2015 at 05:21:38PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@...ux.intel.com>
> 
> Abstract the printing of shadow metrics. Instead of every
> metric calling fprintf directly and taking care of indentation,
> use two call backs: one to print metrics and another to
> start a new line.
> 
> This will allow adding metrics to CSV mode and also
> using them for other purposes.
> 
> The computation of padding is now done in the central
> callback, instead of every metric doing it manually.
> This makes it easier to add new metrics.
> 
> Right now there is no (intentional) behavior change, just refactoring.
> 
> Signed-off-by: Andi Kleen <ak@...ux.intel.com>
> ---
>  tools/perf/builtin-stat.c     |  98 +++++++++++++++++++--------
>  tools/perf/util/stat-shadow.c | 154 ++++++++++++++++++++++--------------------
>  tools/perf/util/stat.h        |  10 ++-
>  3 files changed, 160 insertions(+), 102 deletions(-)
> 
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index d99d850..e6386f1 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -617,7 +617,49 @@ static void aggr_printout(struct perf_evsel *evsel, int id, int nr)
>  	}
>  }
>  
> -static void nsec_printout(int id, int nr, struct perf_evsel *evsel, double avg)
> +struct outstate {
> +	FILE *fh;
> +};


because we already need to make the print_metric callback global,
would it be better to make this struct global, having all the
needed callbacks defined within? something like:

typedef void (*perf_stat_output_metric_t)(void *ctx, const char *color, const char *unit,
					  const char *fmt, double val);

typedef void (*perf_stat_output_newln_t)(void *ctx);

struct perf_stat_output_ctx {
	FILE			  *output
	perf_stat_output_metric_t  metric;
	perf_stat_output_newln_t   nl;
};

not sure about the naming, but IMO should have some perf_sta_.. global form

it'd also ease the new arguments count from 3 to 1

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ