Re: [PATCH v2 5/5] perf: Record sample last_period before updating
From: Leo Yan
Date: Tue Jan 21 2025 - 12:22:30 EST
On Mon, Jan 06, 2025 at 12:01:56PM +0000, mark.barnett@xxxxxxx wrote:
> From: Mark Barnett <mark.barnett@xxxxxxx>
>
> This change alters the PowerPC and x86 driver implementations to record
> the last sample period before the event is updated for the next period.
>
> A common pattern in PMU driver implementations is to have a
> "*_event_set_period" function which takes care of updating the various
> period-related fields in a perf_event structure. In most cases, the
> drivers choose to call this function after initializing a sample data
> structure with perf_sample_data_init. The x86 and PowerPC drivers
> deviate from this, choosing to update the period before initializing the
> sample data. When using an event with an alternate sample period, this
> causes an incorrect period to be written to the sample data that gets
> reported to userspace.
I found conflict when I applied this patch on linux-next [1], with the
commit below:
commit faac6f105ef169e2e5678c14e1ffebf2a7d780b6
Author: Yabin Cui <yabinc@xxxxxxxxxx>
Date: Wed May 15 12:36:09 2024 -0700
perf/core: Check sample_type in perf_sample_save_brstack
Check sample_type in perf_sample_save_brstack() to prevent
saving branch stack data when it isn't required.
Suggested-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Signed-off-by: Yabin Cui <yabinc@xxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>
Acked-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Link: https://lore.kernel.org/r/20240515193610.2350456-4-yabinc@xxxxxxxxxx
Please consider to rebase the patch to fix conflict in next spin.
Thanks,
Leo
[1] git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git