From owner-freebsd-current@freebsd.org Fri Apr 8 16:19:28 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EAF18B08B09 for ; Fri, 8 Apr 2016 16:19:28 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id BB0FC18E1 for ; Fri, 8 Apr 2016 16:19:28 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 055097300A; Fri, 8 Apr 2016 18:24:17 +0200 (CEST) Date: Fri, 8 Apr 2016 18:24:16 +0200 From: Luigi Rizzo To: freebsd-current@freebsd.org Subject: stall-free memory reads ? (possibly stale) ? Message-ID: <20160408162416.GA94343@onelab2.iet.unipi.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2016 16:19:29 -0000 Hi, 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. cheers luigi