"Jin, Yao" <yao.jin@xxxxxxxxxxxxxxx> writes:
On 7/10/2017 2:05 PM, Michael Ellerman wrote:...
Jin Yao <yao.jin@xxxxxxxxxxxxxxx> writes:
It is often useful to know the branch types while analyzing branch
data. For example, a call is very different from a conditional branch.
Yeah I'm not saying we don't need the different types, I'm saying I'dCall and jump are all branches. If we want to figure out which one isTo keep consistent on kernel and userspace and make the classificationMost of the code and doc uses "branch" but then a few these are called
more common, the patch adds the common branch type classification
in perf_event.h.
"jump". Can we just stick with "branch"?
PERF_BR_NONE : unknowneg:
PERF_BR_JCC : conditional jump
PERF_BR_JMP : jump
PERF_BR_IND_JMP : indirect jump
PERF_BR_COND : conditional branch
PERF_BR_UNCOND : unconditional branch
PERF_BR_IND : indirect branch
jump and which one is call, we need the detail branch type definitions.
rather we just called them "branch" not "jump". Just because "jump" can
mean different things on different arches.
For example, if we only say "PERF_BR_IND", we could not know if it's anYes we can, PERF_BR_IND is an indirect branch, which is not a call,
indirect jump or indirect call.
because if it was a call then it would be PERF_BR_IND_CALL.
OK, but I still don't know what that means :)PERF_BR_IRQ is for hw interrupt and PERF_BR_INT is for sw interrupt.PERF_BR_CALL : callI'm not sure what that means, I'm guessing on x86 it means someone
PERF_BR_IND_CALL : indirect call
PERF_BR_RET : return
PERF_BR_SYSCALL : syscall
PERF_BR_SYSRET : syscall return
PERF_BR_IRQ : hw interrupt/trap/fault
PERF_BR_INT : sw interrupt
executed "int" ?
What's an example of an instruction that is PERF_BR_IRQ and PERF_BR_INT ?
PERF_BR_CALL/PERF_BR_IND_CALL and PERF_BR_RET are for function callYep makes sense.
(direct call and indirect call) and return.
PERF_BR_SYSCALL/PERF_BR_SYSRET are for syscall and syscall return.Yep OK.
What I meant was you're using 4 bits for the type, so you have 16Is that sufficiently useful to use up a bit? I think we only have 3Do you means 3 bits? Each bit stands for one branch type? I guess what
free?
you mean is:
PERF_BR_COND : conditional branch
PERF_BR_UNCOND : unconditional branch
PERF_BR_IND : indirect branch
But 3 branch types are not enough for us.
possible values, and you've defined 13 of them. Meaning there are only 3
types free.
So we should try to only define branch types that are really useful, and
keep some free for future use.
Maybe PERF_BR_INT is really common on x86 and so it's important to count
it, but like I said above I don't know what it is.
OK so let's not put it in the Linux API until it's defined?It's reserved for future using I think.PERF_BR_IRET : return from interruptWhat is a "not generic far branch" ?
PERF_BR_FAR_BRANCH: not generic far branch type
I don't know what that would mean on powerpc for example.
...I think the only thing we have on powerpc that's commonly used and that
isn't covered above is branches that decrement a loop counter and then
branch based on the result.
Sorry, I'm not familiar with powerpc arch. Or could you add the branchThese are good:
type which powerpc needs?
+ PERF_BR_COND = 1, /* conditional */
+ PERF_BR_UNCOND = 2, /* unconditional */
+ PERF_BR_IND = 3, /* indirect */
+ PERF_BR_CALL = 4, /* call */
+ PERF_BR_IND_CALL = 5, /* indirect call */
+ PERF_BR_RET = 6, /* return */
These we wouldn't use currently, but make sense:
+ PERF_BR_SYSCALL = 7, /* syscall */
+ PERF_BR_SYSRET = 8, /* syscall return */
+ PERF_BR_IRET = 11, /* return from interrupt */
These I'm not so sure about, I don't really know what they would map to
for us:
+ PERF_BR_IRQ = 9, /* hw interrupt/trap/fault */
+ PERF_BR_INT = 10, /* sw interrupt */
And sounds like this should be dropped for now:
+ PERF_BR_FAR_BRANCH = 12, /* not generic far branch type */
The branch types you haven't covered which might be useful for us are:
PERF_BR_COND_CALL /* Conditional call */
PERF_BR_COND_RET /* Condition return */
cheers