On Fri, Apr 08, 2016 at 06:24:16PM +0200, Luigi Rizzo wrote:
> I have an application with two threads sharing a memory variable,
> one continuously writing, one continuously reading.
> Because of the way my system works, the reader can tolerate reading
> stale data, but it should not stall on memory reads (the line
> is on the local cache for the reader, just might be invalidated).
> I was wondering if there is some way (either generic or
> x86-specific, either simple or convoluted, possibly using
> multiple versions of the shared variable in different cache
> lines) to make sure that reads never stalls (or, equivalently,
> let me read stale values from the cache) ?
> I have done some experiments and on a single-socket machines
> the stallled reads take some 50ns; on a dual socket machine
> the stall penalty grows to about 200ns.
You cannot turn off cache-coherence logic. Of course, you could avoid
cache at all, by using non-temporal stores or setting memory to
write-combining or non-cacheable. But the result from the non-temporal
writes/cached reads is undefined and probably never working, while for
WC memory you get hit from full memory latency on read.
If you are fine reading stale value, then you could update two instances
of the variable, one with the full rate, and another instance, located
in different cache line, with the reduced rate. Readers would access
only the reduced rate instance.
To get the eventual consistency, a timer would be needed which updates
the slow variable by the fast value.
email@example.com mailing list
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"