Re: [PATCH v2] perf tools: Avoid unaligned pointer operations

From: Ian Rogers
Date: Fri Dec 13 2024 - 15:58:21 EST


On Thu, Nov 28, 2024 at 6:59 AM Liang, Kan <kan.liang@xxxxxxxxxxxxxxx> wrote:
>
> On 2024-11-27 8:03 p.m., Namhyung Kim wrote:
> > The sample data is 64-bit aligned basically but raw data starts with
> > 32-bit length field and data follows. In perf_event__synthesize_sample
> > it treats the sample data as a 64-bit array. And it needs some trick
> > to update the raw data properly.
> >
> > But it seems some compilers are not happy with this and the program dies
> > siliently. I found the sample parsing test failed without any messages
> > on affected systems.
> >
> > Let's update the code to use a 32-bit pointer directly and make sure the
> > result is 64-bit aligned again. No functional changes intended.
> >
> > Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>
> > Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
>
> Reviewed-by: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>

nit: The commit message subject is somewhat generic. Perhaps "perf
synthetic-events: Avoid unaligned accesses for raw samples".

Thanks,
Ian