From: Thomas Renninger <trenn@suse.com>
To: linux@dominikbrodowski.net, sherry.hurwitz@amd.com,
linux-pm@vger.kernel.org, xufuhai <xufuhai1992@gmail.com>,
xufuhai <xufuhai@kuaishou.com>
Cc: lishujin@kuaishou.com
Subject: Re: [PATCH 2/2] cpupower: fix amd cpu (family >= 0x17) active state issue
Date: Mon, 29 Mar 2021 12:58:32 +0200 [thread overview]
Message-ID: <1717786.6COvnHc5Zm@c100> (raw)
In-Reply-To: <20210324082838.41462-2-xufuhai1992@gmail.com>
Hi,
Am Mittwoch, 24. März 2021, 09:28:38 CEST schrieb xufuhai:
> From: xufuhai <xufuhai@kuaishou.com>
>
> If the read_msr function is executed by a non-root user, the function
> returns -1, which means that there is no permission to access
> /dev/cpu/%d/msr, but cpufreq_has_boost_support should also return -1
> immediately, and should not follow the original logic to return 0, which
> will cause amd The cpupower tool returns the turbo active status as 0.
Yes, this seem to be buggy.
Can you clean this up a bit more, please:
> Reproduce procedure:
> cpupower frequency-info
>
> Signed-off-by: xufuhai <xufuhai@kuaishou.com>
> ---
> tools/power/cpupower/utils/helpers/misc.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tools/power/cpupower/utils/helpers/misc.c
> b/tools/power/cpupower/utils/helpers/misc.c index
> fc6e34511721..be96f9ce18eb 100644
> --- a/tools/power/cpupower/utils/helpers/misc.c
> +++ b/tools/power/cpupower/utils/helpers/misc.c
> @@ -30,10 +30,15 @@ int cpufreq_has_boost_support(unsigned int cpu, int
> *support, int *active, */
>
> if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CPB_MSR) {
> - if (!read_msr(cpu, MSR_AMD_HWCR, &val)) {
> + ret = read_msr(cpu, MSR_AMD_HWCR, &val);
> + if (!ret) {
ret should be initialized. I would initialize it with -1, but as Intel case
is always "good"/zero, it may make sense here to set:
ret = 0
at the beginning of the func already.
At the end of the func, unconditionally returning zero:
return 0;
should be replace by:
return ret;
> if (!(val & CPUPOWER_AMD_CPBDIS))
> *active = 1;
> - }
> + } else
> + /* no permission to access /dev/cpu/%d/msr, return -1 immediately,
> + * and should not follow the original logic to return 0
> + */
> + return ret;
Then this part is not needed anymore, right?
Still the comment would be nice to show up, maybe slightly modified
in the if condition?
Afaik 100% correct comment would be:
/* ... */
for one line comment and:
/*
* ...
* ...
*/
for multiline comment (one more line..).
> } else {
> ret = amd_pci_get_num_boost_states(active, states);
> if (ret)
and these 2 lines can vanish as well at this point:
if (ret)
return ret;
What do you think?
Thanks for spotting this,
Thomas
next parent reply other threads:[~2021-03-29 10:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210324082838.41462-1-xufuhai1992@gmail.com>
[not found] ` <20210324082838.41462-2-xufuhai1992@gmail.com>
2021-03-29 10:58 ` Thomas Renninger [this message]
2021-03-30 2:46 ` [PATCH 2/2] cpupower: fix amd cpu (family >= 0x17) active state issue xufuhai
2021-04-08 2:21 ` xufuhai
2021-04-15 7:02 ` [PATCH v2 " xufuhai
2021-04-15 13:45 ` Huang Rui
2021-04-15 23:07 ` Shuah Khan
[not found] ` <CAOkq_BcdvS1NtKJ9=peRWHc00kGjfvdE+Cyz7vqvH0+kermfhQ@mail.gmail.com>
2021-04-16 15:04 ` Shuah Khan
2021-03-29 11:10 ` [PATCH 1/2] cpupower: fix amd cpu (family < " Thomas Renninger
2021-03-30 3:47 ` xufuhai
2021-04-08 2:22 ` xufuhai
2021-03-24 10:28 [PATCH 2/2] cpupower: fix amd cpu (family >= " xufuhai
2021-03-26 20:13 ` Shuah Khan
2021-03-29 4:11 ` xufuhai
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=1717786.6COvnHc5Zm@c100 \
--to=trenn@suse.com \
--cc=linux-pm@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
--cc=lishujin@kuaishou.com \
--cc=sherry.hurwitz@amd.com \
--cc=xufuhai1992@gmail.com \
--cc=xufuhai@kuaishou.com \
/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