acpica-devel.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
To: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Cc: <rafael@kernel.org>, <lenb@kernel.org>, <robert.moore@intel.com>,
	<linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<acpica-devel@lists.linux.dev>, <tglx@linutronix.de>,
	<mingo@redhat.com>, <bp@alien8.de>, <dave.hansen@linux.intel.com>,
	<x86@kernel.org>, <hpa@zytor.com>, <mcgrof@kernel.org>,
	<peterz@infradead.org>, <j.granados@samsung.com>,
	<viresh.kumar@linaro.org>, <linux-pm@vger.kernel.org>,
	<CobeChen@zhaoxin.com>, <TimGuo@zhaoxin.com>,
	<LeoLiu-oc@zhaoxin.com>, <LindaChai@zhaoxin.com>
Subject: Re: [PATCH 3/3] ACPI: cpufreq: Add ITMT support when CPPC enabled for Zhaoxin CPUs
Date: Wed, 31 Jan 2024 18:55:25 +0800	[thread overview]
Message-ID: <7f869bc1-9129-48b2-b0fd-483c790a8d1b@zhaoxin.com> (raw)
In-Reply-To: <20240117225158.GD13777@ranerica-svr.sc.intel.com>


On 2024/1/18 06:51, Ricardo Neri wrote:
>
> [这封邮件来自外部发件人]
>
> On Thu, Dec 28, 2023 at 03:57:05PM +0800, Tony W Wang-oc wrote:
>> For Zhaoxin CPUs, the cores' highest frequencies may be different, which
>> means that cores may run at different max frequencies,
>>
>> According to ACPI-spec6 chapter 8.4.7, the per-core highest frequency
>> value can be obtained via cppc.
>>
>> The core with the higher frequency have better performance, which can be
>> called as preferred core. And better performance can be achieved by
>> making the scheduler to run tasks on these preferred cores.
>>
>> The cpufreq driver can use the highest frequency value as the prioriy of
>> core to make the scheduler try to get better performace. More specifically,
>> in the acpi-cpufreq driver use cppc_get_highest_perf() to get highest
>> frequency value of each core, use sched_set_itmt_core_prio() to set
>> highest frequency value as core priority, and use sched_set_itmt_support()
>> provided by ITMT to tell the scheduler to favor on the preferred cores.
>>
>> Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
>> ---
>>   drivers/cpufreq/acpi-cpufreq.c | 56 +++++++++++++++++++++++++++++++++-
>>   1 file changed, 55 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
>> index 37f1cdf46d29..f4c1ff9e4bb0 100644
>> --- a/drivers/cpufreq/acpi-cpufreq.c
>> +++ b/drivers/cpufreq/acpi-cpufreq.c
>> @@ -663,8 +663,56 @@ static u64 get_max_boost_ratio(unsigned int cpu)
>>
>>        return div_u64(highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf);
>>   }
>> +
>> +/* The work item is needed to avoid CPU hotplug locking issues */
>> +static void sched_itmt_work_fn(struct work_struct *work)
>> +{
>> +     sched_set_itmt_support();
>> +}
>> +
>> +static DECLARE_WORK(sched_itmt_work, sched_itmt_work_fn);
>> +
>> +static void set_itmt_prio(int cpu)
>> +{
>> +     static bool cppc_highest_perf_diff;
>> +     static struct cpumask core_prior_mask;
>> +     u64 highest_perf;
>> +     static u64 max_highest_perf = 0, min_highest_perf = U64_MAX;
>> +     int ret;
>> +
>> +     ret = cppc_get_highest_perf(cpu, &highest_perf);
>> +     if (ret)
>> +             return;
>> +
>> +     sched_set_itmt_core_prio(highest_perf, cpu);
>> +     cpumask_set_cpu(cpu, &core_prior_mask);
>> +
>> +     if (max_highest_perf <= min_highest_perf) {
>> +             if (highest_perf > max_highest_perf)
>> +                     max_highest_perf = highest_perf;
>> +
>> +             if (highest_perf < min_highest_perf)
>> +                     min_highest_perf = highest_perf;
>> +
>> +             if (max_highest_perf > min_highest_perf) {
>> +                     /*
>> +                      * This code can be run during CPU online under the
>> +                      * CPU hotplug locks, so sched_set_itmt_support()
>> +                      * cannot be called from here.  Queue up a work item
>> +                      * to invoke it.
>> +                      */
>> +                     cppc_highest_perf_diff = true;
>> +             }
>> +     }
>> +
>> +     if (cppc_highest_perf_diff && cpumask_equal(&core_prior_mask, cpu_online_mask)) {
>> +             pr_debug("queue a work to set itmt enabled\n");
>> +             schedule_work(&sched_itmt_work);
>> +     }
>> +}
> sched_itmt_work and this function is a duplicate of what the intel_pstate
> driver already does. It might be good if consolidate in a single place
> if you are going to pursue this approach.

Thanks for your suggestion, will change the patch code in v2.

Sorry for late.


      reply	other threads:[~2024-01-31 10:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-28  7:57 [PATCH 0/3] Add Zhaoxin preferred core support in acpi-cpufreq Tony W Wang-oc
2023-12-28  7:57 ` [PATCH 1/3] ACPI: CPPC: Add get the highest perf register value support Tony W Wang-oc
2024-01-17 22:07   ` Ricardo Neri
2024-01-31 10:52     ` Tony W Wang-oc
2023-12-28  7:57 ` [PATCH 2/3] x86/sched/itmt: Export two API symbols Tony W Wang-oc
2023-12-28  7:57 ` [PATCH 3/3] ACPI: cpufreq: Add ITMT support when CPPC enabled for Zhaoxin CPUs Tony W Wang-oc
2024-01-03 15:37   ` Rafael J. Wysocki
2024-01-04  6:26     ` Tony W Wang-oc
2024-01-17 22:51   ` Ricardo Neri
2024-01-31 10:55     ` Tony W Wang-oc [this message]

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=7f869bc1-9129-48b2-b0fd-483c790a8d1b@zhaoxin.com \
    --to=tonywwang-oc@zhaoxin.com \
    --cc=CobeChen@zhaoxin.com \
    --cc=LeoLiu-oc@zhaoxin.com \
    --cc=LindaChai@zhaoxin.com \
    --cc=TimGuo@zhaoxin.com \
    --cc=acpica-devel@lists.linux.dev \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=j.granados@samsung.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=ricardo.neri-calderon@linux.intel.com \
    --cc=robert.moore@intel.com \
    --cc=tglx@linutronix.de \
    --cc=viresh.kumar@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).