svn commit: r313040 - head/sys/mips/include

Konstantin Belousov kostikbel at gmail.com
Wed Feb 1 16:13:59 UTC 2017


On Wed, Feb 01, 2017 at 10:38:42AM -0500, Alexander Kabaev wrote:
> On Wed, 1 Feb 2017 16:17:21 +0200
> Konstantin Belousov <kostikbel at gmail.com> wrote:
> 
> > Please do not retry on sc failure, return the error to upper layer.
> > See also r313007 and preceeding discussion after r312973.
> 
> There was not much a discussion there, do you mind expanding a bit on
> why one behavior is more desired than other? I am not against the
> change, but I need to understand the reasoning behind it better. Since
> atomic_cmpset retries too, it will have to be adjusted as well.

atomic_cmpset() cannot avoid retry on the ll/sc architectures, because
sc might fail even if the old and the new values are same. One of the
points of the fcmpset API design is to avoid nested loops: this is a
microoptimization to put less pressure on the CPUs frontend. The caller
of (f)cmpset must check for failure anyway, so not doing this inside the
function reduces number of branches. Less branches makes code shorter,
and reduces utilization of some CPU resources, like branch predictor
state.


More information about the svn-src-all mailing list