Skip to content

Commit 2a606a1

Browse files
Stephane EranianPeter Zijlstra
authored andcommitted
ACPI: Add perf low power callback
Add an optional callback needed by some PMU features, e.g., AMD BRS, to give a chance to the perf_events code to change its state before a CPU goes to low power and after it comes back. The callback is void when the PERF_NEEDS_LOPWR_CB flag is not set. This flag must be set in arch specific perf_event.h header whenever needed. When not set, there is no impact on the ACPI code. Signed-off-by: Stephane Eranian <[email protected]> [peterz: build fix] Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent cc37e52 commit 2a606a1

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

drivers/acpi/acpi_pad.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/tick.h>
1818
#include <linux/slab.h>
1919
#include <linux/acpi.h>
20+
#include <linux/perf_event.h>
2021
#include <asm/mwait.h>
2122
#include <xen/xen.h>
2223

@@ -164,6 +165,9 @@ static int power_saving_thread(void *data)
164165
tsc_marked_unstable = 1;
165166
}
166167
local_irq_disable();
168+
169+
perf_lopwr_cb(true);
170+
167171
tick_broadcast_enable();
168172
tick_broadcast_enter();
169173
stop_critical_timings();
@@ -172,6 +176,9 @@ static int power_saving_thread(void *data)
172176

173177
start_critical_timings();
174178
tick_broadcast_exit();
179+
180+
perf_lopwr_cb(false);
181+
175182
local_irq_enable();
176183

177184
if (time_before(expire_time, jiffies)) {

drivers/acpi/processor_idle.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/cpuidle.h>
2222
#include <linux/cpu.h>
2323
#include <linux/minmax.h>
24+
#include <linux/perf_event.h>
2425
#include <acpi/processor.h>
2526

2627
/*
@@ -549,6 +550,8 @@ static void wait_for_freeze(void)
549550
*/
550551
static void __cpuidle acpi_idle_do_entry(struct acpi_processor_cx *cx)
551552
{
553+
perf_lopwr_cb(true);
554+
552555
if (cx->entry_method == ACPI_CSTATE_FFH) {
553556
/* Call into architectural FFH based C-state */
554557
acpi_processor_ffh_cstate_enter(cx);
@@ -559,6 +562,8 @@ static void __cpuidle acpi_idle_do_entry(struct acpi_processor_cx *cx)
559562
inb(cx->address);
560563
wait_for_freeze();
561564
}
565+
566+
perf_lopwr_cb(false);
562567
}
563568

564569
/**

include/linux/perf_event.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,4 +1676,10 @@ typedef int (perf_snapshot_branch_stack_t)(struct perf_branch_entry *entries,
16761676
unsigned int cnt);
16771677
DECLARE_STATIC_CALL(perf_snapshot_branch_stack, perf_snapshot_branch_stack_t);
16781678

1679+
#ifndef PERF_NEEDS_LOPWR_CB
1680+
static inline void perf_lopwr_cb(bool mode)
1681+
{
1682+
}
1683+
#endif
1684+
16791685
#endif /* _LINUX_PERF_EVENT_H */

0 commit comments

Comments
 (0)