[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABN1KCJ0Tk5ah33zKpksq4Ftqa8Eh+V3bGZRMRAv-XrmakT1Og@mail.gmail.com>
Date: Wed, 5 Apr 2023 15:42:28 -0700
From: David Dai <davidai@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Viresh Kumar <viresh.kumar@...aro.org>,
Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Valentin Schneider <vschneid@...hat.com>,
Saravana Kannan <saravanak@...gle.com>,
kernel-team@...roid.com, linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org
Subject: Re: [RFC PATCH 6/6] cpufreq: add kvm-cpufreq driver
On Wed, Apr 5, 2023 at 1:23 AM Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Thu, Mar 30, 2023 at 03:43:41PM -0700, David Dai wrote:
>
> > +struct remote_data {
> > + int ret;
> > + struct cpufreq_frequency_table *table;
> > +};
> > +
> > +static void remote_get_freqtbl_num_entries(void *data)
> > +{
> > + struct arm_smccc_res hvc_res;
> > + u32 freq = 1UL;
> > + int *idx = data;
> > +
> > + while (freq != CPUFREQ_TABLE_END) {
> > + arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_GET_CPUFREQ_TBL_FUNC_ID,
> > + *idx, &hvc_res);
> > + if (hvc_res.a0) {
> > + *idx = -ENODEV;
> > + return;
> > + }
> > + freq = hvc_res.a1;
> > + (*idx)++;
> > + }
> > +}
> > +
> > +static int kvm_cpufreq_get_freqtbl_num_entries(int cpu)
> > +{
> > + int num_entries = 0;
> > +
> > + smp_call_function_single(cpu, remote_get_freqtbl_num_entries, &num_entries, true);
> > + return num_entries;
> > +}
> > +
> > +static void remote_populate_freqtbl(void *data)
> > +{
> > + struct arm_smccc_res hvc_res;
> > + struct remote_data *freq_data = data;
> > + struct cpufreq_frequency_table *pos;
> > + struct cpufreq_frequency_table *table = freq_data->table;
> > + int idx;
> > +
> > + cpufreq_for_each_entry_idx(pos, table, idx) {
> > + arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_GET_CPUFREQ_TBL_FUNC_ID,
> > + idx, &hvc_res);
> > + if (hvc_res.a0) {
> > + freq_data->ret = -ENODEV;
> > + return;
> > + }
> > + pos->frequency = hvc_res.a1;
> > + }
> > + freq_data->ret = 0;
> > +}
> > +
> > +static int kvm_cpufreq_populate_freqtbl(struct cpufreq_frequency_table *table, int cpu)
> > +{
> > + struct remote_data freq_data;
> > +
> > + freq_data.table = table;
> > + smp_call_function_single(cpu, remote_populate_freqtbl, &freq_data, true);
> > + return freq_data.ret;
> > +}
>
Hi Peter,
Thanks for taking the time to review!
> *WHY* are you sending IPIs to do a hypercall ?!?
>
> You can simply have the hypercall tell what vCPU you're doing this for.
>
We’ll remove all the code that’s making IPI calls and switch over to
populating the frequency tables in the device tree when we move from
RFC to PATCH. It is here for now to make it easier for others to
cherry-pick and test the series without needing more changes to their
VMM.
Thanks,
David
Powered by blists - more mailing lists