From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 01/15] atomic: introduce atomic operations Date: Wed, 08 Aug 2012 15:49:42 +0200 Message-ID: <50226E76.7000609@redhat.com> References: <1344407156-25562-1-git-send-email-qemulist@gmail.com> <1344407156-25562-2-git-send-email-qemulist@gmail.com> <5022671E.8070602@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Stefan Hajnoczi , Marcelo Tosatti , Liu Ping Fan , qemu-devel@nongnu.org, Blue Swirl , Avi Kivity , Anthony Liguori , Jan Kiszka , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= To: Peter Maydell Return-path: Received: from mail-pb0-f46.google.com ([209.85.160.46]:33660 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751931Ab2HHNtw (ORCPT ); Wed, 8 Aug 2012 09:49:52 -0400 Received: by pbbrr13 with SMTP id rr13so1498032pbb.19 for ; Wed, 08 Aug 2012 06:49:51 -0700 (PDT) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 08/08/2012 15:32, Peter Maydell ha scritto: >> > 1. GCC atomics look ugly, :) do not provide rmb/wmb, and in some >> > versions of GCC mb is known to be (wrongly) a no-op. >> > >> > 2. glib atomics do not provide mb/rmb/wmb either, and >> > g_atomic_int_get/g_atomic_int_set are inefficient: they add barriers >> > everywhere, while it is clearer if you put barriers manually, and you >> > often do not need barriers in the get side. glib atomics also do not >> > provide xchg. > These are arguments in favour of "don't try to use atomic ops" -- > if serious large projects like GCC and glib can't produce working > efficient implementations for all target architectures, what chance > do we have? Well, maybe... but the flaws in both GCC and glib are small in size (even though large in importance, at least for us) and we can work around them easily. mb/rmb/wmb is essentially the small set of atomic operations that we're already using. Paolo From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:32831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sz6e6-00087C-VA for qemu-devel@nongnu.org; Wed, 08 Aug 2012 09:50:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sz6e1-0005Ik-30 for qemu-devel@nongnu.org; Wed, 08 Aug 2012 09:49:58 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:50493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sz6e0-0005Ia-Sx for qemu-devel@nongnu.org; Wed, 08 Aug 2012 09:49:53 -0400 Received: by pbbrp12 with SMTP id rp12so1029714pbb.4 for ; Wed, 08 Aug 2012 06:49:51 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <50226E76.7000609@redhat.com> Date: Wed, 08 Aug 2012 15:49:42 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1344407156-25562-1-git-send-email-qemulist@gmail.com> <1344407156-25562-2-git-send-email-qemulist@gmail.com> <5022671E.8070602@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 01/15] atomic: introduce atomic operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: kvm@vger.kernel.org, Stefan Hajnoczi , Marcelo Tosatti , Liu Ping Fan , qemu-devel@nongnu.org, Blue Swirl , Avi Kivity , Anthony Liguori , Jan Kiszka , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Il 08/08/2012 15:32, Peter Maydell ha scritto: >> > 1. GCC atomics look ugly, :) do not provide rmb/wmb, and in some >> > versions of GCC mb is known to be (wrongly) a no-op. >> > >> > 2. glib atomics do not provide mb/rmb/wmb either, and >> > g_atomic_int_get/g_atomic_int_set are inefficient: they add barriers >> > everywhere, while it is clearer if you put barriers manually, and you >> > often do not need barriers in the get side. glib atomics also do not >> > provide xchg. > These are arguments in favour of "don't try to use atomic ops" -- > if serious large projects like GCC and glib can't produce working > efficient implementations for all target architectures, what chance > do we have? Well, maybe... but the flaws in both GCC and glib are small in size (even though large in importance, at least for us) and we can work around them easily. mb/rmb/wmb is essentially the small set of atomic operations that we're already using. Paolo