Skip to content

Commit e16fd7f

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf: Use sample_flags for data_src
Use the new sample_flags to indicate whether the data_src field is filled by the PMU driver. Remove the data_src field from the perf_sample_data_init() to minimize the number of cache lines touched. Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20220901130959.1285717-6-kan.liang@linux.intel.com
1 parent 2abe681 commit e16fd7f

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

arch/powerpc/perf/core-book3s.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2301,8 +2301,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
23012301
}
23022302

23032303
if (event->attr.sample_type & PERF_SAMPLE_DATA_SRC &&
2304-
ppmu->get_mem_data_src)
2304+
ppmu->get_mem_data_src) {
23052305
ppmu->get_mem_data_src(&data.data_src, ppmu->flags, regs);
2306+
data.sample_flags |= PERF_SAMPLE_DATA_SRC;
2307+
}
23062308

23072309
if (event->attr.sample_type & PERF_SAMPLE_WEIGHT_TYPE &&
23082310
ppmu->get_mem_weight) {

arch/x86/events/intel/ds.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,8 +1535,10 @@ static void setup_pebs_fixed_sample_data(struct perf_event *event,
15351535
/*
15361536
* data.data_src encodes the data source
15371537
*/
1538-
if (sample_type & PERF_SAMPLE_DATA_SRC)
1538+
if (sample_type & PERF_SAMPLE_DATA_SRC) {
15391539
data->data_src.val = get_data_src(event, pebs->dse);
1540+
data->sample_flags |= PERF_SAMPLE_DATA_SRC;
1541+
}
15401542

15411543
/*
15421544
* We must however always use iregs for the unwinder to stay sane; the
@@ -1770,8 +1772,10 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,
17701772
data->sample_flags |= PERF_SAMPLE_WEIGHT_TYPE;
17711773
}
17721774

1773-
if (sample_type & PERF_SAMPLE_DATA_SRC)
1775+
if (sample_type & PERF_SAMPLE_DATA_SRC) {
17741776
data->data_src.val = get_data_src(event, meminfo->aux);
1777+
data->sample_flags |= PERF_SAMPLE_DATA_SRC;
1778+
}
17751779

17761780
if (sample_type & PERF_SAMPLE_ADDR_TYPE)
17771781
data->addr = meminfo->address;

include/linux/perf_event.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,14 +1013,14 @@ struct perf_sample_data {
10131013
struct perf_raw_record *raw;
10141014
u64 period;
10151015
u64 txn;
1016-
union perf_mem_data_src data_src;
10171016

10181017
/*
10191018
* The other fields, optionally {set,used} by
10201019
* perf_{prepare,output}_sample().
10211020
*/
10221021
struct perf_branch_stack *br_stack;
10231022
union perf_sample_weight weight;
1023+
union perf_mem_data_src data_src;
10241024

10251025
u64 type;
10261026
u64 ip;
@@ -1063,7 +1063,6 @@ static inline void perf_sample_data_init(struct perf_sample_data *data,
10631063
data->addr = addr;
10641064
data->raw = NULL;
10651065
data->period = period;
1066-
data->data_src.val = PERF_MEM_NA;
10671066
data->txn = 0;
10681067
}
10691068

kernel/events/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7411,6 +7411,9 @@ void perf_prepare_sample(struct perf_event_header *header,
74117411
if (filtered_sample_type & PERF_SAMPLE_WEIGHT_TYPE)
74127412
data->weight.full = 0;
74137413

7414+
if (filtered_sample_type & PERF_SAMPLE_DATA_SRC)
7415+
data->data_src.val = PERF_MEM_NA;
7416+
74147417
if (sample_type & PERF_SAMPLE_REGS_INTR) {
74157418
/* regs dump ABI info */
74167419
int size = sizeof(u64);

0 commit comments

Comments
 (0)