Messages in this thread Patch in this message | | | From | Namhyung Kim <> | Subject | [PATCH] perf: Change the layout of perf_sample_data | Date | Thu, 22 Sep 2022 13:55:50 -0700 |
| |
With recent change, it can set fields only if it's actually used. Change the data layout so that it can have commonly used fields together in a cache line boundary. The main user (the perf tools) sets the IP, TID, TIME, PERIOD always. Also group relevant fields like addr, phys_addr and data_page_size.
Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- include/linux/perf_event.h | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index e9b151cde491..8c16dae6e6bb 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1023,25 +1023,13 @@ extern u64 perf_event_read_value(struct perf_event *event, struct perf_sample_data { - /* - * Fields set by perf_sample_data_init(), group so as to - * minimize the cachelines touched. - */ u64 sample_flags; u64 period; - + u64 type; /* - * The other fields, optionally {set,used} by - * perf_{prepare,output}_sample(). + * Fields set commonly by perf tools, group so as to + * minimize the cachelines touched. */ - struct perf_branch_stack *br_stack; - union perf_sample_weight weight; - union perf_mem_data_src data_src; - u64 txn; - u64 addr; - struct perf_raw_record *raw; - - u64 type; u64 ip; struct { u32 pid; @@ -1049,22 +1037,33 @@ struct perf_sample_data { } tid_entry; u64 time; u64 id; - u64 stream_id; struct { u32 cpu; u32 reserved; } cpu_entry; + + /* + * The other fields, optionally {set,used} by + * perf_{prepare,output}_sample(). + */ struct perf_callchain_entry *callchain; - u64 aux_size; + struct perf_raw_record *raw; + struct perf_branch_stack *br_stack; + union perf_sample_weight weight; + union perf_mem_data_src data_src; + u64 txn; struct perf_regs regs_user; struct perf_regs regs_intr; u64 stack_user_size; - u64 phys_addr; + u64 stream_id; u64 cgroup; + u64 addr; + u64 phys_addr; u64 data_page_size; u64 code_page_size; + u64 aux_size; } ____cacheline_aligned; /* default value for data source */ -- 2.37.3.998.g577e59143f-goog
| |