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


Groups > linux.kernel > #1625550

Re: [PATCH v4 5/5] perf report: Show branch type in callchain entry

From Jiri Olsa <jolsa@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v4 5/5] perf report: Show branch type in callchain entry
Date 2017-04-18 21:00 +0200
Message-ID <txGw3-1bd-23@gated-at.bofh.it> (permalink)
References <tv4XU-8aE-5@gated-at.bofh.it> <tv4XV-8aE-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Apr 12, 2017 at 06:21:06AM +0800, Jin Yao wrote:

SNIP

> +static int branch_type_str(struct branch_type_stat *stat,
> +			   char *bf, int bfsize)
> +{
> +	int i, j = 0, printed = 0;
> +	u64 total = 0;
> +
> +	for (i = 0; i < PERF_BR_MAX; i++)
> +		total += stat->counts[i];
> +
> +	if (total == 0)
> +		return 0;
> +
> +	printed += scnprintf(bf + printed, bfsize - printed, " (");
> +
> +	if (stat->jcc_fwd > 0) {
> +		j++;
> +		printed += scnprintf(bf + printed, bfsize - printed,
> +				     "JCC forward");
> +	}
> +
> +	if (stat->jcc_bwd > 0) {
> +		if (j++)
> +			printed += scnprintf(bf + printed, bfsize - printed,
> +					     " JCC backward");
> +		else
> +			printed += scnprintf(bf + printed, bfsize - printed,
> +					     "JCC backward");
> +	}
> +
> +	if (stat->cross_4k > 0) {
> +		if (j++)
> +			printed += scnprintf(bf + printed, bfsize - printed,
> +					     " CROSS_4K");
> +		else
> +			printed += scnprintf(bf + printed, bfsize - printed,
> +					     "CROSS_4K");
> +	}

could that 2 legs if be shortened to just one scnprintf like (untested):

   printed += scnprintf(bf + printed, bfsize - printed, "%s%s", j++ ? " " : "", "CROSS_4K");

I'd also probably use some kind of macro or function
with all that similar code, but I dont insist ;-)

thanks,
jirka

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 0/5] perf report: Show branch type Jin Yao <yao.jin@linux.intel.com> - 2017-04-11 16:30 +0200
  [PATCH v4 2/5] perf/x86/intel: Record branch type Jin Yao <yao.jin@linux.intel.com> - 2017-04-11 16:30 +0200
  [PATCH v4 1/5] perf/core: Define the common branch type classification Jin Yao <yao.jin@linux.intel.com> - 2017-04-11 16:30 +0200
  [PATCH v4 5/5] perf report: Show branch type in callchain entry Jin Yao <yao.jin@linux.intel.com> - 2017-04-11 16:30 +0200
    Re: [PATCH v4 5/5] perf report: Show branch type in callchain entry Jiri Olsa <jolsa@redhat.com> - 2017-04-18 21:00 +0200
      Re: [PATCH v4 5/5] perf report: Show branch type in callchain entry "Jin, Yao" <yao.jin@linux.intel.com> - 2017-04-19 02:40 +0200
    Re: [PATCH v4 5/5] perf report: Show branch type in callchain entry Jiri Olsa <jolsa@redhat.com> - 2017-04-18 21:00 +0200
      Re: [PATCH v4 5/5] perf report: Show branch type in callchain entry "Jin, Yao" <yao.jin@linux.intel.com> - 2017-04-19 02:40 +0200
  Re: [PATCH v4 0/5] perf report: Show branch type Jiri Olsa <jolsa@redhat.com> - 2017-04-12 13:00 +0200
    Re: [PATCH v4 0/5] perf report: Show branch type "Jin, Yao" <yao.jin@linux.intel.com> - 2017-04-12 14:30 +0200
      Re: [PATCH v4 0/5] perf report: Show branch type Jiri Olsa <jolsa@redhat.com> - 2017-04-12 16:30 +0200
        Re: [PATCH v4 0/5] perf report: Show branch type Jiri Olsa <jolsa@redhat.com> - 2017-04-12 17:50 +0200
        Re: [PATCH v4 0/5] perf report: Show branch type "Jin, Yao" <yao.jin@linux.intel.com> - 2017-04-12 17:50 +0200
    Re: [PATCH v4 0/5] perf report: Show branch type "Jin, Yao" <yao.jin@linux.intel.com> - 2017-04-13 04:10 +0200
      Re: [PATCH v4 0/5] perf report: Show branch type "Jin, Yao" <yao.jin@linux.intel.com> - 2017-04-13 05:30 +0200
        Re: [PATCH v4 0/5] perf report: Show branch type Jiri Olsa <jolsa@redhat.com> - 2017-04-13 10:30 +0200

csiph-web