Date: Wed, 1 Feb 2017 08:39:05 -0800 From: David Chisnall <theraven@FreeBSD.org> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Alexander Kabaev <kabaev@gmail.com>, Alexander Kabaev <kan@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r313040 - head/sys/mips/include Message-ID: <191141D2-4665-4E24-AA4F-A34127C15953@FreeBSD.org> In-Reply-To: <20170201161354.GF2092@kib.kiev.ua> References: <201702010500.v1150YLR075051@repo.freebsd.org> <20170201141721.GB2092@kib.kiev.ua> <20170201103842.1ad0989f@kan> <20170201161354.GF2092@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On 1 Feb 2017, at 08:13, Konstantin Belousov <kostikbel@gmail.com> wrote:
>
> 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@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.
C[++]11 addresses this by having a weak and a strong variant of compare and exchange. The strong version may only fail if the comparison fails, we weak version is permitted to fail spuriously. Given that most uses of compare and exchange use a loop, and most ll/sc architectures guarantee forward process after a few attempts, you almost always want to use the weak version.
The weak version also has the advantage that the compiler is free to fold the initial load into the load linked, as long as the target architecture would permit it, so you end up with more idiomatic ll, op, sc, branch sequences, rather than l, op, ll, branch, sc, branch sequences.
David
[-- Attachment #2 --]
0 *H
010 + 0 *H
00"kg}0z$F`0
*H
0u10 UIL10U
StartCom Ltd.1)0'U StartCom Certification Authority1#0!UStartCom Class 1 Client CA0
160419092742Z
170419092742Z0D10Utheraven@freebsd.org1#0! *H
theraven@freebsd.org0"0
*H
0
!htֆ[J
^=*':#Y6"ӊ ؊cR_0WZ=Rx4 asPm&0:P2>u=NbLn]E}$$ xS4ǖRI68RpO֔{\oz;)D=SOM^#;Ԡ*Y߆ mbf/+hBӅuQ@ڭʫ&8@Xm 00U0U%0++0 U0 0Us[Ddp =0U#0$l9aIF+('Hmh0o+c0a0$+0http://ocsp.startssl.com09+0-http://aia.startssl.com/certs/sca.client1.crt08U10/0-+)'http://crl.startssl.com/sca-client1.crl0U0theraven@freebsd.org0#U0http://www.startssl.com/0FU ?0=0;+70,0*+http://www.startssl.com/policy0
*H
R1m
=.A#6n-B;w5'zGL:=E44hOaŹi}l}{f!_Fh+MDZu!K&ECE~PWѥftB+UcEKD&3V]g,}{-)M[_!8jJ&a͒N"jԫt2ךz0ζ=|E?<viA2W9&_u{:u۲\E00ʠk}
Q
Y0
*H
0}10 UIL10U
StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom Certification Authority0
151216010005Z
301216010005Z0u10 UIL10U
StartCom Ltd.1)0'U StartCom Certification Authority1#0!UStartCom Class 1 Client CA0"0
*H
0
}â}[[_u$Wy5 |̔
vnqY)\aL$dYG|B"QǤĩVD#'F k9O_]*ςz_kU.u3r #:C<ogT)K
Xah8v[\KqdlO)3+u7J5";[vfL/"2ϩJ#4ד[U TB,a˖a7H< =q d0`0U0U%0++0U0 02U+0)0'%#!http://crl.startssl.com/sfsca.crl0f+Z0X0$+0http://ocsp.startssl.com00+0$http://aia.startssl.com/certs/ca.crt0U$l9aIF+('Hmh0U#0N@[i04hCA0?U 80604U 0,0*+http://www.startssl.com/policy0
*H
[#'#4pnRۡЗN⛭`]K"#H*߷Թψ;UA8Ҟeg{ozmYE60A)wXRK6c^-Al^k[':G=;oLv{$B5;8b,ZP4{o[-j m)[땭[4 s.c|ҴvYLJ<|ӯgu0jD2
@hl+:j\ze_ևa@HyMHINxpK?% 㤺RC:=?^&7m´)A2;E~VB1$EvcKj؝(OoپU`"$a;ҡj0$&<$ۊ+/xjzb,7}W*1ܺtDv#8K
%^P>/i?)yRuQg^z`~sP91N0J00u10 UIL10U
StartCom Ltd.1)0'U StartCom Certification Authority1#0!UStartCom Class 1 Client CA"kg}0z$F`0 + 0 *H
1 *H
0 *H
1
170201163906Z0# *H
19+M\R^G
Rc0 +7100u10 UIL10U
StartCom Ltd.1)0'U StartCom Certification Authority1#0!UStartCom Class 1 Client CA"kg}0z$F`0*H
10u10 UIL10U
StartCom Ltd.1)0'U StartCom Certification Authority1#0!UStartCom Class 1 Client CA"kg}0z$F`0
*H
n枬G_
YKx
o\`'bHPS+_B*߯Pf㗑j-j_MS\-2[#+NpJ.>lD4JD3ȫ0ڍ>)3>Qߪ(hEimqd\]q|(qZLCTع.C>hyNnO\fbHgawHPa'w$e@)8rP_G~rܥF{f
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?191141D2-4665-4E24-AA4F-A34127C15953>
