From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiOcx-0005u1-Vo for qemu-devel@nongnu.org; Thu, 08 May 2014 09:44:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiOcr-00010R-7k for qemu-devel@nongnu.org; Thu, 08 May 2014 09:44:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiOcr-00010B-1J for qemu-devel@nongnu.org; Thu, 08 May 2014 09:44:41 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s48DidDT000544 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 8 May 2014 09:44:40 -0400 Date: Thu, 8 May 2014 14:44:35 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20140508134435.GB2408@work-vm> References: <20140508101655.GA7534@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140508101655.GA7534@stefanha-thinkpad.redhat.com> Subject: Re: [Qemu-devel] [RFC] dataplane: IOThreads and writing dataplane-capable code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Paolo Bonzini , Fam Zheng , qemu-devel@nongnu.org, Max Reitz * Stefan Hajnoczi (stefanha@redhat.com) wrote: > How to synchronize with an IOThread > ----------------------------------- > AioContext is not thread-safe so some rules must be followed when using file > descriptors, event notifiers, timers, or BHs across threads: > > 1. AioContext functions can be called safely from file descriptor, event > notifier, timer, or BH callbacks invoked by the AioContext. No locking is > necessary. > > 2. Other threads wishing to access the AioContext must use > aio_context_acquire()/aio_context_release() for mutual exclusion. Once the > context is acquired no other thread can access it or run event loop iterations > in this AioContext. > > aio_context_acquire()/aio_context_release() calls may be nested. This > means you can call them if you're not sure whether #1 applies. > > Side note: the best way to schedule a function call across threads is to create > a BH in the target AioContext beforehand and then call qemu_bh_schedule(). No > acquire/release or locking is needed for the qemu_bh_schedule() call. But be > sure to acquire the AioContext for aio_bh_new() if necessary. How do these IOThreads pause during migration? Are they paused by the 'qemu_mutex_lock_iothread' that the migration thread calls? Dave -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK