Skip to content

Commit ceaeaf6

Browse files
committed
Merge tag 'perf-urgent-2026-01-24' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf events fixes from Ingo Molnar: - Fix mmap_count warning & bug when creating a group member event with the PERF_FLAG_FD_OUTPUT flag - Disable the sample period == 1 branch events BTS optimization on guests, because BTS is not virtualized * tag 'perf-urgent-2026-01-24' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/intel: Do not enable BTS for guests perf: Fix refcount warning on event->mmap_count increment
2 parents dc67a35 + 91dcfae commit ceaeaf6

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

arch/x86/events/perf_event.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,13 +1574,22 @@ static inline bool intel_pmu_has_bts_period(struct perf_event *event, u64 period
15741574
struct hw_perf_event *hwc = &event->hw;
15751575
unsigned int hw_event, bts_event;
15761576

1577-
if (event->attr.freq)
1577+
/*
1578+
* Only use BTS for fixed rate period==1 events.
1579+
*/
1580+
if (event->attr.freq || period != 1)
1581+
return false;
1582+
1583+
/*
1584+
* BTS doesn't virtualize.
1585+
*/
1586+
if (event->attr.exclude_host)
15781587
return false;
15791588

15801589
hw_event = hwc->config & INTEL_ARCH_EVENT_MASK;
15811590
bts_event = x86_pmu.event_map(PERF_COUNT_HW_BRANCH_INSTRUCTIONS);
15821591

1583-
return hw_event == bts_event && period == 1;
1592+
return hw_event == bts_event;
15841593
}
15851594

15861595
static inline bool intel_pmu_has_bts(struct perf_event *event)

kernel/events/core.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6997,6 +6997,15 @@ static int perf_mmap_rb(struct vm_area_struct *vma, struct perf_event *event,
69976997
if (data_page_nr(event->rb) != nr_pages)
69986998
return -EINVAL;
69996999

7000+
/*
7001+
* If this event doesn't have mmap_count, we're attempting to
7002+
* create an alias of another event's mmap(); this would mean
7003+
* both events will end up scribbling the same user_page;
7004+
* which makes no sense.
7005+
*/
7006+
if (!refcount_read(&event->mmap_count))
7007+
return -EBUSY;
7008+
70007009
if (refcount_inc_not_zero(&event->rb->mmap_count)) {
70017010
/*
70027011
* Success -- managed to mmap() the same buffer

0 commit comments

Comments
 (0)