From: Viresh Kumar <viresh.kumar@linaro.org>
To: "Rafael Wysocki" <rjw@rjwysocki.net>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
linux-pm@vger.kernel.org,
Vincent Guittot <vincent.guittot@linaro.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 6/7] KVM: x86: Update cpufreq transition notifier to handle multiple CPUs
Date: Thu, 14 Mar 2019 12:12:52 +0530 [thread overview]
Message-ID: <adcf2b6e181d2ad2ab1b7038ba898eb4f4e53906.1552545525.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1552545525.git.viresh.kumar@linaro.org>
The cpufreq core currently calls the cpufreq transition notifier
callback once for each affected CPU. This is going to change soon and
the cpufreq core will call the callback only once for each cpufreq
policy. The callback must look at the newly added field in struct
cpufreq_freqs, "cpus", which contains policy->related_cpus (both
online/offline CPUs) and perform per-cpu actions for them if any.
This patch updates kvmclock_cpufreq_notifier() to use the new "cpus"
field and perform the per-cpu activity for all online CPUs in this
cpumask.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
arch/x86/kvm/x86.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 941f932373d0..24eb6123391d 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6648,10 +6648,8 @@ static void kvm_hyperv_tsc_notifier(void)
}
#endif
-static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
- void *data)
+static void __kvmclock_cpufreq_notifier(struct cpufreq_freqs *freq, int cpu)
{
- struct cpufreq_freqs *freq = data;
struct kvm *kvm;
struct kvm_vcpu *vcpu;
int i, send_ipi = 0;
@@ -6695,17 +6693,12 @@ static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long va
*
*/
- if (val == CPUFREQ_PRECHANGE && freq->old > freq->new)
- return 0;
- if (val == CPUFREQ_POSTCHANGE && freq->old < freq->new)
- return 0;
-
- smp_call_function_single(freq->cpu, tsc_khz_changed, freq, 1);
+ smp_call_function_single(cpu, tsc_khz_changed, freq, 1);
spin_lock(&kvm_lock);
list_for_each_entry(kvm, &vm_list, vm_list) {
kvm_for_each_vcpu(i, vcpu, kvm) {
- if (vcpu->cpu != freq->cpu)
+ if (vcpu->cpu != cpu)
continue;
kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
if (vcpu->cpu != smp_processor_id())
@@ -6727,8 +6720,24 @@ static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long va
* guest context is entered kvmclock will be updated,
* so the guest will not see stale values.
*/
- smp_call_function_single(freq->cpu, tsc_khz_changed, freq, 1);
+ smp_call_function_single(cpu, tsc_khz_changed, freq, 1);
}
+}
+
+static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
+ void *data)
+{
+ struct cpufreq_freqs *freq = data;
+ int cpu;
+
+ if (val == CPUFREQ_PRECHANGE && freq->old > freq->new)
+ return 0;
+ if (val == CPUFREQ_POSTCHANGE && freq->old < freq->new)
+ return 0;
+
+ for_each_cpu_and(cpu, freq->cpus, cpu_online_mask)
+ __kvmclock_cpufreq_notifier(freq, cpu);
+
return 0;
}
--
2.21.0.rc0.269.g1a574e7a288b
next prev parent reply other threads:[~2019-03-14 6:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-14 6:42 [PATCH 0/7] cpufreq: Call transition notifier only once for each policy Viresh Kumar
2019-03-14 6:42 ` [PATCH 1/7] cpufreq: Pass policy->related_cpus to transition notifiers Viresh Kumar
2019-03-14 6:42 ` [PATCH 2/7] ARM: smp: Update cpufreq transition notifier to handle multiple CPUs Viresh Kumar
2019-03-14 6:42 ` [PATCH 3/7] ARM: twd: " Viresh Kumar
2019-03-14 6:42 ` [PATCH 4/7] sparc64: " Viresh Kumar
2019-03-14 17:27 ` David Miller
2019-03-14 6:42 ` [PATCH 5/7] x86/tsc: " Viresh Kumar
2019-03-14 9:33 ` Rafael J. Wysocki
2019-03-14 10:03 ` Viresh Kumar
2019-03-14 6:42 ` Viresh Kumar [this message]
2019-03-14 6:42 ` [PATCH 7/7] cpufreq: Call transition notifiers only once for each policy Viresh Kumar
2019-03-14 9:28 ` [PATCH 0/7] cpufreq: Call transition notifier " Rafael J. Wysocki
2019-03-14 9:40 ` Rafael J. Wysocki
2019-03-14 10:18 ` Viresh Kumar
2019-03-14 10:16 ` Viresh Kumar
2019-03-14 10:55 ` Rafael J. Wysocki
2019-03-14 11:03 ` Viresh Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adcf2b6e181d2ad2ab1b7038ba898eb4f4e53906.1552545525.git.viresh.kumar@linaro.org \
--to=viresh.kumar@linaro.org \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=vincent.guittot@linaro.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®