Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+21 -15
+21 -15
arch/x86/kernel/cpu/aperfmperf.c
··· 477 477 478 478 DEFINE_PER_CPU(unsigned long, arch_freq_scale) = SCHED_CAPACITY_SCALE; 479 479 480 - void arch_scale_freq_tick(void) 480 + static void scale_freq_tick(u64 acnt, u64 mcnt) 481 481 { 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; 496 483 497 484 if (check_shl_overflow(acnt, 2*SCHED_CAPACITY_SHIFT, &acnt)) 498 485 goto error; ··· 500 513 error: 501 514 pr_warn("Scheduler frequency invariance went wobbly, disabling!\n"); 502 515 schedule_work(&disable_freq_invariance_work); 516 + } 517 + 518 + void arch_scale_freq_tick(void) 519 + { 520 + struct aperfmperf *s = this_cpu_ptr(&cpu_samples); 521 + u64 acnt, mcnt, aperf, mperf; 522 + 523 + if (!arch_scale_freq_invariant()) 524 + return; 525 + 526 + rdmsrl(MSR_IA32_APERF, aperf); 527 + rdmsrl(MSR_IA32_MPERF, mperf); 528 + acnt = aperf - s->aperf; 529 + mcnt = mperf - s->mperf; 530 + 531 + s->aperf = aperf; 532 + s->mperf = mperf; 533 + 534 + scale_freq_tick(acnt, mcnt); 503 535 } 504 536 #endif /* CONFIG_X86_64 && CONFIG_SMP */