From owner-freebsd-current@freebsd.org Fri Apr 8 21:22:48 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 70EFBB07AD4 for ; Fri, 8 Apr 2016 21:22:48 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 34B1612BC for ; Fri, 8 Apr 2016 21:22:48 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1aodrR-000CF2-7s; Sat, 09 Apr 2016 00:22:37 +0300 Date: Sat, 9 Apr 2016 00:22:37 +0300 From: Slawa Olhovchenkov To: Luigi Rizzo Cc: freebsd-current@freebsd.org Subject: Re: stall-free memory reads ? (possibly stale) ? Message-ID: <20160408212237.GA6614@zxy.spb.ru> References: <20160408162416.GA94343@onelab2.iet.unipi.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160408162416.GA94343@onelab2.iet.unipi.it> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false 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 21:22:48 -0000 On Fri, Apr 08, 2016 at 06:24:16PM +0200, Luigi Rizzo wrote: > 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. Can this link help to you? https://tu-dresden.de/die_tu_dresden/zentrale_einrichtungen/zih/forschung/projekte/benchit/2015_ICPP_authors_version.pdf