Skip to content

Commit 05c9b0c

Browse files
sandip4nIngo Molnar
authored andcommitted
perf/x86/intel/uncore: Use HRTIMER_MODE_HARD for detecting overflows
hrtimer handlers can be deferred to softirq context and affect timely detection of counter overflows. Hence switch to HRTIMER_MODE_HARD. Disabling and re-enabling IRQs in the hrtimer handler is not required as pmu->start() and pmu->stop() can no longer intervene while updating event->hw.prev_count. Suggested-by: Peter Zijlstra <[email protected]> Signed-off-by: Sandipan Das <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/0ad4698465077225769e8edd5b2c7e8f48f636d5.1744906694.git.sandipan.das@amd.com
1 parent 4f81cc2 commit 05c9b0c

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

arch/x86/events/intel/uncore.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,11 @@ static enum hrtimer_restart uncore_pmu_hrtimer(struct hrtimer *hrtimer)
305305
{
306306
struct intel_uncore_box *box;
307307
struct perf_event *event;
308-
unsigned long flags;
309308
int bit;
310309

311310
box = container_of(hrtimer, struct intel_uncore_box, hrtimer);
312311
if (!box->n_active || box->cpu != smp_processor_id())
313312
return HRTIMER_NORESTART;
314-
/*
315-
* disable local interrupt to prevent uncore_pmu_event_start/stop
316-
* to interrupt the update process
317-
*/
318-
local_irq_save(flags);
319313

320314
/*
321315
* handle boxes with an active event list as opposed to active
@@ -328,16 +322,14 @@ static enum hrtimer_restart uncore_pmu_hrtimer(struct hrtimer *hrtimer)
328322
for_each_set_bit(bit, box->active_mask, UNCORE_PMC_IDX_MAX)
329323
uncore_perf_event_update(box, box->events[bit]);
330324

331-
local_irq_restore(flags);
332-
333325
hrtimer_forward_now(hrtimer, ns_to_ktime(box->hrtimer_duration));
334326
return HRTIMER_RESTART;
335327
}
336328

337329
void uncore_pmu_start_hrtimer(struct intel_uncore_box *box)
338330
{
339331
hrtimer_start(&box->hrtimer, ns_to_ktime(box->hrtimer_duration),
340-
HRTIMER_MODE_REL_PINNED);
332+
HRTIMER_MODE_REL_PINNED_HARD);
341333
}
342334

343335
void uncore_pmu_cancel_hrtimer(struct intel_uncore_box *box)
@@ -347,7 +339,7 @@ void uncore_pmu_cancel_hrtimer(struct intel_uncore_box *box)
347339

348340
static void uncore_pmu_init_hrtimer(struct intel_uncore_box *box)
349341
{
350-
hrtimer_setup(&box->hrtimer, uncore_pmu_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
342+
hrtimer_setup(&box->hrtimer, uncore_pmu_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
351343
}
352344

353345
static struct intel_uncore_box *uncore_alloc_box(struct intel_uncore_type *type,

0 commit comments

Comments
 (0)