From owner-freebsd-current@freebsd.org Fri Sep 23 11:41:29 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 88DAABE1815 for ; Fri, 23 Sep 2016 11:41:29 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (mail.turbocat.net [IPv6:2a01:4f8:d16:4514::2]) (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 55658C68 for ; Fri, 23 Sep 2016 11:41:29 +0000 (UTC) (envelope-from hps@selasky.org) Received: from laptop015.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 8EC151FE023 for ; Fri, 23 Sep 2016 13:41:27 +0200 (CEST) To: FreeBSD Current From: Hans Petter Selasky Subject: Question about wmb() and rmb() and task switching Message-ID: Date: Fri, 23 Sep 2016 13:46:15 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 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, 23 Sep 2016 11:41:29 -0000 Hi, Does use of wmb() and rmb() for amd64 as defined in sys/amd64/include/atomic.h required use of critical_enter()/critical_exit(). I was looking at the code in sys/amd64/amd64/cpu_switch.S which switches between threads and I don't see any "sfence" instructions in there. Given the following piece of dummy code: var_a = 1; var_b = 2; wmb(); If there is a task switch between writing var_a and var_b so that the thread in question continues executing on another core, can it happen that the write to var_a is not flushed when wmb() is executed? var_a = 1; var_b = 2; wmb(); --HPS