Skip to content

Commit 7b08463

Browse files
namhyungPeter Zijlstra
authored andcommitted
perf: Use sample_flags for addr
Use the new sample_flags to indicate whether the addr field is filled by the PMU driver. As most PMU drivers pass 0, it can set the flag only if it has a non-zero value. And use 0 in perf_sample_output() if it's not filled already. Signed-off-by: Namhyung Kim <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent dca6344 commit 7b08463

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

arch/x86/events/intel/ds.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,8 +1621,10 @@ static void setup_pebs_fixed_sample_data(struct perf_event *event,
16211621

16221622

16231623
if ((sample_type & PERF_SAMPLE_ADDR_TYPE) &&
1624-
x86_pmu.intel_cap.pebs_format >= 1)
1624+
x86_pmu.intel_cap.pebs_format >= 1) {
16251625
data->addr = pebs->dla;
1626+
data->sample_flags |= PERF_SAMPLE_ADDR;
1627+
}
16261628

16271629
if (x86_pmu.intel_cap.pebs_format >= 2) {
16281630
/* Only set the TSX weight when no memory weight. */
@@ -1783,8 +1785,10 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,
17831785
data->sample_flags |= PERF_SAMPLE_DATA_SRC;
17841786
}
17851787

1786-
if (sample_type & PERF_SAMPLE_ADDR_TYPE)
1788+
if (sample_type & PERF_SAMPLE_ADDR_TYPE) {
17871789
data->addr = meminfo->address;
1790+
data->sample_flags |= PERF_SAMPLE_ADDR;
1791+
}
17881792

17891793
if (sample_type & PERF_SAMPLE_TRANSACTION) {
17901794
data->txn = intel_get_tsx_transaction(meminfo->tsx_tuning,

include/linux/perf_event.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,6 @@ struct perf_sample_data {
10281028
* minimize the cachelines touched.
10291029
*/
10301030
u64 sample_flags;
1031-
u64 addr;
10321031
struct perf_raw_record *raw;
10331032
u64 period;
10341033

@@ -1040,6 +1039,7 @@ struct perf_sample_data {
10401039
union perf_sample_weight weight;
10411040
union perf_mem_data_src data_src;
10421041
u64 txn;
1042+
u64 addr;
10431043

10441044
u64 type;
10451045
u64 ip;
@@ -1079,9 +1079,13 @@ static inline void perf_sample_data_init(struct perf_sample_data *data,
10791079
{
10801080
/* remaining struct members initialized in perf_prepare_sample() */
10811081
data->sample_flags = 0;
1082-
data->addr = addr;
10831082
data->raw = NULL;
10841083
data->period = period;
1084+
1085+
if (addr) {
1086+
data->addr = addr;
1087+
data->sample_flags |= PERF_SAMPLE_ADDR;
1088+
}
10851089
}
10861090

10871091
/*

kernel/events/core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7414,6 +7414,11 @@ void perf_prepare_sample(struct perf_event_header *header,
74147414
if (filtered_sample_type & PERF_SAMPLE_TRANSACTION)
74157415
data->txn = 0;
74167416

7417+
if (sample_type & (PERF_SAMPLE_ADDR | PERF_SAMPLE_PHYS_ADDR | PERF_SAMPLE_DATA_PAGE_SIZE)) {
7418+
if (filtered_sample_type & PERF_SAMPLE_ADDR)
7419+
data->addr = 0;
7420+
}
7421+
74177422
if (sample_type & PERF_SAMPLE_REGS_INTR) {
74187423
/* regs dump ABI info */
74197424
int size = sizeof(u64);

0 commit comments

Comments
 (0)