Date: Mon, 18 Dec 2000 00:40:46 +1100 (EST) From: Bruce Evans <bde@zeta.org.au> To: Chuck Paterson <cp@bsdi.com> Cc: Julian Elischer <julian@elischer.org>, John Baldwin <jhb@FreeBSD.ORG>, Alfred Perlstein <bright@wintelcom.net>, smp@FreeBSD.ORG Subject: Re: atomic increment? Message-ID: <Pine.BSF.4.21.0012172338480.8671-100000@besplex.bde.org> In-Reply-To: <200012161629.eBGGTsP05883@berserker.bsdi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 16 Dec 2000, Chuck Paterson wrote: > Actually performaning the volatile function ->>may<<- have reduced > register pressure resulting in gcc using the load eax. There sure > isn't much which gcc is going to believe is save to leave in a register > across this instruction sequence once it is tagged as volatile. I think gcc should know that it is safe. Clobbering of registers by asms is specified in the input/output constraints and the clobber list. `volatile' qualifiers shouldn't affect this. > This does bring up the point that not all use of atomic ops are > equal. There are those which must not only have the locked prefix > to make the operation work but must be executed in the correct place in > the instruction stream to get correct overall semantics. On the other > hand there are those, such a stat counters, which only need the > lock prefix. These uses really shouldn't require being tagged as volatile. Um, it is the volatile qualifiers on the pointer args of the atomic functions that cause the pessimization, not the volatile qualifiers on the asms. We use the former just to avoid -Wcast-qual warnings about non-problems. See i386/include/atomic.h rev.1.4. The atomic functions are used on a few volatile variables (perhaps fewer than there should be); the addresses of these variables have type `volatile [u]intN_t', so the corresponding function arg must have a volatile qualifer; this also works for non-volatile variables, so we don't need non-volatile variants of the functions (strictly, we need signed integer variants of them, but we cheat on that). I usually declare all asms as volatile so that I don't have to worry about them being moved. In practice, they don't seem to get moved much without the volatile qualifier, so always using volatile is efficient enough. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0012172338480.8671-100000>