Linux-PM Archive mirror
 help / color / mirror / Atom feed
From: "Yuan, Perry" <Perry.Yuan@amd.com>
To: Oleksandr Natalenko <oleksandr@natalenko.name>,
	"rafael.j.wysocki@intel.com" <rafael.j.wysocki@intel.com>,
	"Limonciello, Mario" <Mario.Limonciello@amd.com>,
	"viresh.kumar@linaro.org" <viresh.kumar@linaro.org>,
	"Huang, Ray" <Ray.Huang@amd.com>,
	"Shenoy, Gautham Ranjal" <gautham.shenoy@amd.com>,
	"Petkov, Borislav" <Borislav.Petkov@amd.com>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"Huang, Shimmer" <Shimmer.Huang@amd.com>,
	"Du, Xiaojian" <Xiaojian.Du@amd.com>,
	"Meng, Li (Jassmine)" <Li.Meng@amd.com>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v10 6/7] cpufreq: amd-pstate: introduce per CPU frequency boost control
Date: Wed, 8 May 2024 12:20:58 +0000	[thread overview]
Message-ID: <CYYPR12MB8655F5A8DC7F001E818048DD9CE52@CYYPR12MB8655.namprd12.prod.outlook.com> (raw)
In-Reply-To: <1884700.tdWV9SEqCh@natalenko.name>

[AMD Official Use Only - General]

Regards.
Perry

> -----Original Message-----
> From: Oleksandr Natalenko <oleksandr@natalenko.name>
> Sent: Wednesday, May 8, 2024 5:43 PM
> To: rafael.j.wysocki@intel.com; Limonciello, Mario
> <Mario.Limonciello@amd.com>; viresh.kumar@linaro.org; Huang, Ray
> <Ray.Huang@amd.com>; Shenoy, Gautham Ranjal
> <gautham.shenoy@amd.com>; Petkov, Borislav
> <Borislav.Petkov@amd.com>; Yuan, Perry <Perry.Yuan@amd.com>
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Huang, Shimmer
> <Shimmer.Huang@amd.com>; Du, Xiaojian <Xiaojian.Du@amd.com>; Meng,
> Li (Jassmine) <Li.Meng@amd.com>; linux-pm@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH v10 6/7] cpufreq: amd-pstate: introduce per CPU
> frequency boost control
>
> On středa 8. května 2024 11:34:21, SELČ Oleksandr Natalenko wrote:
> > Hello.
> >
> > On středa 8. května 2024 9:21:11, SELČ Perry Yuan wrote:
> > > Add a new sysfs attribute file to support per CPU frequency boost
> > > control, allowing individual CPUs to enable or disable CPB separately.
> > >
> > > The new sysfs attribute file is located at below path,
> > > `/sys/devices/system/cpu/cpuX/cpufreq/boost`,
> > > where `X` represents the CPU number.
> > >
> > > To disable CPB for a specific CPU, you can use the following command:
> > > $ sudo bash -c "echo 0 > /sys/devices/system/cpu/cpuX/cpufreq/boost"
> > >
> > > After disabling CPB, the CPU frequency will no longer boost beyond
> > > the base frequency for that particular CPU.
> > >
> > > for example:
> > > ----------------------------------------------------------------------
> > > CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE    MAXMHZ   MINMHZ
> MHZ
> > >   0    0      0    0 0:0:0:0          yes 4208.0000 400.0000 1666.7740
> > >   1    0      0    0 0:0:0:0          yes 4208.0000 400.0000  400.0000
> > >
> > > --------------------------------------------------------------------
> > > -- $ sudo bash -c "echo 0 >
> > > /sys/devices/system/cpu/cpu0/cpufreq/boost"
> > >
> > > CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE    MAXMHZ   MINMHZ
> MHZ
> > >   0    0      0    0 0:0:0:0          yes 3501.0000 400.0000 4154.3140
> > >   1    0      0    0 0:0:0:0          yes 4208.0000 400.0000  400.0000
> > >
> > > Please be aware that modifying the global variable
> > > `amd_pstate_global_params.cpb_boost` will overwrite the individual CPU
> settings.
> > >
> > > Signed-off-by: Perry Yuan <perry.yuan@amd.com>
> > > ---
> > >  drivers/cpufreq/amd-pstate.c | 27 +++++++++++++++++++++++++++
> > >  1 file changed, 27 insertions(+)
> > >
> > > diff --git a/drivers/cpufreq/amd-pstate.c
> > > b/drivers/cpufreq/amd-pstate.c index 11bce2c1db32..cb0055e7c842
> > > 100644
> > > --- a/drivers/cpufreq/amd-pstate.c
> > > +++ b/drivers/cpufreq/amd-pstate.c
> > > @@ -1371,6 +1371,30 @@ static int amd_pstate_cpu_boost(int cpu, bool
> state)
> > >   return ret < 0 ? ret : 0;
> > >  }
> > >
> > > +static ssize_t show_boost(struct cpufreq_policy *policy, char *buf)
> > > +{
> > > + struct amd_cpudata *cpudata = policy->driver_data;
> > > + bool boost_val;
> > > +
> > > + boost_val = READ_ONCE(cpudata->boost_state);
> > > +
> > > + return sysfs_emit(buf, "%u\n", boost_val); }
> > > +
> > > +static ssize_t store_boost(
> > > +         struct cpufreq_policy *policy, const char *buf, size_t count) {
> > > + bool boost_val;
> > > + int ret;
> > > +
> > > + if (sscanf(buf, "%d", &boost_val) != 1)
> >
> > This will generate warning. IIUC, sscanf() doesn't work with booleans
> directly, so you'd probably want to read the value into an (unsigned) integer,
> and then cast it to bool.
>
> …or maybe just use kstrtobool()?

Yes,  the kstrtobool is the function I need to use,  will change it in next.
Thanks
Perry.

>
> >
> > > +         return -EINVAL;
> > > +
> > > + ret = amd_pstate_cpu_boost(policy->cpu, boost_val);
> > > +
> > > + return ret < 0 ? ret : count;
> > > +}
> > > +
> > >  static ssize_t cpb_boost_show(struct device *dev,
> > >                      struct device_attribute *attr, char *buf)  { @@ -
> 1416,6
> > > +1440,7 @@ cpufreq_freq_attr_ro(amd_pstate_prefcore_ranking);
> > >  cpufreq_freq_attr_ro(amd_pstate_hw_prefcore);
> > >  cpufreq_freq_attr_rw(energy_performance_preference);
> > >  cpufreq_freq_attr_ro(energy_performance_available_preferences);
> > > +cpufreq_freq_attr_rw(boost);
> > >  static DEVICE_ATTR_RW(status);
> > >  static DEVICE_ATTR_RO(prefcore);
> > >  static DEVICE_ATTR_RW(cpb_boost);
> > > @@ -1426,6 +1451,7 @@ static struct freq_attr *amd_pstate_attr[] = {
> > >   &amd_pstate_highest_perf,
> > >   &amd_pstate_prefcore_ranking,
> > >   &amd_pstate_hw_prefcore,
> > > + &boost,
> > >   NULL,
> > >  };
> > >
> > > @@ -1437,6 +1463,7 @@ static struct freq_attr *amd_pstate_epp_attr[]
> = {
> > >   &amd_pstate_hw_prefcore,
> > >   &energy_performance_preference,
> > >   &energy_performance_available_preferences,
> > > + &boost,
> > >   NULL,
> > >  };
> > >
> > >
> >
> >
> >
>
>
> --
> Oleksandr Natalenko (post-factum)

  reply	other threads:[~2024-05-08 12:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08  7:21 [PATCH v10 0/7] AMD Pstate Driver Core Performance Boost Perry Yuan
2024-05-08  7:21 ` [PATCH v10 1/7] cpufreq: acpi: move MSR_K7_HWCR_CPB_DIS_BIT into msr-index.h Perry Yuan
2024-05-08  7:21 ` [PATCH v10 2/7] cpufreq: amd-pstate: initialize new core precision boost state Perry Yuan
2024-05-08  7:21 ` [PATCH v10 3/7] cpufreq: amd-pstate: implement cpb_boost sysfs entry for boost control Perry Yuan
2024-05-08  9:39   ` Oleksandr Natalenko
2024-05-08 11:42     ` Yuan, Perry
2024-05-08  7:21 ` [PATCH v10 4/7] cpufreq: amd-pstate: fix the MSR highest perf will be reset issue while cpb boost off Perry Yuan
2024-05-08  7:21 ` [PATCH v10 5/7] Documentation: cpufreq: amd-pstate: introduce the new cpu boost control method Perry Yuan
2024-05-08  7:21 ` [PATCH v10 6/7] cpufreq: amd-pstate: introduce per CPU frequency boost control Perry Yuan
2024-05-08  9:34   ` Oleksandr Natalenko
2024-05-08  9:43     ` Oleksandr Natalenko
2024-05-08 12:20       ` Yuan, Perry [this message]
2024-05-08  7:21 ` [PATCH v10 7/7] Documentation: cpufreq: amd-pstate: update doc for Per CPU boost control method Perry Yuan
2024-05-08  8:18 ` [PATCH v10 0/7] AMD Pstate Driver Core Performance Boost Borislav Petkov
2024-05-09 16:01   ` Yuan, Perry
2024-05-09 16:12     ` Borislav Petkov
2024-05-08 15:11 ` Oleksandr Natalenko
2024-05-08 19:13   ` Oleksandr Natalenko
2024-05-08 19:21     ` Oleksandr Natalenko
2024-05-08 21:31       ` Oleksandr Natalenko
2024-05-08 22:13         ` Mario Limonciello
2024-05-09 12:01           ` Oleksandr Natalenko
2024-05-09 16:03             ` Yuan, Perry

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=CYYPR12MB8655F5A8DC7F001E818048DD9CE52@CYYPR12MB8655.namprd12.prod.outlook.com \
    --to=perry.yuan@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Borislav.Petkov@amd.com \
    --cc=Li.Meng@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=Ray.Huang@amd.com \
    --cc=Shimmer.Huang@amd.com \
    --cc=Xiaojian.Du@amd.com \
    --cc=gautham.shenoy@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=oleksandr@natalenko.name \
    --cc=rafael.j.wysocki@intel.com \
    --cc=viresh.kumar@linaro.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).