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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 9 Sep 2020 08:43:44 -0500
From:   Alex Elder <elder@...aro.org>
To:     David Miller <davem@...emloft.net>
Cc:     kuba@...nel.org, evgreen@...omium.org, subashab@...eaurora.org,
        cpratapa@...eaurora.org, bjorn.andersson@...aro.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 1/5] net: ipa: use atomic exchange for suspend
 reference

On 9/8/20 10:27 PM, David Miller wrote:
> From: Alex Elder <elder@...aro.org>
> Date: Tue,  8 Sep 2020 19:21:23 -0500
> 
>> We take a single IPA clock reference to keep the clock running
>> until we get a system suspend operation.  When a system suspend
>> request arrives, we drop that reference, and if that's the last
>> reference (likely) we'll proceed with suspending endpoints and
>> disabling the IPA core clock and interconnects.
>>
>> In most places we simply set the reference count to 0 or 1
>> atomically.  Instead--primarily to catch coding errors--use an
>> atomic exchange to update the reference count value, and report
>> an error in the event the previous value was unexpected.
>>
>> In a few cases it's not hard to see that the error message should
>> never be reported.  Report them anyway, but add some excitement
>> to the message by ending it with an exclamation point.
>>
>> Signed-off-by: Alex Elder <elder@...aro.org>
> 
> Please use refcount_t if you're wanting to validate things like
> this.

There is exactly one reference here; the "reference" is
essentially a Boolean flag.  So the value is always either
0 or 1.

I can use refcount_dec_if_one() for the 1->0 transition,
but I'm not sure how I can do the 0->1 transition with
refcount_t.  I admit I might be missing something.

Would you like me to add refcount_inc_if_zero()?

Otherwise would you prefer a different naming convention
to use for this Boolean "reference count"?

Thanks.

					-Alex

> 
> Thank you.
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ