From: "Jin, Yao" <yao.jin@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: acme@kernel.org, jolsa@kernel.org, mingo@redhat.com,
alexander.shishkin@linux.intel.com, mpe@ellerman.id.au,
Linux-kernel@vger.kernel.org, ak@linux.intel.com,
kan.liang@intel.com, yao.jin@intel.com
Subject: Re: [PATCH v8 2/7] perf/x86/intel: Record branch type
Date: Thu, 13 Jul 2017 23:15:14 +0800 [thread overview]
Message-ID: <c325bd11-81d2-9015-eebc-0fda83f00b58@linux.intel.com> (raw)
In-Reply-To: <ec68380d-7762-d7d1-f84d-7d4c8ae190ea@linux.intel.com>
On 7/13/2017 11:06 PM, Jin, Yao wrote:
>
> 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
>
Looks it should be:
if (type)
return branch_map[__ffs(type) - 1];
>>> +
>>> + return PERF_BR_UNKNOWN;
>>> +}
>
next prev parent reply other threads:[~2017-07-13 15:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-13 12:04 [PATCH v8 0/7] perf report: Show branch type Jin Yao
2017-07-13 12:04 ` [PATCH v8 1/7] perf/core: Define the common branch type classification Jin Yao
2017-07-13 12:04 ` Michael Ellerman
2017-07-13 12:33 ` Jin, Yao
2017-07-13 12:04 ` [PATCH v8 2/7] perf/x86/intel: Record branch type Jin Yao
2017-07-13 14:31 ` Peter Zijlstra
2017-07-13 14:53 ` Jin, Yao
2017-07-13 15:06 ` Jin, Yao
2017-07-13 15:15 ` Jin, Yao [this message]
2017-07-13 12:04 ` [PATCH v8 3/7] perf record: Create a new option save_type in --branch-filter Jin Yao
2017-07-13 12:04 ` [PATCH v8 4/7] perf report: Refactor the branch info printing code Jin Yao
2017-07-13 12:04 ` [PATCH v8 5/7] perf util: Create branch.c/.h for common branch functions Jin Yao
2017-07-13 12:04 ` [PATCH v8 6/7] perf report: Show branch type statistics for stdio mode Jin Yao
2017-07-13 12:04 ` [PATCH v8 7/7] perf report: Show branch type in callchain entry Jin Yao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c325bd11-81d2-9015-eebc-0fda83f00b58@linux.intel.com \
--to=yao.jin@linux.intel.com \
--cc=Linux-kernel@vger.kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=peterz@infradead.org \
--cc=yao.jin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox