Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1684820 > unrolled thread
| Started by | Jin Yao <yao.jin@linux.intel.com> |
|---|---|
| First post | 2017-07-11 09:10 +0200 |
| Last post | 2017-07-12 12:50 +0200 |
| Articles | 4 — 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.
[PATCH v7 1/7] perf/core: Define the common branch type classification Jin Yao <yao.jin@linux.intel.com> - 2017-07-11 09:10 +0200
Re: [PATCH v7 1/7] perf/core: Define the common branch type classification Peter Zijlstra <peterz@infradead.org> - 2017-07-11 14:10 +0200
Re: [PATCH v7 1/7] perf/core: Define the common branch type classification "Jin, Yao" <yao.jin@linux.intel.com> - 2017-07-11 14:30 +0200
Re: [PATCH v7 1/7] perf/core: Define the common branch type classification Michael Ellerman <mpe@ellerman.id.au> - 2017-07-12 12:50 +0200
| From | Jin Yao <yao.jin@linux.intel.com> |
|---|---|
| Date | 2017-07-11 09:10 +0200 |
| Subject | [PATCH v7 1/7] perf/core: Define the common branch type classification |
| Message-ID | <u1XsZ-7CX-11@gated-at.bofh.it> |
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.
The patch only defines a minimum but most common set of branch types.
PERF_BR_NONE : unknown
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
The patch also adds a new field type (4 bits) in perf_branch_entry
to record the branch type (reserve 5 for future branch types)
Since the disassembling of branch instruction needs some overhead,
a new PERF_SAMPLE_BRANCH_TYPE_SAVE is introduced to indicate if it
needs to disassemble the branch instruction and record the branch
type.
Change log
----------
v7: Just keep the most common branch types.
Others are removed.
v6: Not changed.
v5: Not changed. The v5 patch series just change the userspace.
v4: Comparing to previous version, the major changes are:
1. Remove the PERF_BR_JCC_FWD/PERF_BR_JCC_BWD, they will be
computed later in userspace.
2. Remove the "cross" field in perf_branch_entry. The cross page
computing will be done later in userspace.
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
include/uapi/linux/perf_event.h | 27 ++++++++++++++++++++++++++-
tools/include/uapi/linux/perf_event.h | 27 ++++++++++++++++++++++++++-
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index b1c0b18..fcfb98c 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -174,6 +174,8 @@ enum perf_branch_sample_type_shift {
PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT = 14, /* no flags */
PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT = 15, /* no cycles */
+ PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT = 16, /* save branch type */
+
PERF_SAMPLE_BRANCH_MAX_SHIFT /* non-ABI */
};
@@ -198,9 +200,30 @@ enum perf_branch_sample_type {
PERF_SAMPLE_BRANCH_NO_FLAGS = 1U << PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT,
PERF_SAMPLE_BRANCH_NO_CYCLES = 1U << PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT,
+ PERF_SAMPLE_BRANCH_TYPE_SAVE =
+ 1U << PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT,
+
PERF_SAMPLE_BRANCH_MAX = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
};
+/*
+ * Common flow change classification
+ */
+enum {
+ PERF_BR_NONE = 0, /* unknown */
+ PERF_BR_COND = 1, /* conditional */
+ PERF_BR_UNCOND = 2, /* unconditional */
+ PERF_BR_IND = 3, /* indirect */
+ PERF_BR_CALL = 4, /* function call */
+ PERF_BR_IND_CALL = 5, /* indirect function call */
+ PERF_BR_RET = 6, /* function return */
+ PERF_BR_SYSCALL = 7, /* syscall */
+ PERF_BR_SYSRET = 8, /* syscall return */
+ PERF_BR_COND_CALL = 9, /* conditional function call */
+ PERF_BR_COND_RET = 10, /* conditional function return */
+ PERF_BR_MAX,
+};
+
#define PERF_SAMPLE_BRANCH_PLM_ALL \
(PERF_SAMPLE_BRANCH_USER|\
PERF_SAMPLE_BRANCH_KERNEL|\
@@ -1015,6 +1038,7 @@ union perf_mem_data_src {
* in_tx: running in a hardware transaction
* abort: aborting a hardware transaction
* cycles: cycles from last branch (or 0 if not supported)
+ * type: branch type
*/
struct perf_branch_entry {
__u64 from;
@@ -1024,7 +1048,8 @@ struct perf_branch_entry {
in_tx:1, /* in transaction */
abort:1, /* transaction abort */
cycles:16, /* cycle count to last branch */
- reserved:44;
+ type:4, /* branch type */
+ reserved:40;
};
#endif /* _UAPI_LINUX_PERF_EVENT_H */
diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index b1c0b18..fcfb98c 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -174,6 +174,8 @@ enum perf_branch_sample_type_shift {
PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT = 14, /* no flags */
PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT = 15, /* no cycles */
+ PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT = 16, /* save branch type */
+
PERF_SAMPLE_BRANCH_MAX_SHIFT /* non-ABI */
};
@@ -198,9 +200,30 @@ enum perf_branch_sample_type {
PERF_SAMPLE_BRANCH_NO_FLAGS = 1U << PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT,
PERF_SAMPLE_BRANCH_NO_CYCLES = 1U << PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT,
+ PERF_SAMPLE_BRANCH_TYPE_SAVE =
+ 1U << PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT,
+
PERF_SAMPLE_BRANCH_MAX = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
};
+/*
+ * Common flow change classification
+ */
+enum {
+ PERF_BR_NONE = 0, /* unknown */
+ PERF_BR_COND = 1, /* conditional */
+ PERF_BR_UNCOND = 2, /* unconditional */
+ PERF_BR_IND = 3, /* indirect */
+ PERF_BR_CALL = 4, /* function call */
+ PERF_BR_IND_CALL = 5, /* indirect function call */
+ PERF_BR_RET = 6, /* function return */
+ PERF_BR_SYSCALL = 7, /* syscall */
+ PERF_BR_SYSRET = 8, /* syscall return */
+ PERF_BR_COND_CALL = 9, /* conditional function call */
+ PERF_BR_COND_RET = 10, /* conditional function return */
+ PERF_BR_MAX,
+};
+
#define PERF_SAMPLE_BRANCH_PLM_ALL \
(PERF_SAMPLE_BRANCH_USER|\
PERF_SAMPLE_BRANCH_KERNEL|\
@@ -1015,6 +1038,7 @@ union perf_mem_data_src {
* in_tx: running in a hardware transaction
* abort: aborting a hardware transaction
* cycles: cycles from last branch (or 0 if not supported)
+ * type: branch type
*/
struct perf_branch_entry {
__u64 from;
@@ -1024,7 +1048,8 @@ struct perf_branch_entry {
in_tx:1, /* in transaction */
abort:1, /* transaction abort */
cycles:16, /* cycle count to last branch */
- reserved:44;
+ type:4, /* branch type */
+ reserved:40;
};
#endif /* _UAPI_LINUX_PERF_EVENT_H */
--
2.7.4
[toc] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2017-07-11 14:10 +0200 |
| Subject | Re: [PATCH v7 1/7] perf/core: Define the common branch type classification |
| Message-ID | <u229k-26d-13@gated-at.bofh.it> |
| In reply to | #1684820 |
On Tue, Jul 11, 2017 at 11:00:57PM +0800, Jin Yao wrote:
> PERF_BR_NONE : unknown
I would suggest PERF_BR_UNKNOWN or PERF_BR_MISC, since PERF_BR_NONE
reads like it wasn't a branch at all.
> 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
>
> The patch also adds a new field type (4 bits) in perf_branch_entry
> to record the branch type (reserve 5 for future branch types)
What's up with that 5 ? I can't see anything like that in the patch
itself:
> @@ -1024,7 +1048,8 @@ struct perf_branch_entry {
> in_tx:1, /* in transaction */
> abort:1, /* transaction abort */
> cycles:16, /* cycle count to last branch */
> - reserved:44;
> + type:4, /* branch type */
> + reserved:40;
> };
[toc] | [prev] | [next] | [standalone]
| From | "Jin, Yao" <yao.jin@linux.intel.com> |
|---|---|
| Date | 2017-07-11 14:30 +0200 |
| Subject | Re: [PATCH v7 1/7] perf/core: Define the common branch type classification |
| Message-ID | <u22sF-2cL-3@gated-at.bofh.it> |
| In reply to | #1684996 |
On 7/11/2017 8:06 PM, Peter Zijlstra wrote:
> On Tue, Jul 11, 2017 at 11:00:57PM +0800, Jin Yao wrote:
>> PERF_BR_NONE : unknown
> I would suggest PERF_BR_UNKNOWN or PERF_BR_MISC, since PERF_BR_NONE
> reads like it wasn't a branch at all.
OK, I will change it to PERF_BR_UNKNOWN.
>> 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
>>
>> The patch also adds a new field type (4 bits) in perf_branch_entry
>> to record the branch type (reserve 5 for future branch types)
> What's up with that 5 ? I can't see anything like that in the patch
> itself:
Sorry, I don't say this clearly.
We has defined 11 branch types (from PERF_BR_UNKNOWN to
PERF_BR_COND_RET), so we can define 5 new types in future.
Thanks
Jin Yao
>> @@ -1024,7 +1048,8 @@ struct perf_branch_entry {
>> in_tx:1, /* in transaction */
>> abort:1, /* transaction abort */
>> cycles:16, /* cycle count to last branch */
>> - reserved:44;
>> + type:4, /* branch type */
>> + reserved:40;
>> };
>
[toc] | [prev] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2017-07-12 12:50 +0200 |
| Message-ID | <u2nnr-76E-3@gated-at.bofh.it> |
| In reply to | #1684820 |
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. > > The patch only defines a minimum but most common set of branch types. > > PERF_BR_NONE : unknown > 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 This series looks good to me, I agree with Peter that UNKNOWN would be better than NONE. I'll add it to my list of things we need to implement on powerpc. cheers
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web