[PATCH] perf powerpc-vpadtl: Fix raw_size of DTL samples

Wang Yan posted 1 patch 1 month ago
tools/perf/util/powerpc-vpadtl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] perf powerpc-vpadtl: Fix raw_size of DTL samples
Posted by Wang Yan 1 month ago
In powerpc_vpadtl_sample(), raw_data of the synthetic sample points to a
struct powerpc_vpadtl_entry (48 bytes), but raw_size is set to
sizeof(record).  record is a struct powerpc_vpadtl_entry pointer, so
sizeof(record) is the size of the pointer (8 bytes on 64-bit) rather
than the size of the record itself.

As a result, consumers that bound their access to raw_data by raw_size
only see or copy the first 8 bytes of each DTL entry instead of the full
record.

Use sizeof(*record) so that raw_size reflects the actual length of the
raw data.

Fixes: 8644834a482a ("perf powerpc: Process the DTL entries in queue and deliver samples")
Signed-off-by: Wang Yan <wangyan01@kylinos.cn>
---
 tools/perf/util/powerpc-vpadtl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/powerpc-vpadtl.c b/tools/perf/util/powerpc-vpadtl.c
index 710f3093f3f9..af6783cfdb53 100644
--- a/tools/perf/util/powerpc-vpadtl.c
+++ b/tools/perf/util/powerpc-vpadtl.c
@@ -196,7 +196,7 @@ static int powerpc_vpadtl_sample(struct powerpc_vpadtl_entry *record,
 	sample.cpumode = PERF_RECORD_MISC_KERNEL;
 	sample.time = save;
 	sample.raw_data = record;
-	sample.raw_size = sizeof(record);
+	sample.raw_size = sizeof(*record);
 	event.sample.header.type = PERF_RECORD_SAMPLE;
 	event.sample.header.misc = sample.cpumode;
 	event.sample.header.size = sizeof(struct perf_event_header);
-- 
2.25.1
Re: [PATCH] perf powerpc-vpadtl: Fix raw_size of DTL samples
Posted by Namhyung Kim 3 weeks, 6 days ago
On Tue, 25 Aug 2026 17:47:33 +0800, Wang Yan wrote:
> In powerpc_vpadtl_sample(), raw_data of the synthetic sample points to a
> struct powerpc_vpadtl_entry (48 bytes), but raw_size is set to
> sizeof(record).  record is a struct powerpc_vpadtl_entry pointer, so
> sizeof(record) is the size of the pointer (8 bytes on 64-bit) rather
> than the size of the record itself.
> 
> As a result, consumers that bound their access to raw_data by raw_size
> only see or copy the first 8 bytes of each DTL entry instead of the full
> record.
> 
> [...]
Applied to perf-tools, thanks!

Best regards,
Namhyung
Re: [PATCH] perf powerpc-vpadtl: Fix raw_size of DTL samples
Posted by Athira Rajeev 1 month ago

> On 25 Aug 2026, at 3:17 PM, Wang Yan <wangyan01@kylinos.cn> wrote:
> 
> In powerpc_vpadtl_sample(), raw_data of the synthetic sample points to a
> struct powerpc_vpadtl_entry (48 bytes), but raw_size is set to
> sizeof(record).  record is a struct powerpc_vpadtl_entry pointer, so
> sizeof(record) is the size of the pointer (8 bytes on 64-bit) rather
> than the size of the record itself.
> 
> As a result, consumers that bound their access to raw_data by raw_size
> only see or copy the first 8 bytes of each DTL entry instead of the full
> record.
> 
> Use sizeof(*record) so that raw_size reflects the actual length of the
> raw data.
> 
> Fixes: 8644834a482a ("perf powerpc: Process the DTL entries in queue and deliver samples")
> Signed-off-by: Wang Yan <wangyan01@kylinos.cn>
Reviewed-by: Athira Rajeev <atrajeev@linux.ibm.com>

Thanks
Athira
> ---
> tools/perf/util/powerpc-vpadtl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/powerpc-vpadtl.c b/tools/perf/util/powerpc-vpadtl.c
> index 710f3093f3f9..af6783cfdb53 100644
> --- a/tools/perf/util/powerpc-vpadtl.c
> +++ b/tools/perf/util/powerpc-vpadtl.c
> @@ -196,7 +196,7 @@ static int powerpc_vpadtl_sample(struct powerpc_vpadtl_entry *record,
> sample.cpumode = PERF_RECORD_MISC_KERNEL;
> sample.time = save;
> sample.raw_data = record;
> - sample.raw_size = sizeof(record);
> + sample.raw_size = sizeof(*record);
> event.sample.header.type = PERF_RECORD_SAMPLE;
> event.sample.header.misc = sample.cpumode;
> event.sample.header.size = sizeof(struct perf_event_header);
> -- 
> 2.25.1
> 
Re: [PATCH] perf powerpc-vpadtl: Fix raw_size of DTL samples
Posted by Arnaldo Carvalho de Melo 4 weeks ago
On Fri, Aug 28, 2026 at 05:29:00PM +0530, Athira Rajeev wrote:
> > On 25 Aug 2026, at 3:17 PM, Wang Yan <wangyan01@kylinos.cn> wrote:
> > 
> > In powerpc_vpadtl_sample(), raw_data of the synthetic sample points to a
> > struct powerpc_vpadtl_entry (48 bytes), but raw_size is set to
> > sizeof(record).  record is a struct powerpc_vpadtl_entry pointer, so
> > sizeof(record) is the size of the pointer (8 bytes on 64-bit) rather
> > than the size of the record itself.
> > 
> > As a result, consumers that bound their access to raw_data by raw_size
> > only see or copy the first 8 bytes of each DTL entry instead of the full
> > record.
> > 
> > Use sizeof(*record) so that raw_size reflects the actual length of the
> > raw data.
> > 
> > Fixes: 8644834a482a ("perf powerpc: Process the DTL entries in queue and deliver samples")
> > Signed-off-by: Wang Yan <wangyan01@kylinos.cn>

> Reviewed-by: Athira Rajeev <atrajeev@linux.ibm.com>

Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Namhyung, I think this is v7.3 material.

- Arnaldo