[perf/core: Update sample_flags for raw_data in perf_output_sample
PATCH 1/1 [perf/core: Update sample_flags for raw_data in perf_output_sample
commit 838d9bb62d13 ("perf: Use sample_flags for raw_data") added check for PERF_SAMPLE_RAW in sample_flags in perf_prepare_sample(). But while copying the sample in memory, the check for sample_flags is not added in perf_output_sample(). Fix adds the same in perf_output_sample as well.
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -7099,7 +7099,7 @@ void perf_output_sample(struct perf_output_handle *handle,if (sample_type &PERF_SAMPLE_RAW ) {struct perf_raw_record *raw = data->raw; -if (raw) { +if (raw && (data->sample_flags &PERF_SAMPLE_RAW )) {struct perf_raw_frag *frag = &raw->frag;perf_output_put (handle, raw->size);
Signature · 1 line
2.31.1
PATCH 1/1 [perf/core: Update sample_flags for raw_data in perf_output_sample
commit 838d9bb62d13 ("perf: Use sample_flags for raw_data") added check for PERF_SAMPLE_RAW in sample_flags in perf_prepare_sample(). But while copying the sample in memory, the check for sample_flags is not added in perf_output_sample(). Fix adds the same in perf_output_sample as well.
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -7099,7 +7099,7 @@ void perf_output_sample(struct perf_output_handle *handle,if (sample_type &PERF_SAMPLE_RAW ) {struct perf_raw_record *raw = data->raw; -if (raw) { +if (raw && (data->sample_flags &PERF_SAMPLE_RAW )) {struct perf_raw_frag *frag = &raw->frag;perf_output_put (handle, raw->size);
Signature · 1 line
2.31.1
Peter Zijlstra
maintainerQuoted 17 lines · Athira Rajeev
commit
838d9bb62d13("perf: Usesample_flagsforraw_data") added check forPERF_SAMPLE_RAWinsample_flagsinperf_prepare_sample(). But while copying the sample in memory, the check forsample_flagsis not added inperf_output_sample(). Fix adds the same inperf_output_sampleas well.Fixes 838d9bb62d13 ("perf: Use sample_flags for raw_data")Signed-off-by Athira Rajeev <[email protected]>--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/events/core.c +0
-0
kernel/events/core.c void perf_output_sample(struct perf_output_handle *handle, · line 7105
Quoted 8 lines
kernel/events/core.c +1
-1@@ -7099,7 +7099,7 @@ void perf_output_sample(struct perf_output_handle *handle,if (sample_type &PERF_SAMPLE_RAW ) {struct perf_raw_record *raw = data->raw; -if (raw) { +if (raw && (data->sample_flags &PERF_SAMPLE_RAW )) {struct perf_raw_frag *frag = &raw->frag;perf_output_put (handle, raw->size);
Urgh.. something smells here. We already did a PERF_SAMPLE_RAW test.
And perf_prepare_sample() explicitly makes data->raw be NULL when not set earlier.
So what's going wrong?
Quoted 29 lines · Peter Zijlstra
Quoted 24 lines · Athira Rajeev
commit
838d9bb62d13("perf: Usesample_flagsforraw_data") added check forPERF_SAMPLE_RAWinsample_flagsinperf_prepare_sample(). But while copying the sample in memory, the check forsample_flagsis not added inperf_output_sample(). Fix adds the same inperf_output_sampleas well.Fixes 838d9bb62d13 ("perf: Use sample_flags for raw_data")Signed-off-by Athira Rajeev <[email protected]>---
kernel/events/core.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/events/core.c +1
-1@@ -7099,7 +7099,7 @@ void perf_output_sample(struct perf_output_handle *handle,if (sample_type &PERF_SAMPLE_RAW ) {struct perf_raw_record *raw = data->raw; -if (raw) { +if (raw && (data->sample_flags &PERF_SAMPLE_RAW )) {struct perf_raw_frag *frag = &raw->frag;
Quoted 8 lines
kernel/events/core.c void perf_output_sample(struct perf_output_handle *handle, · line 7105
Quoted 1 line
kernel/events/core.c +0
-0perf_output_put (handle, raw->size);Urgh.. something smells here. We already did a
PERF_SAMPLE_RAWtest.And
perf_prepare_sample()explicitly makesdata->rawbe NULL when not set earlier.So what's going wrong?
Hi Peter,
Sorry for late response. I was out on vacation couple of days.
I didn't hit any specific issue or fail with current code. But patch intention was to keep the perf_prepare_sample and perf_output_sample to be in sync with the checks that we are doing.
Thanks
Athira