]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
perf: Avoid the read if the count is already updated
authorPeter Zijlstra (Intel) <peterz@infradead.org>
Tue, 21 Jan 2025 15:23:02 +0000 (07:23 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jun 2025 12:40:16 +0000 (14:40 +0200)
commite1c3bfe365f10c3c5cfa53e16ad60201879f74f4
tree18f5f2928a6809d1a2a9e8bf838bcf2f709665c0
parent84916c757cb40b6c940961903144017977d88524
perf: Avoid the read if the count is already updated

[ Upstream commit 8ce939a0fa194939cc1f92dbd8bc1a7806e7d40a ]

The event may have been updated in the PMU-specific implementation,
e.g., Intel PEBS counters snapshotting. The common code should not
read and overwrite the value.

The PERF_SAMPLE_READ in the data->sample_type can be used to detect
whether the PMU-specific value is available. If yes, avoid the
pmu->read() in the common code. Add a new flag, skip_read, to track the
case.

Factor out a perf_pmu_read() to clean up the code.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250121152303.3128733-3-kan.liang@linux.intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/perf_event.h
kernel/events/core.c
kernel/events/ring_buffer.c