Received: from [140.186.70.92] (port=57659 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q2Uso-00027U-AC for qemu-devel@nongnu.org; Wed, 23 Mar 2011 16:42:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q2Usm-0003Gk-53 for qemu-devel@nongnu.org; Wed, 23 Mar 2011 16:42:22 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:46267) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q2Usl-0003GD-Nw for qemu-devel@nongnu.org; Wed, 23 Mar 2011 16:42:20 -0400 Message-Id: From: =?WINDOWS-1252?Q?Andreas_F=E4rber?= In-Reply-To: Content-Type: text/plain; charset=WINDOWS-1252; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: [Qemu-devel] [PATCH] simpletrace: Thread-safe tracing Date: Wed, 23 Mar 2011 21:42:16 +0100 References: <1298885894-23090-1-git-send-email-stefanha@linux.vnet.ibm.com> <7E78EF7C-737B-49AE-827F-7A6519D05FFF@web.de> Sender: andreas.faerber@web.de List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi , Alexander Graf , "qemu-devel@nongnu.org Developers" , Avi Kivity , Prerna Saxena , Paolo Bonzini Am 23.03.2011 um 08:39 schrieb Stefan Hajnoczi: > On Tue, Mar 22, 2011 at 11:52 PM, Andreas F=E4rber = > wrote: >> Am 28.02.2011 um 10:38 schrieb Stefan Hajnoczi: >> >>> Trace events outside the global mutex cannot be used with the simple >>> trace backend since it is not thread-safe. There is no check to =20 >>> prevent >>> them being enabled so people sometimes learn this the hard way. >>> >>> This patch restructures the simple trace backend with a ring buffer >>> suitable for multiple concurrent writers. A writeout thread =20 >>> empties the >>> trace buffer when threshold fill levels are reached. Should the >>> writeout thread be unable to keep up with trace generation, =20 >>> records will >>> simply be dropped. >>> >>> Each time events are dropped a special record is written to the =20 >>> trace >>> file indicating how many events were dropped. The event ID is >>> 0xfffffffffffffffe and its signature is dropped(uint32_t count). >>> >>> Signed-off-by: Stefan Hajnoczi >>> --- >>> v2: >>> * Add 'dropped' event so we know when events were lost. >> >> [...] >>> >>> + __sync_synchronize(); /* read memory barrier before accessing =20= >>> record >>> */ >> >> Getting this at HEAD on Darwin/ppc64: >> >> CC simpletrace.o >> /Users/andreas/QEMU/qemu/simpletrace.c: In function =20 >> =91get_trace_record=92: >> /Users/andreas/QEMU/qemu/simpletrace.c:81: warning: implicit =20 >> declaration of >> function =91__sync_synchronize=92 >> /Users/andreas/QEMU/qemu/simpletrace.c:81: warning: nested extern >> declaration of =91__sync_synchronize=92 >> /Users/andreas/QEMU/qemu/simpletrace.c: In function =91trace=92: >> /Users/andreas/QEMU/qemu/simpletrace.c:161: warning: implicit =20 >> declaration of >> function =91__sync_fetch_and_add=92 >> /Users/andreas/QEMU/qemu/simpletrace.c:161: warning: nested extern >> declaration of =91__sync_fetch_and_add=92 >> [...] >> LINK qemu-nbd >> Undefined symbols: >> "___sync_fetch_and_add", referenced from: >> _trace in simpletrace.o >> "___sync_synchronize", referenced from: >> _get_trace_record in simpletrace.o >> _trace in simpletrace.o >> ld: symbol(s) not found >> collect2: ld returned 1 exit status >> make: *** [qemu-nbd] Error 1 >> >> Haven't investigated further yet. > > /me shakes his fist at Apple gcc! Well, due to ppc I'm stuck at Leopard. Could be different on Snow =20 Leopard... > These are gcc builtins, I believe the were added in gcc 4.1: > = http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html#Atomic-Bu= iltins > > Which version of gcc are you running? $ gcc --version powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493) Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There =20 is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR =20 PURPOSE. Andreas=