Skip to content

Commit aaec7c0

Browse files
committed
KVM: x86: avoid useless copy of cpufreq policy
struct cpufreq_policy is quite big and it is not a good idea to allocate one on the stack. Just use cpufreq_cpu_get and cpufreq_cpu_put which is even simpler. Reported-by: Christoph Hellwig <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 4f337fa commit aaec7c0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arch/x86/kvm/x86.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7190,15 +7190,15 @@ static void kvm_timer_init(void)
71907190

71917191
if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
71927192
#ifdef CONFIG_CPU_FREQ
7193-
struct cpufreq_policy policy;
7193+
struct cpufreq_policy *policy;
71947194
int cpu;
71957195

7196-
memset(&policy, 0, sizeof(policy));
71977196
cpu = get_cpu();
7198-
cpufreq_get_policy(&policy, cpu);
7199-
if (policy.cpuinfo.max_freq)
7200-
max_tsc_khz = policy.cpuinfo.max_freq;
7197+
policy = cpufreq_cpu_get(cpu);
7198+
if (policy && policy->cpuinfo.max_freq)
7199+
max_tsc_khz = policy->cpuinfo.max_freq;
72017200
put_cpu();
7201+
cpufreq_cpu_put(policy);
72027202
#endif
72037203
cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block,
72047204
CPUFREQ_TRANSITION_NOTIFIER);

0 commit comments

Comments
 (0)