Skip to content

Commit 477f00f

Browse files
Kan LiangIngo Molnar
authored andcommitted
perf/x86/intel/ds: Extract code of event update in short period
The drain_pebs() could be called twice in a short period for auto-reload event in pmu::read(). The intel_pmu_save_and_restart_reload() should be called to update the event->count. This case should also be handled on Icelake. Extract the code for later reuse. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 48f38aa commit 477f00f

File tree

1 file changed

+20
-13
lines changed
  • arch/x86/events/intel

1 file changed

+20
-13
lines changed

arch/x86/events/intel/ds.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,25 @@ static void intel_pmu_drain_pebs_core(struct pt_regs *iregs)
14911491
__intel_pmu_pebs_event(event, iregs, at, top, 0, n);
14921492
}
14931493

1494+
static void intel_pmu_pebs_event_update_no_drain(struct cpu_hw_events *cpuc, int size)
1495+
{
1496+
struct perf_event *event;
1497+
int bit;
1498+
1499+
/*
1500+
* The drain_pebs() could be called twice in a short period
1501+
* for auto-reload event in pmu::read(). There are no
1502+
* overflows have happened in between.
1503+
* It needs to call intel_pmu_save_and_restart_reload() to
1504+
* update the event->count for this case.
1505+
*/
1506+
for_each_set_bit(bit, (unsigned long *)&cpuc->pebs_enabled, size) {
1507+
event = cpuc->events[bit];
1508+
if (event->hw.flags & PERF_X86_EVENT_AUTO_RELOAD)
1509+
intel_pmu_save_and_restart_reload(event, 0);
1510+
}
1511+
}
1512+
14941513
static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
14951514
{
14961515
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
@@ -1518,19 +1537,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
15181537
}
15191538

15201539
if (unlikely(base >= top)) {
1521-
/*
1522-
* The drain_pebs() could be called twice in a short period
1523-
* for auto-reload event in pmu::read(). There are no
1524-
* overflows have happened in between.
1525-
* It needs to call intel_pmu_save_and_restart_reload() to
1526-
* update the event->count for this case.
1527-
*/
1528-
for_each_set_bit(bit, (unsigned long *)&cpuc->pebs_enabled,
1529-
size) {
1530-
event = cpuc->events[bit];
1531-
if (event->hw.flags & PERF_X86_EVENT_AUTO_RELOAD)
1532-
intel_pmu_save_and_restart_reload(event, 0);
1533-
}
1540+
intel_pmu_pebs_event_update_no_drain(cpuc, size);
15341541
return;
15351542
}
15361543

0 commit comments

Comments
 (0)