From: Schspa Shi <schspa@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Linux PM <linux-pm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 1/2] cpufreq: fix race on cpufreq online
Date: Fri, 13 May 2022 19:16:01 +0800 [thread overview]
Message-ID: <CAMA88Trc143Zaeua_AEt0ynukACYdPqXMG6R50Zoz-sXmMbX4A@mail.gmail.com> (raw)
In-Reply-To: <20220513061343.wndyhjeehoqmfofp@vireshk-i7>
Viresh Kumar <viresh.kumar@linaro.org> writes:
> On 13-05-22, 14:06, Schspa Shi wrote:
>> Viresh Kumar <viresh.kumar@linaro.org> writes:
>> > On 12-05-22, 21:52, Schspa Shi wrote:
>> >> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> >> index 80f535cc8a75..35dffd738580 100644
>> >> --- a/drivers/cpufreq/cpufreq.c
>> >> +++ b/drivers/cpufreq/cpufreq.c
>> >> @@ -953,7 +953,10 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)
>> >> return -EIO;
>> >>
>> >> down_read(&policy->rwsem);
>> >> - ret = fattr->show(policy, buf);
>> >> + if (unlikely(policy_is_inactive(policy)))
>> >> + ret = -EBUSY;
>> >> + else
>> >> + ret = fattr->show(policy, buf);
>> >
>> > I like it the way I have done earlier, initialize ret to -EBUSY and
>> > get rid of the else part and call show/store in if itself. Same for
>> > below.
>> >
>>
>> I add a unlikely here, to avoid branch prediction failed.
>
> I am not asking you to drop it, I also added the unlikely within the
> implementation of policy_is_inactive() then. It can be written as:
>
> if (likely(!policy_is_inactive(policy)))
> ret = fattr->show(policy, buf);
>
>> And move the
>> to the fail path to avoid a register assignment to -EBUSY.
>
> We don't care about such assignments for performance to be honest.
> This makes the code smaller by few lines, that's enough.
OK, I have uploaded a v5 patch for this. Please review it.
--
Schspa Shi
BRs
prev parent reply other threads:[~2022-05-13 11:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-12 13:52 [PATCH v4 1/2] cpufreq: fix race on cpufreq online Schspa Shi
2022-05-12 13:52 ` [PATCH v4 2/2] cpufreq: make interface functions and lock holding state clear Schspa Shi
2022-05-12 14:44 ` Rafael J. Wysocki
2022-05-12 16:01 ` Schspa Shi
2022-05-12 16:23 ` Rafael J. Wysocki
2022-05-13 4:29 ` Viresh Kumar
2022-05-15 9:53 ` [cpufreq] 0a020f0eff: WARNING:possible_recursive_locking_detected kernel test robot
2022-05-16 2:35 ` Schspa Shi
2022-05-13 4:18 ` [PATCH v4 1/2] cpufreq: fix race on cpufreq online Viresh Kumar
2022-05-13 6:06 ` Schspa Shi
2022-05-13 6:13 ` Viresh Kumar
2022-05-13 11:16 ` Schspa Shi [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=CAMA88Trc143Zaeua_AEt0ynukACYdPqXMG6R50Zoz-sXmMbX4A@mail.gmail.com \
--to=schspa@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--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 NNTP newsgroup(s).