Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1683972 > unrolled thread
| Started by | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| First post | 2017-07-10 08:10 +0200 |
| Last post | 2017-07-11 04:20 +0200 |
| Articles | 12 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification Michael Ellerman <mpe@ellerman.id.au> - 2017-07-10 08:10 +0200
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification "Jin, Yao" <yao.jin@linux.intel.com> - 2017-07-10 10:20 +0200
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification Michael Ellerman <mpe@ellerman.id.au> - 2017-07-10 12:40 +0200
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification "Jin, Yao" <yao.jin@linux.intel.com> - 2017-07-10 13:50 +0200
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification Segher Boessenkool <segher@kernel.crashing.org> - 2017-07-10 15:20 +0200
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification "Jin, Yao" <yao.jin@linux.intel.com> - 2017-07-10 15:30 +0200
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification Peter Zijlstra <peterz@infradead.org> - 2017-07-10 15:50 +0200
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification "Jin, Yao" <yao.jin@linux.intel.com> - 2017-07-10 16:10 +0200
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification Michael Ellerman <mpe@ellerman.id.au> - 2017-07-11 04:30 +0200
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification "Jin, Yao" <yao.jin@linux.intel.com> - 2017-07-11 05:10 +0200
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification Segher Boessenkool <segher@kernel.crashing.org> - 2017-07-10 16:40 +0200
Re: [PATCH v6 1/7] perf/core: Define the common branch type classification Michael Ellerman <mpe@ellerman.id.au> - 2017-07-11 04:20 +0200
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2017-07-10 08:10 +0200 |
| Subject | Re: [PATCH v6 1/7] perf/core: Define the common branch type classification |
| Message-ID | <u1A3o-1hK-5@gated-at.bofh.it> |
Hi Jin Yao, Sorry I haven't commented until now, but it got lost in the flood of patches. Just a few nit-picks below ... Jin Yao <yao.jin@linux.intel.com> 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. > > Currently we have to look it up in binary while the binary may later > not be available and even the binary is available but user has to take > some time. It is very useful for user to check it directly in perf > report. > > Perf already has support for disassembling the branch instruction > to get the x86 branch type. > > To keep consistent on kernel and userspace and make the classification > more common, the patch adds the common branch type classification > in perf_event.h. Most of the code and doc uses "branch" but then a few these are called "jump". Can we just stick with "branch"? > PERF_BR_NONE : unknown > PERF_BR_JCC : conditional jump > PERF_BR_JMP : jump > PERF_BR_IND_JMP : indirect jump eg: PERF_BR_COND : conditional branch PERF_BR_UNCOND : unconditional branch PERF_BR_IND : indirect branch > PERF_BR_CALL : call > 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 I'm not sure what that means, I'm guessing on x86 it means someone executed "int" ? Is that sufficiently useful to use up a bit? I think we only have 3 free? > PERF_BR_IRET : return from interrupt > PERF_BR_FAR_BRANCH: not generic far branch type What is a "not generic far branch" ? 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. It might be nice if we could separate those out from other conditional branches. Whether it's worth using a bit for I'm not sure. Do other arches have something similar? Those branches do tend to be "backward conditional", so that may be sufficient. But backward conditional also includes if bodies that have been moved out of line and then branch back to the main body of the function. cheers
[toc] | [next] | [standalone]
| From | "Jin, Yao" <yao.jin@linux.intel.com> |
|---|---|
| Date | 2017-07-10 10:20 +0200 |
| Subject | Re: [PATCH v6 1/7] perf/core: Define the common branch type classification |
| Message-ID | <u1C5c-2xU-15@gated-at.bofh.it> |
| In reply to | #1683972 |
On 7/10/2017 2:05 PM, Michael Ellerman wrote: > Hi Jin Yao, > > Sorry I haven't commented until now, but it got lost in the flood of > patches. Never mind, it's no problem. :) > Just a few nit-picks below ... > Jin Yao <yao.jin@linux.intel.com> 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. >> >> Currently we have to look it up in binary while the binary may later >> not be available and even the binary is available but user has to take >> some time. It is very useful for user to check it directly in perf >> report. >> >> Perf already has support for disassembling the branch instruction >> to get the x86 branch type. >> >> To keep consistent on kernel and userspace and make the classification >> more common, the patch adds the common branch type classification >> in perf_event.h. > Most of the code and doc uses "branch" but then a few these are called > "jump". Can we just stick with "branch"? > >> PERF_BR_NONE : unknown >> PERF_BR_JCC : conditional jump >> PERF_BR_JMP : jump >> PERF_BR_IND_JMP : indirect jump > eg: > > PERF_BR_COND : conditional branch > PERF_BR_UNCOND : unconditional branch > PERF_BR_IND : indirect branch Call and jump are all branches. If we want to figure out which one is jump and which one is call, we need the detail branch type definitions. For example, if we only say "PERF_BR_IND", we could not know if it's an indirect jump or indirect call. >> PERF_BR_CALL : call >> 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 > I'm not sure what that means, I'm guessing on x86 it means someone > executed "int" ? PERF_BR_IRQ is for hw interrupt and PERF_BR_INT is for sw interrupt. PERF_BR_CALL/PERF_BR_IND_CALL and PERF_BR_RET are for function call (direct call and indirect call) and return. PERF_BR_SYSCALL/PERF_BR_SYSRET are for syscall and syscall return. > Is that sufficiently useful to use up a bit? I think we only have 3 > free? Do you means 3 bits? Each bit stands for one branch type? I guess what 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. >> PERF_BR_IRET : return from interrupt >> PERF_BR_FAR_BRANCH: not generic far branch type > What is a "not generic far branch" ? > > I don't know what that would mean on powerpc for example. It's reserved for future using I think. > > 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. > > It might be nice if we could separate those out from other conditional > branches. Whether it's worth using a bit for I'm not sure. Do other > arches have something similar? > > Those branches do tend to be "backward conditional", so that may be > sufficient. But backward conditional also includes if bodies that have > been moved out of line and then branch back to the main body of the > function. > > cheers Sorry, I'm not familiar with powerpc arch. Or could you add the branch type which powerpc needs? For backward conditional and forward conditional, we compute them in userspace according to the from/to addresses. Thanks Jin Yao
[toc] | [prev] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2017-07-10 12:40 +0200 |
| Message-ID | <u1EgF-3Sw-1@gated-at.bofh.it> |
| In reply to | #1684045 |
"Jin, Yao" <yao.jin@linux.intel.com> writes: > On 7/10/2017 2:05 PM, Michael Ellerman wrote: >> Jin Yao <yao.jin@linux.intel.com> 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. >>> ... >>> To keep consistent on kernel and userspace and make the classification >>> more common, the patch adds the common branch type classification >>> in perf_event.h. >> >> Most of the code and doc uses "branch" but then a few these are called >> "jump". Can we just stick with "branch"? >> >>> PERF_BR_NONE : unknown >>> PERF_BR_JCC : conditional jump >>> PERF_BR_JMP : jump >>> PERF_BR_IND_JMP : indirect jump >> eg: >> >> PERF_BR_COND : conditional branch >> PERF_BR_UNCOND : unconditional branch >> PERF_BR_IND : indirect branch > > Call and jump are all branches. If we want to figure out which one is > jump and which one is call, we need the detail branch type definitions. Yeah I'm not saying we don't need the different types, I'm saying I'd 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 an > indirect jump or indirect call. Yes we can, PERF_BR_IND is an indirect branch, which is not a call, because if it was a call then it would be PERF_BR_IND_CALL. >>> PERF_BR_CALL : call >>> 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 >> I'm not sure what that means, I'm guessing on x86 it means someone >> executed "int" ? > > PERF_BR_IRQ is for hw interrupt and PERF_BR_INT is for sw interrupt. OK, but I still don't know what that means :) 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 call > (direct call and indirect call) and return. Yep makes sense. > PERF_BR_SYSCALL/PERF_BR_SYSRET are for syscall and syscall return. Yep OK. >> Is that sufficiently useful to use up a bit? I think we only have 3 >> free? > > Do you means 3 bits? Each bit stands for one branch type? I guess what > 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. What I meant was you're using 4 bits for the type, so you have 16 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. >>> PERF_BR_IRET : return from interrupt >>> PERF_BR_FAR_BRANCH: not generic far branch type >> What is a "not generic far branch" ? >> >> I don't know what that would mean on powerpc for example. > > It's reserved for future using I think. OK so let's not put it in the Linux API until it's defined? >> 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 branch > type which powerpc needs? These are good: + 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
[toc] | [prev] | [next] | [standalone]
| From | "Jin, Yao" <yao.jin@linux.intel.com> |
|---|---|
| Date | 2017-07-10 13:50 +0200 |
| Subject | Re: [PATCH v6 1/7] perf/core: Define the common branch type classification |
| Message-ID | <u1Fmq-4u7-5@gated-at.bofh.it> |
| In reply to | #1684124 |
Hi Michael, Please let me summarize for the new branch type definitions. 1. We all agree these definitions: + 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 */ + PERF_BR_SYSCALL = 7, /* syscall */ + PERF_BR_SYSRET = 8, /* syscall return */ + PERF_BR_IRET = 11, /* return from interrupt */ 2. I wish to keep following definitions for x86. + PERF_BR_IRQ = 9, /* hw interrupt/trap/fault */ + PERF_BR_INT = 10, /* sw interrupt */ PERF_BR_INT is triggered by instruction "int" . PERF_BR_IRQ is triggered by interrupts, traps, faults (the ring 0,3 transition). 3. I can drop PERF_BR_FAR_BRANCH 4. I'd like to add following types for powerpc. PERF_BR_COND_CALL /* Conditional call */ PERF_BR_COND_RET /* Condition return */ If you agree these new definitions, I will prepare the new patch. Thanks Jin Yao On 7/10/2017 6:32 PM, Michael Ellerman wrote: > "Jin, Yao" <yao.jin@linux.intel.com> writes: >> On 7/10/2017 2:05 PM, Michael Ellerman wrote: >>> Jin Yao <yao.jin@linux.intel.com> 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. >>>> > ... >>>> To keep consistent on kernel and userspace and make the classification >>>> more common, the patch adds the common branch type classification >>>> in perf_event.h. >>> Most of the code and doc uses "branch" but then a few these are called >>> "jump". Can we just stick with "branch"? >>> >>>> PERF_BR_NONE : unknown >>>> PERF_BR_JCC : conditional jump >>>> PERF_BR_JMP : jump >>>> PERF_BR_IND_JMP : indirect jump >>> eg: >>> >>> PERF_BR_COND : conditional branch >>> PERF_BR_UNCOND : unconditional branch >>> PERF_BR_IND : indirect branch >> Call and jump are all branches. If we want to figure out which one is >> jump and which one is call, we need the detail branch type definitions. > Yeah I'm not saying we don't need the different types, I'm saying I'd > 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 an >> indirect jump or indirect call. > Yes we can, PERF_BR_IND is an indirect branch, which is not a call, > because if it was a call then it would be PERF_BR_IND_CALL. > >>>> PERF_BR_CALL : call >>>> 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 >>> I'm not sure what that means, I'm guessing on x86 it means someone >>> executed "int" ? >> PERF_BR_IRQ is for hw interrupt and PERF_BR_INT is for sw interrupt. > OK, but I still don't know what that means :) > > 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 call >> (direct call and indirect call) and return. > Yep makes sense. > >> PERF_BR_SYSCALL/PERF_BR_SYSRET are for syscall and syscall return. > Yep OK. > >>> Is that sufficiently useful to use up a bit? I think we only have 3 >>> free? >> Do you means 3 bits? Each bit stands for one branch type? I guess what >> 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. > What I meant was you're using 4 bits for the type, so you have 16 > 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. > >>>> PERF_BR_IRET : return from interrupt >>>> PERF_BR_FAR_BRANCH: not generic far branch type >>> What is a "not generic far branch" ? >>> >>> I don't know what that would mean on powerpc for example. >> It's reserved for future using I think. > OK so let's not put it in the Linux API until it's defined? > >>> 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 branch >> type which powerpc needs? > These are good: > > + 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
[toc] | [prev] | [next] | [standalone]
| From | Segher Boessenkool <segher@kernel.crashing.org> |
|---|---|
| Date | 2017-07-10 15:20 +0200 |
| Message-ID | <u1GLw-5vA-11@gated-at.bofh.it> |
| In reply to | #1684161 |
Hi! On Mon, Jul 10, 2017 at 07:46:17PM +0800, Jin, Yao wrote: > 1. We all agree these definitions: > > + 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 */ > + PERF_BR_SYSCALL = 7, /* syscall */ > + PERF_BR_SYSRET = 8, /* syscall return */ > + PERF_BR_IRET = 11, /* return from interrupt */ Do we? It does not map very well to PowerPC branch types. > 2. I wish to keep following definitions for x86. > > + PERF_BR_IRQ = 9, /* hw interrupt/trap/fault */ > + PERF_BR_INT = 10, /* sw interrupt */ > > PERF_BR_INT is triggered by instruction "int" . > PERF_BR_IRQ is triggered by interrupts, traps, faults (the ring 0,3 > transition). So your "PERF_BR_INT" is a system call? And PERF_BR_IRQ is not an interrupt request (as its name suggests), not what we call an "external interrupt" either; instead it is every interrupt that is not a system call? It also does not follow the lines of "software caused interrupt" vs. the rest. > 4. I'd like to add following types for powerpc. > > PERF_BR_COND_CALL /* Conditional call */ > PERF_BR_COND_RET /* Condition return */ Almost all PowerPC branches have a "conditional" version (only "syscall" and "sysret/iret" do not -- and those last two are the same, just like PERF_BR_INT seems to be the same as PERF_BR_SYSCALL). So how should those PERF_BR_* be used? It cannot be used in an architecture-neutral interface the way you define it now. Segher
[toc] | [prev] | [next] | [standalone]
| From | "Jin, Yao" <yao.jin@linux.intel.com> |
|---|---|
| Date | 2017-07-10 15:30 +0200 |
| Subject | Re: [PATCH v6 1/7] perf/core: Define the common branch type classification |
| Message-ID | <u1GVb-5yK-9@gated-at.bofh.it> |
| In reply to | #1684224 |
Hi, Following branch types should be common enough, right? + 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 */ I decide to only define these types in this patch set. For other more arch-related branch type, we can add it in future. Is this OK? Thanks Jin Yao On 7/10/2017 9:10 PM, Segher Boessenkool wrote: > Hi! > > On Mon, Jul 10, 2017 at 07:46:17PM +0800, Jin, Yao wrote: >> 1. We all agree these definitions: >> >> + 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 */ >> + PERF_BR_SYSCALL = 7, /* syscall */ >> + PERF_BR_SYSRET = 8, /* syscall return */ >> + PERF_BR_IRET = 11, /* return from interrupt */ > Do we? It does not map very well to PowerPC branch types. > >> 2. I wish to keep following definitions for x86. >> >> + PERF_BR_IRQ = 9, /* hw interrupt/trap/fault */ >> + PERF_BR_INT = 10, /* sw interrupt */ >> >> PERF_BR_INT is triggered by instruction "int" . >> PERF_BR_IRQ is triggered by interrupts, traps, faults (the ring 0,3 >> transition). > So your "PERF_BR_INT" is a system call? And PERF_BR_IRQ is not an > interrupt request (as its name suggests), not what we call an "external > interrupt" either; instead it is every interrupt that is not a system > call? > > It also does not follow the lines of "software caused interrupt" vs. > the rest. > >> 4. I'd like to add following types for powerpc. >> >> PERF_BR_COND_CALL /* Conditional call */ >> PERF_BR_COND_RET /* Condition return */ > Almost all PowerPC branches have a "conditional" version (only "syscall" > and "sysret/iret" do not -- and those last two are the same, just like > PERF_BR_INT seems to be the same as PERF_BR_SYSCALL). > > So how should those PERF_BR_* be used? It cannot be used in an > architecture-neutral interface the way you define it now. > > > Segher
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2017-07-10 15:50 +0200 |
| Subject | Re: [PATCH v6 1/7] perf/core: Define the common branch type classification |
| Message-ID | <u1Hey-5Fo-15@gated-at.bofh.it> |
| In reply to | #1684224 |
On Mon, Jul 10, 2017 at 08:10:50AM -0500, Segher Boessenkool wrote: > > PERF_BR_INT is triggered by instruction "int" . > > PERF_BR_IRQ is triggered by interrupts, traps, faults (the ring 0,3 > > transition). > > So your "PERF_BR_INT" is a system call? The "INT" thing has indeed been used as system call mechanism (typically INT 80). But these days we have special purpose syscall instructions. It could maybe be compared to the PPC "Unconditional TRAP with immediate" where you use the immediate value as an index into a handler vector. > And PERF_BR_IRQ is not an interrupt request (as its name suggests), > not what we call an "external interrupt" either; instead it is every > interrupt that is not a system call? It is actual interrupts, but also faults, traps and all the other exceptions not caused by "INT" I think.
[toc] | [prev] | [next] | [standalone]
| From | "Jin, Yao" <yao.jin@linux.intel.com> |
|---|---|
| Date | 2017-07-10 16:10 +0200 |
| Subject | Re: [PATCH v6 1/7] perf/core: Define the common branch type classification |
| Message-ID | <u1HxU-61m-21@gated-at.bofh.it> |
| In reply to | #1684249 |
On 7/10/2017 9:46 PM, Peter Zijlstra wrote: > On Mon, Jul 10, 2017 at 08:10:50AM -0500, Segher Boessenkool wrote: > >>> PERF_BR_INT is triggered by instruction "int" . >>> PERF_BR_IRQ is triggered by interrupts, traps, faults (the ring 0,3 >>> transition). >> So your "PERF_BR_INT" is a system call? > The "INT" thing has indeed been used as system call mechanism (typically > INT 80). But these days we have special purpose syscall instructions. > > It could maybe be compared to the PPC "Unconditional TRAP with > immediate" where you use the immediate value as an index into a handler > vector. > >> And PERF_BR_IRQ is not an interrupt request (as its name suggests), >> not what we call an "external interrupt" either; instead it is every >> interrupt that is not a system call? > It is actual interrupts, but also faults, traps and all the other > exceptions not caused by "INT" I think. > Yes. It's interrupt, traps, faults. If from is in the user space and to is in the kernel, it indicates the ring3 -> ring0 transition. If the from instruction is not syscall or other ring transition instruction, it should be interrupt, traps and faults. That's how we get the PERF_BR_IRQ on x86. Anyway, maybe we just use a minimum but the most common set of branch types now, it could be a good start and acceptable on all architectures. 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 */ Thanks Jin Yao
[toc] | [prev] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2017-07-11 04:30 +0200 |
| Message-ID | <u1T61-4Qu-1@gated-at.bofh.it> |
| In reply to | #1684278 |
"Jin, Yao" <yao.jin@linux.intel.com> writes: > On 7/10/2017 9:46 PM, Peter Zijlstra wrote: >> On Mon, Jul 10, 2017 at 08:10:50AM -0500, Segher Boessenkool wrote: >> >>>> PERF_BR_INT is triggered by instruction "int" . >>>> PERF_BR_IRQ is triggered by interrupts, traps, faults (the ring 0,3 >>>> transition). >>> So your "PERF_BR_INT" is a system call? >> The "INT" thing has indeed been used as system call mechanism (typically >> INT 80). But these days we have special purpose syscall instructions. >> >> It could maybe be compared to the PPC "Unconditional TRAP with >> immediate" where you use the immediate value as an index into a handler >> vector. >> >>> And PERF_BR_IRQ is not an interrupt request (as its name suggests), >>> not what we call an "external interrupt" either; instead it is every >>> interrupt that is not a system call? >> It is actual interrupts, but also faults, traps and all the other >> exceptions not caused by "INT" I think. >> > Yes. It's interrupt, traps, faults. If from is in the user space and to > is in the kernel, it indicates the ring3 -> ring0 transition. > > If the from instruction is not syscall or other ring transition > instruction, it should be interrupt, traps and faults. That's how we get > the PERF_BR_IRQ on x86. > > Anyway, maybe we just use a minimum but the most common set of branch > types now, it could be a good start and acceptable on all architectures. > > 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 */ That would be fine by me, if you're sick of talking about it and just want to get it merged :) I think you could expand it a bit, this list would cover the vast bulk of branch types for us: PERF_BR_COND /* Conditional */ PERF_BR_UNCOND /* Unconditional */ PERF_BR_IND /* Indirect */ PERF_BR_CALL /* Function call */ PERF_BR_IND_CALL /* Indirect function call */ PERF_BR_RET /* Function return */ PERF_BR_SYSCALL /* Syscall */ PERF_BR_SYSRET /* Syscall return */ PERF_BR_COND_CALL /* Conditional function call */ PERF_BR_COND_RET /* Conditional function return */ cheers
[toc] | [prev] | [next] | [standalone]
| From | "Jin, Yao" <yao.jin@linux.intel.com> |
|---|---|
| Date | 2017-07-11 05:10 +0200 |
| Subject | Re: [PATCH v6 1/7] perf/core: Define the common branch type classification |
| Message-ID | <u1TIJ-5ip-1@gated-at.bofh.it> |
| In reply to | #1684748 |
On 7/11/2017 10:28 AM, Michael Ellerman wrote: > "Jin, Yao" <yao.jin@linux.intel.com> writes: > >> On 7/10/2017 9:46 PM, Peter Zijlstra wrote: >>> On Mon, Jul 10, 2017 at 08:10:50AM -0500, Segher Boessenkool wrote: >>> >>>>> PERF_BR_INT is triggered by instruction "int" . >>>>> PERF_BR_IRQ is triggered by interrupts, traps, faults (the ring 0,3 >>>>> transition). >>>> So your "PERF_BR_INT" is a system call? >>> The "INT" thing has indeed been used as system call mechanism (typically >>> INT 80). But these days we have special purpose syscall instructions. >>> >>> It could maybe be compared to the PPC "Unconditional TRAP with >>> immediate" where you use the immediate value as an index into a handler >>> vector. >>> >>>> And PERF_BR_IRQ is not an interrupt request (as its name suggests), >>>> not what we call an "external interrupt" either; instead it is every >>>> interrupt that is not a system call? >>> It is actual interrupts, but also faults, traps and all the other >>> exceptions not caused by "INT" I think. >>> >> Yes. It's interrupt, traps, faults. If from is in the user space and to >> is in the kernel, it indicates the ring3 -> ring0 transition. >> >> If the from instruction is not syscall or other ring transition >> instruction, it should be interrupt, traps and faults. That's how we get >> the PERF_BR_IRQ on x86. >> >> Anyway, maybe we just use a minimum but the most common set of branch >> types now, it could be a good start and acceptable on all architectures. >> >> 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 */ > That would be fine by me, if you're sick of talking about it and just > want to get it merged :) :) > > I think you could expand it a bit, this list would cover the vast bulk > of branch types for us: > > PERF_BR_COND /* Conditional */ > PERF_BR_UNCOND /* Unconditional */ > PERF_BR_IND /* Indirect */ > PERF_BR_CALL /* Function call */ > PERF_BR_IND_CALL /* Indirect function call */ > PERF_BR_RET /* Function return */ > PERF_BR_SYSCALL /* Syscall */ > PERF_BR_SYSRET /* Syscall return */ > PERF_BR_COND_CALL /* Conditional function call */ > PERF_BR_COND_RET /* Conditional function return */ > > cheers OK, accept! Use 4 bits for above branch types and we can reserve 5 for potential future types. Thanks Jin Yao
[toc] | [prev] | [next] | [standalone]
| From | Segher Boessenkool <segher@kernel.crashing.org> |
|---|---|
| Date | 2017-07-10 16:40 +0200 |
| Message-ID | <u1I0W-6aD-27@gated-at.bofh.it> |
| In reply to | #1684249 |
Hi Peter, On Mon, Jul 10, 2017 at 03:46:58PM +0200, Peter Zijlstra wrote: > On Mon, Jul 10, 2017 at 08:10:50AM -0500, Segher Boessenkool wrote: > > > > PERF_BR_INT is triggered by instruction "int" . > > > PERF_BR_IRQ is triggered by interrupts, traps, faults (the ring 0,3 > > > transition). > > > > So your "PERF_BR_INT" is a system call? > > The "INT" thing has indeed been used as system call mechanism (typically > INT 80). But these days we have special purpose syscall instructions. > > It could maybe be compared to the PPC "Unconditional TRAP with > immediate" where you use the immediate value as an index into a handler > vector. If we would do that, yes :-) (We just generate a SIGTRAP instead). > > And PERF_BR_IRQ is not an interrupt request (as its name suggests), > > not what we call an "external interrupt" either; instead it is every > > interrupt that is not a system call? > > It is actual interrupts, but also faults, traps and all the other > exceptions not caused by "INT" I think. Ah, right, exceptions == interrupts for PowerPC, more terminological confusion :-) Segher
[toc] | [prev] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2017-07-11 04:20 +0200 |
| Message-ID | <u1SWm-4Ny-5@gated-at.bofh.it> |
| In reply to | #1684224 |
Segher Boessenkool <segher@kernel.crashing.org> writes:
> Hi!
>
> On Mon, Jul 10, 2017 at 07:46:17PM +0800, Jin, Yao wrote:
>> 1. We all agree these definitions:
>>
>> + 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 */
>> + PERF_BR_SYSCALL = 7, /* syscall */
>> + PERF_BR_SYSRET = 8, /* syscall return */
>> + PERF_BR_IRET = 11, /* return from interrupt */
>
> Do we? It does not map very well to PowerPC branch types.
I think they map well enough to the types of branches that are actually
used in practice.
To represent the full range of possibilities we'd need to switch to a
bitmap of flags, ie. COND, IND, CALL, RET, SYSCALL, INT, etc. But it
would need more than 4 bits and I don't think there's that much added
value in being able to represent all the bizarre combinations.
But maybe that is the best option as it makes the API more flexible and
means we don't have to get the list of branches correct up front?
I ran some quick numbers on a kernel I had here (powernv w/gcc 7):
Type Percent
-----------------
cond 40.92% beq (79166) bne (57379) ble (10411) bgt (9587) blt (6248) bge (3704) bdnz (1251) bdz (353) bns (30) bdnzf (2) bdnzt (1)
uncond 14.89% b (61182)
indirect 0.10% bctr (418)
call 33.33% bl (136926)
ind call 1.44% bctrl (5912)
return 9.23% blr (37943)
= 99.91%
If we add cond call/return that covers another 0.08% taking us to 99.99%
of branches.
I know future compilers and or different code might use a different
distribution, but I doubt it will change all that much.
Maybe cond could be broken down further, but the only really meaningful
sub category I can think of is the decrementing type, and those are
quite rare.
cheers
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web