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: <53edb27d-bfa5-7e84-0f6e-ab721c65f457@arm.com>
Date:   Fri, 23 Oct 2020 18:10:52 +0100
From:   André Przywara <andre.przywara@....com>
To:     Leo Yan <leo.yan@...aro.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Wei Li <liwei391@...wei.com>,
        James Clark <james.clark@....com>, Al Grant <Al.Grant@....com>,
        Dave Martin <Dave.Martin@....com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 16/20] perf arm-spe: Add new function
 arm_spe_pkt_desc_op_type()

On 22/10/2020 15:58, Leo Yan wrote:

Hi,

> The operation type packet is complex and contains subclass; the parsing
> flow causes deep indentation; for more readable, this patch introduces
> a new function arm_spe_pkt_desc_op_type() which is used for operation
> type parsing.
> 
> Signed-off-by: Leo Yan <leo.yan@...aro.org>

Compared '-' and '+' with diff -w, no changes.

Reviewed-by: Andre Przywara <andre.przywara@....com>

Thanks,
Andre

> ---
>  .../arm-spe-decoder/arm-spe-pkt-decoder.c     | 122 ++++++++++--------
>  1 file changed, 66 insertions(+), 56 deletions(-)
> 
> diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> index 2cb019999016..19d05d9734ab 100644
> --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> @@ -336,6 +336,70 @@ static int arm_spe_pkt_desc_event(const struct arm_spe_pkt *packet,
>  	return buf_len - blen;
>  }
>  
> +static int arm_spe_pkt_desc_op_type(const struct arm_spe_pkt *packet,
> +				    char *buf, size_t buf_len)
> +{
> +	int ret, idx = packet->index;
> +	unsigned long long payload = packet->payload;
> +	size_t blen = buf_len;
> +
> +	switch (idx) {
> +	case 0:
> +		return arm_spe_pkt_snprintf(&buf, &blen,
> +				payload & 0x1 ? "COND-SELECT" : "INSN-OTHER");
> +	case 1:
> +		ret = arm_spe_pkt_snprintf(&buf, &blen,
> +					   payload & 0x1 ? "ST" : "LD");
> +		if (ret < 0)
> +			return ret;
> +
> +		if (payload & 0x2) {
> +			if (payload & 0x4) {
> +				ret = arm_spe_pkt_snprintf(&buf, &blen, " AT");
> +				if (ret < 0)
> +					return ret;
> +			}
> +			if (payload & 0x8) {
> +				ret = arm_spe_pkt_snprintf(&buf, &blen, " EXCL");
> +				if (ret < 0)
> +					return ret;
> +			}
> +			if (payload & 0x10) {
> +				ret = arm_spe_pkt_snprintf(&buf, &blen, " AR");
> +				if (ret < 0)
> +					return ret;
> +			}
> +		} else if (payload & 0x4) {
> +			ret = arm_spe_pkt_snprintf(&buf, &blen, " SIMD-FP");
> +			if (ret < 0)
> +				return ret;
> +		}
> +
> +		return buf_len - blen;
> +
> +	case 2:
> +		ret = arm_spe_pkt_snprintf(&buf, &blen, "B");
> +		if (ret < 0)
> +			return ret;
> +
> +		if (payload & 0x1) {
> +			ret = arm_spe_pkt_snprintf(&buf, &blen, " COND");
> +			if (ret < 0)
> +				return ret;
> +		}
> +		if (payload & 0x2) {
> +			ret = arm_spe_pkt_snprintf(&buf, &blen, " IND");
> +			if (ret < 0)
> +				return ret;
> +		}
> +
> +		return buf_len - blen;
> +
> +	default:
> +		return 0;
> +	}
> +}
> +
>  static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
>  				 char *buf, size_t buf_len)
>  {
> @@ -403,7 +467,7 @@ static int arm_spe_pkt_desc_counter(const struct arm_spe_pkt *packet,
>  int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
>  		     size_t buf_len)
>  {
> -	int ret, idx = packet->index;
> +	int idx = packet->index;
>  	unsigned long long payload = packet->payload;
>  	const char *name = arm_spe_pkt_name(packet->type);
>  	size_t blen = buf_len;
> @@ -416,61 +480,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
>  	case ARM_SPE_EVENTS:
>  		return arm_spe_pkt_desc_event(packet, buf, buf_len);
>  	case ARM_SPE_OP_TYPE:
> -		switch (idx) {
> -		case 0:
> -			return arm_spe_pkt_snprintf(&buf, &blen,
> -					payload & 0x1 ? "COND-SELECT" : "INSN-OTHER");
> -		case 1:
> -			ret = arm_spe_pkt_snprintf(&buf, &blen,
> -						   payload & 0x1 ? "ST" : "LD");
> -			if (ret < 0)
> -				return ret;
> -
> -			if (payload & 0x2) {
> -				if (payload & 0x4) {
> -					ret = arm_spe_pkt_snprintf(&buf, &blen, " AT");
> -					if (ret < 0)
> -						return ret;
> -				}
> -				if (payload & 0x8) {
> -					ret = arm_spe_pkt_snprintf(&buf, &blen, " EXCL");
> -					if (ret < 0)
> -						return ret;
> -				}
> -				if (payload & 0x10) {
> -					ret = arm_spe_pkt_snprintf(&buf, &blen, " AR");
> -					if (ret < 0)
> -						return ret;
> -				}
> -			} else if (payload & 0x4) {
> -				ret = arm_spe_pkt_snprintf(&buf, &blen, " SIMD-FP");
> -				if (ret < 0)
> -					return ret;
> -			}
> -
> -			return buf_len - blen;
> -
> -		case 2:
> -			ret = arm_spe_pkt_snprintf(&buf, &blen, "B");
> -			if (ret < 0)
> -				return ret;
> -
> -			if (payload & 0x1) {
> -				ret = arm_spe_pkt_snprintf(&buf, &blen, " COND");
> -				if (ret < 0)
> -					return ret;
> -			}
> -			if (payload & 0x2) {
> -				ret = arm_spe_pkt_snprintf(&buf, &blen, " IND");
> -				if (ret < 0)
> -					return ret;
> -			}
> -
> -			return buf_len - blen;
> -
> -		default:
> -			return 0;
> -		}
> +		return arm_spe_pkt_desc_op_type(packet, buf, buf_len);
>  	case ARM_SPE_DATA_SOURCE:
>  	case ARM_SPE_TIMESTAMP:
>  		return arm_spe_pkt_snprintf(&buf, &blen, "%s %lld", name, payload);
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ