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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ec68380d-7762-d7d1-f84d-7d4c8ae190ea@linux.intel.com>
Date:   Thu, 13 Jul 2017 23:06:59 +0800
From:   "Jin, Yao" <yao.jin@...ux.intel.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     acme@...nel.org, jolsa@...nel.org, mingo@...hat.com,
        alexander.shishkin@...ux.intel.com, mpe@...erman.id.au,
        Linux-kernel@...r.kernel.org, ak@...ux.intel.com,
        kan.liang@...el.com, yao.jin@...el.com
Subject: Re: [PATCH v8 2/7] perf/x86/intel: Record branch type


Sorry, please ignore my previous response.


On 7/13/2017 10:31 PM, Peter Zijlstra wrote:
> On Thu, Jul 13, 2017 at 08:04:14PM +0800, Jin Yao wrote:
>> +#define X86_BR_TYPE_MAP_MAX	16
>> +
>> +static int
>> +common_branch_type(int type)
>> +{
>> +	int i, mask;
>> +	const int branch_map[X86_BR_TYPE_MAP_MAX] = {
>> +		PERF_BR_CALL,		/* X86_BR_CALL */
>> +		PERF_BR_RET,		/* X86_BR_RET */
>> +		PERF_BR_SYSCALL,	/* X86_BR_SYSCALL */
>> +		PERF_BR_SYSRET,		/* X86_BR_SYSRET */
>> +		PERF_BR_UNKNOWN,	/* X86_BR_INT */
>> +		PERF_BR_UNKNOWN,	/* X86_BR_IRET */
>> +		PERF_BR_COND,		/* X86_BR_JCC */
>> +		PERF_BR_UNCOND,		/* X86_BR_JMP */
>> +		PERF_BR_UNKNOWN,	/* X86_BR_IRQ */
>> +		PERF_BR_IND_CALL,	/* X86_BR_IND_CALL */
>> +		PERF_BR_UNKNOWN,	/* X86_BR_ABORT */
>> +		PERF_BR_UNKNOWN,	/* X86_BR_IN_TX */
>> +		PERF_BR_UNKNOWN,	/* X86_BR_NO_TX */
>> +		PERF_BR_CALL,		/* X86_BR_ZERO_CALL */
>> +		PERF_BR_UNKNOWN,	/* X86_BR_CALL_STACK */
>> +		PERF_BR_IND,		/* X86_BR_IND_JMP */
>> +	};
>> +
>> +	type >>= 2; /* skip X86_BR_USER and X86_BR_KERNEL */
>
>> +	mask = ~(~0 << 1);
> OCC worthy means of writing: 1
>
>> +
>> +	for (i = 0; i < X86_BR_TYPE_MAP_MAX; i++) {
>> +		if (type & mask)
>> +			return branch_map[i];
>> +
>> +		type >>= 1;
>> +	}
> That is some of the more confused code I've seen in a while :/
>
> 	if (type)
> 		return branch_map[__ffs(type)];
>
> is what you meant to write, no?

Now I understand what you suggest. Yes, that's right.

Do I need to update the patch?

Thanks
Jin Yao

>> +
>> +	return PERF_BR_UNKNOWN;
>> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ