Skip to content

Commit 0f2828e

Browse files
committed
cpufreq: intel_pstate: Get rid of unnecessary READ_ONCE() annotations
Drop two redundant checks involving READ_ONCE() from notify_hwp_interrupt() and make it check hwp_active without READ_ONCE() which is not necessary, because that variable is only set once during the early initialization of the driver. In order to make that clear, annotate hwp_active with __ro_after_init. Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 432acb2 commit 0f2828e

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ struct pstate_funcs {
292292

293293
static struct pstate_funcs pstate_funcs __read_mostly;
294294

295-
static int hwp_active __read_mostly;
295+
static bool hwp_active __ro_after_init;
296296
static int hwp_mode_bdw __read_mostly;
297297
static bool per_cpu_limits __read_mostly;
298298
static bool hwp_boost __read_mostly;
@@ -1636,11 +1636,10 @@ static cpumask_t hwp_intr_enable_mask;
16361636
void notify_hwp_interrupt(void)
16371637
{
16381638
unsigned int this_cpu = smp_processor_id();
1639-
struct cpudata *cpudata;
16401639
unsigned long flags;
16411640
u64 value;
16421641

1643-
if (!READ_ONCE(hwp_active) || !boot_cpu_has(X86_FEATURE_HWP_NOTIFY))
1642+
if (!hwp_active || !boot_cpu_has(X86_FEATURE_HWP_NOTIFY))
16441643
return;
16451644

16461645
rdmsrl_safe(MSR_HWP_STATUS, &value);
@@ -1652,24 +1651,8 @@ void notify_hwp_interrupt(void)
16521651
if (!cpumask_test_cpu(this_cpu, &hwp_intr_enable_mask))
16531652
goto ack_intr;
16541653

1655-
/*
1656-
* Currently we never free all_cpu_data. And we can't reach here
1657-
* without this allocated. But for safety for future changes, added
1658-
* check.
1659-
*/
1660-
if (unlikely(!READ_ONCE(all_cpu_data)))
1661-
goto ack_intr;
1662-
1663-
/*
1664-
* The free is done during cleanup, when cpufreq registry is failed.
1665-
* We wouldn't be here if it fails on init or switch status. But for
1666-
* future changes, added check.
1667-
*/
1668-
cpudata = READ_ONCE(all_cpu_data[this_cpu]);
1669-
if (unlikely(!cpudata))
1670-
goto ack_intr;
1671-
1672-
schedule_delayed_work(&cpudata->hwp_notify_work, msecs_to_jiffies(10));
1654+
schedule_delayed_work(&all_cpu_data[this_cpu]->hwp_notify_work,
1655+
msecs_to_jiffies(10));
16731656

16741657
spin_unlock_irqrestore(&hwp_notify_lock, flags);
16751658

@@ -3464,7 +3447,7 @@ static int __init intel_pstate_init(void)
34643447
* deal with it.
34653448
*/
34663449
if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) || hwp_forced) {
3467-
WRITE_ONCE(hwp_active, 1);
3450+
hwp_active = true;
34683451
hwp_mode_bdw = id->driver_data;
34693452
intel_pstate.attr = hwp_cpufreq_attrs;
34703453
intel_cpufreq.attr = hwp_cpufreq_attrs;

0 commit comments

Comments
 (0)