From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSF5J-00074r-SN for qemu-devel@nongnu.org; Tue, 05 Jan 2010 14:28:53 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSF5F-0006zw-39 for qemu-devel@nongnu.org; Tue, 05 Jan 2010 14:28:53 -0500 Received: from [199.232.76.173] (port=34047 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSF5E-0006zX-Td for qemu-devel@nongnu.org; Tue, 05 Jan 2010 14:28:48 -0500 Received: from mx20.gnu.org ([199.232.41.8]:35457) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NSF5E-0002qi-IC for qemu-devel@nongnu.org; Tue, 05 Jan 2010 14:28:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NS8pi-0003P5-LD for qemu-devel@nongnu.org; Tue, 05 Jan 2010 07:48:22 -0500 Message-ID: <4B43350A.7000309@redhat.com> Date: Tue, 05 Jan 2010 13:48:10 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1261382970-23251-1-git-send-email-pbonzini@redhat.com> <1261382970-23251-12-git-send-email-pbonzini@redhat.com> <4B424E95.4040806@codemonkey.ws> <4B42491C.1050709@redhat.com> <4B4280FC.4020602@codemonkey.ws> In-Reply-To: <4B4280FC.4020602@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 11/19] use a bottom half to run timers List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org On 01/05/2010 12:59 AM, Anthony Liguori wrote: > > When I think of a main loop, I think of something that provides the > following three services > > 1) fd based events > 2) time based events > 3) an idle callback > > The problem we have is that bottom halves aren't quite idle callbacks. > They have some really weird properties about the guarantees of when > they're executed. At any rate, you really cannot express a time based > event as an idle callback because you need to setup the select() timeout > based on the next deadline and then dispatch timer event based on > selects return. idle functions have none of this ability. I see bottom halves as a fourth service, providing the ability to synchronize stuff that needs to execute in a particular thread (guaranteeing thread-safety and especially signal-safety). In some sense, the problem is that bottom halves conflate this service _and_ idle callbacks, and that is the weird property. Idle callbacks are used basically only for DMA, and real-world DMA does not have at all the semantics that qemu_bh_schedule_idle provides (which in turn is very tricky and not exactly what comments in qemu_bh_update_timeout promise). Compared to qemu_bh_schedule_idle, bottom halves have sane semantics. It would be nicer IMO to remove qemu_bh_schedule_idle, have first-class idle callbacks, and leave bottom halves as they are now. I'll put that on the todo list. :-) That said, I'll try to replace this patch with one that doesn't use a bottom half. Paolo