mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-18 18:23:53 +08:00
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 <hch@lst.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
4f337faf1c
commit
aaec7c03de
@ -7190,15 +7190,15 @@ static void kvm_timer_init(void)
|
|||||||
|
|
||||||
if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
|
if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
|
||||||
#ifdef CONFIG_CPU_FREQ
|
#ifdef CONFIG_CPU_FREQ
|
||||||
struct cpufreq_policy policy;
|
struct cpufreq_policy *policy;
|
||||||
int cpu;
|
int cpu;
|
||||||
|
|
||||||
memset(&policy, 0, sizeof(policy));
|
|
||||||
cpu = get_cpu();
|
cpu = get_cpu();
|
||||||
cpufreq_get_policy(&policy, cpu);
|
policy = cpufreq_cpu_get(cpu);
|
||||||
if (policy.cpuinfo.max_freq)
|
if (policy && policy->cpuinfo.max_freq)
|
||||||
max_tsc_khz = policy.cpuinfo.max_freq;
|
max_tsc_khz = policy->cpuinfo.max_freq;
|
||||||
put_cpu();
|
put_cpu();
|
||||||
|
cpufreq_cpu_put(policy);
|
||||||
#endif
|
#endif
|
||||||
cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block,
|
cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block,
|
||||||
CPUFREQ_TRANSITION_NOTIFIER);
|
CPUFREQ_TRANSITION_NOTIFIER);
|
||||||
|
Loading…
Reference in New Issue
Block a user