lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMA88Trc143Zaeua_AEt0ynukACYdPqXMG6R50Zoz-sXmMbX4A@mail.gmail.com>
Date:   Fri, 13 May 2022 19:16:01 +0800
From:   Schspa Shi <schspa@...il.com>
To:     Viresh Kumar <viresh.kumar@...aro.org>
Cc:     "Rafael J. Wysocki" <rafael@...nel.org>,
        Linux PM <linux-pm@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 1/2] cpufreq: fix race on cpufreq online

Viresh Kumar <viresh.kumar@...aro.org> writes:

> On 13-05-22, 14:06, Schspa Shi wrote:
>> Viresh Kumar <viresh.kumar@...aro.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ