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