Skip to content

Commit 73a5fa7

Browse files
committed
x86/aperfmperf: Restructure arch_scale_freq_tick()
Preparation for sharing code with the CPU frequency portion of the aperf/mperf code. No functional change. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Paul E. McKenney <paulmck@kernel.org> Link: https://lore.kernel.org/r/20220415161206.706185092@linutronix.de
1 parent 24620d9 commit 73a5fa7

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

arch/x86/kernel/cpu/aperfmperf.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -477,22 +477,9 @@ static DECLARE_WORK(disable_freq_invariance_work,
477477

478478
DEFINE_PER_CPU(unsigned long, arch_freq_scale) = SCHED_CAPACITY_SCALE;
479479

480-
void arch_scale_freq_tick(void)
480+
static void scale_freq_tick(u64 acnt, u64 mcnt)
481481
{
482-
struct aperfmperf *s = this_cpu_ptr(&cpu_samples);
483-
u64 aperf, mperf, acnt, mcnt, freq_scale;
484-
485-
if (!arch_scale_freq_invariant())
486-
return;
487-
488-
rdmsrl(MSR_IA32_APERF, aperf);
489-
rdmsrl(MSR_IA32_MPERF, mperf);
490-
491-
acnt = aperf - s->aperf;
492-
mcnt = mperf - s->mperf;
493-
494-
s->aperf = aperf;
495-
s->mperf = mperf;
482+
u64 freq_scale;
496483

497484
if (check_shl_overflow(acnt, 2*SCHED_CAPACITY_SHIFT, &acnt))
498485
goto error;
@@ -514,4 +501,23 @@ void arch_scale_freq_tick(void)
514501
pr_warn("Scheduler frequency invariance went wobbly, disabling!\n");
515502
schedule_work(&disable_freq_invariance_work);
516503
}
504+
505+
void arch_scale_freq_tick(void)
506+
{
507+
struct aperfmperf *s = this_cpu_ptr(&cpu_samples);
508+
u64 acnt, mcnt, aperf, mperf;
509+
510+
if (!arch_scale_freq_invariant())
511+
return;
512+
513+
rdmsrl(MSR_IA32_APERF, aperf);
514+
rdmsrl(MSR_IA32_MPERF, mperf);
515+
acnt = aperf - s->aperf;
516+
mcnt = mperf - s->mperf;
517+
518+
s->aperf = aperf;
519+
s->mperf = mperf;
520+
521+
scale_freq_tick(acnt, mcnt);
522+
}
517523
#endif /* CONFIG_X86_64 && CONFIG_SMP */

0 commit comments

Comments
 (0)