From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Maydell Subject: Re: [PATCH 01/15] atomic: introduce atomic operations Date: Wed, 8 Aug 2012 14:32:02 +0100 Message-ID: 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 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?Q?Andreas_F=C3=A4rber?= To: Paolo Bonzini Return-path: In-Reply-To: <5022671E.8070602@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org On 8 August 2012 14:18, Paolo Bonzini wrote: > Il 08/08/2012 15:09, Stefan Hajnoczi ha scritto: >> No need to roll our own or copy the implementation from the kernel. > > To some extent we need to because: > > 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? -- PMM From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sz6Mt-0003mn-Ls for qemu-devel@nongnu.org; Wed, 08 Aug 2012 09:32:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sz6Ml-00083o-Vs for qemu-devel@nongnu.org; Wed, 08 Aug 2012 09:32:11 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:48653) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sz6Ml-00083h-Re for qemu-devel@nongnu.org; Wed, 08 Aug 2012 09:32:03 -0400 Received: by yenm4 with SMTP id m4so722481yen.4 for ; Wed, 08 Aug 2012 06:32:03 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <5022671E.8070602@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> Date: Wed, 8 Aug 2012 14:32:02 +0100 Message-ID: From: Peter Maydell Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH 01/15] atomic: introduce atomic operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini 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?Q?Andreas_F=C3=A4rber?= On 8 August 2012 14:18, Paolo Bonzini wrote: > Il 08/08/2012 15:09, Stefan Hajnoczi ha scritto: >> No need to roll our own or copy the implementation from the kernel. > > To some extent we need to because: > > 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? -- PMM