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: <98472993-853a-7279-6594-fd173059a4d9@arm.com>
Date:   Tue, 8 Mar 2022 10:36:04 +0530
From:   Anshuman Khandual <anshuman.khandual@....com>
To:     James Clark <james.clark@....com>, acme@...nel.org,
        linux-perf-users@...r.kernel.org
Cc:     german.gomez@....com, leo.yan@...aro.com,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] perf: Refactor perf script branch stack printing



On 3/7/22 22:49, James Clark wrote:
> Remove duplicate code so that future changes to flags are always made to
> all 3 printing variations.
> 
> Signed-off-by: James Clark <james.clark@....com>
> ---
>  tools/perf/builtin-script.c | 27 ++++++++++++---------------
>  1 file changed, 12 insertions(+), 15 deletions(-)
> 
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 9e032343f1c6..fac2e9470926 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -857,6 +857,15 @@ mispred_str(struct branch_entry *br)
>  	return br->flags.predicted ? 'P' : 'M';
>  }
>  
> +static int print_bstack_flags(FILE *fp, struct branch_entry *br)
> +{
> +	return fprintf(fp, "/%c/%c/%c/%d ",
> +		       mispred_str(br),
> +		       br->flags.in_tx ? 'X' : '-',
> +		       br->flags.abort ? 'A' : '-',
> +		       br->flags.cycles);
> +}
> +
>  static int perf_sample__fprintf_brstack(struct perf_sample *sample,
>  					struct thread *thread,
>  					struct perf_event_attr *attr, FILE *fp)
> @@ -895,11 +904,7 @@ static int perf_sample__fprintf_brstack(struct perf_sample *sample,
>  			printed += fprintf(fp, ")");
>  		}
>  
> -		printed += fprintf(fp, "/%c/%c/%c/%d ",
> -			mispred_str(entries + i),
> -			entries[i].flags.in_tx ? 'X' : '-',
> -			entries[i].flags.abort ? 'A' : '-',
> -			entries[i].flags.cycles);
> +		printed += print_bstack_flags(fp, entries + i);
>  	}
>  
>  	return printed;
> @@ -941,11 +946,7 @@ static int perf_sample__fprintf_brstacksym(struct perf_sample *sample,
>  			printed += map__fprintf_dsoname(alt.map, fp);
>  			printed += fprintf(fp, ")");
>  		}
> -		printed += fprintf(fp, "/%c/%c/%c/%d ",
> -			mispred_str(entries + i),
> -			entries[i].flags.in_tx ? 'X' : '-',
> -			entries[i].flags.abort ? 'A' : '-',
> -			entries[i].flags.cycles);
> +		printed += print_bstack_flags(fp, entries + i);
>  	}
>  
>  	return printed;
> @@ -991,11 +992,7 @@ static int perf_sample__fprintf_brstackoff(struct perf_sample *sample,
>  			printed += map__fprintf_dsoname(alt.map, fp);
>  			printed += fprintf(fp, ")");
>  		}
> -		printed += fprintf(fp, "/%c/%c/%c/%d ",
> -			mispred_str(entries + i),
> -			entries[i].flags.in_tx ? 'X' : '-',
> -			entries[i].flags.abort ? 'A' : '-',
> -			entries[i].flags.cycles);
> +		printed += print_bstack_flags(fp, entries + i);
>  	}
>  
>  	return printed;


LGTM

Reviewed-by: Anshuman Khandual <anshuman.khandual@....com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ