From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:51780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gx4SV-0001Aj-Am for qemu-devel@nongnu.org; Fri, 22 Feb 2019 01:37:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gx4ST-0003g1-UA for qemu-devel@nongnu.org; Fri, 22 Feb 2019 01:37:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33406) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gx4ST-0003eA-E0 for qemu-devel@nongnu.org; Fri, 22 Feb 2019 01:37:17 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5DF103097061 for ; Fri, 22 Feb 2019 06:37:15 +0000 (UTC) Date: Fri, 22 Feb 2019 14:36:58 +0800 From: Peter Xu Message-ID: <20190222063658.GF8904@xz-x1> References: <20190222031413.20250-1-peterx@redhat.com> <20190222031413.20250-2-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/4] iothread: replace init_done_cond with a semaphore List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: qemu-devel , Paolo Bonzini , Stefan Hajnoczi , Eric Blake On Fri, Feb 22, 2019 at 07:25:16AM +0100, Marc-Andr=C3=A9 Lureau wrote: > Hi >=20 > On Fri, Feb 22, 2019 at 4:14 AM Peter Xu wrote: > > > > Only sending an init-done message using lock+cond seems an overkill t= o > > me. Replacing it with a simpler semaphore. > > > > Meanwhile, init the semaphore unconditionally, then we can destroy it > > unconditionally too in finalize which seems cleaner. > > > > Signed-off-by: Peter Xu >=20 > The lock is also protecting thread_id. IMHO it's fine because thread_id is only changed at the beginning of iothread_run where the caller will definitely wait for the thread_id to be generated. Here qemu_sem_post() should at least contain one write memory barrier there to make sure the waker will read the correct value after sem_wait() and then later on thread_id is never changed. Regards, --=20 Peter Xu