Date: Wed, 17 Sep 2003 13:22:37 -0500 From: Alan Cox <alc@cs.rice.edu> To: Frank Mayhar <frank@exit.com> Cc: smp@freebsd.org Subject: Re: atomicity of unlocked reads Message-ID: <20030917182237.GM12711@cs.rice.edu> In-Reply-To: <200309171750.h8HHowEf092627@realtime.exit.com> References: <XFMail.20030917114537.jhb@FreeBSD.org> <200309171750.h8HHowEf092627@realtime.exit.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Sep 17, 2003 at 10:50:58AM -0700, Frank Mayhar wrote: > John Baldwin wrote: > > I think you can assume that the read will be atomic. I don't think FreeBSD > > would work very well on a machine where aligned pointer reads/writes weren't > > atomic. > > I dunno, I tend to think that making such assumptions may well come back to > bite me in the ass when I least expect it. In such situation, I invariably > use some kind of "atomic_xxx_load/store" primitive that does the job safely > and in a machine-dependent way while hiding the details from the MI code. > Indeed. Atomicity of the read is not the only issue. Unless I misunderstood, Bruce is proposing to perform an unsynchronized read of a location that is updated by a different processor. This unsynchronized read is to obtain a pointer. In weaker memory consistency models (than that of the x86), there is no guarantee that the data that the pointer refers to will be consistent. In other words, updates to the data that the pointer refers to may not have completed, even though the update to the memory location containing the pointer has completed. This is what an "acquire load" is for. Roughly speaking, it should guarantee that any updates prior to a corresponding "release store" (by a different processor) will be seen. If we don't use "acquire loads" and "release stores" under such circumstances, the poor guy who ports FreeBSD to a processor that, for example, reorders loads, will be an unhappy camper. Alan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030917182237.GM12711>