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: <CAE-0n51gcN+3Ng7+bz21eS_6JomnVDzZMuWyzZVB25paj29j4g@mail.gmail.com>
Date:   Tue, 29 Aug 2023 15:52:19 -0500
From:   Stephen Boyd <swboyd@...omium.org>
To:     Doug Anderson <dianders@...omium.org>,
        Michał Mirosław <mirq-linux@...e.qmqm.pl>
Cc:     Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>, linux-kernel@...r.kernel.org,
        Dmitry Osipenko <digetx@...il.com>
Subject: Re: [PATCH 6/6] regulator: core: simplify lock_two()

Quoting Michał Mirosław (2023-08-28 13:26:54)
> Indeed they are quite similar. I did remove a bit more code than that,
> though: in this case there is no early success return before the loop.
>
> Instead of saying:
>
> lock A
> lock B
> if ok return
> if that failed, loop:
>   unlock A
>   lock B harder
>   lock A
>   if ok return
>   swap A <-> B
>   lock B
>
> Now it's:
>
> lock A
> loop forever:
>   lock B
>   if ok, return
>   unlock A
>   swap them
>   lock A harder
>
> With the same condition 'A held' at the start of an iteration.
>

Removing duplicate code is great! I'm primarily concerned with
readability. The terms 'A' and 'B' doesn't make it easy for me. Can you
maintain the 'held' and 'contended' names for the variables?

That would be

 lock 'held'
 loop forever:
   lock 'contended'
   if ok, return
   unlock 'held'
   swap them
   lock 'held' harder

per the psuedo-code.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ