From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42943 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpzDL-0007Pv-P3 for qemu-devel@nongnu.org; Thu, 17 Feb 2011 03:27:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PpzDJ-00029y-RY for qemu-devel@nongnu.org; Thu, 17 Feb 2011 03:27:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PpzDJ-00029f-Kw for qemu-devel@nongnu.org; Thu, 17 Feb 2011 03:27:49 -0500 Message-ID: <4D5CDBFF.3030808@redhat.com> Date: Thu, 17 Feb 2011 09:27:43 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20110215175410.GA13487@amt.cnet> <4D5ACCED.1080906@siemens.com> <20110215200446.GA15802@amt.cnet> <4D5AE2FC.4020309@web.de> <20110215205504.GA16527@amt.cnet> <20110215205631.GA16579@amt.cnet> <4D5B99A9.1010404@redhat.com> <20110217031538.GA22552@amt.cnet> In-Reply-To: <20110217031538.GA22552@amt.cnet> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] fix halt emulation with icount and CONFIG_IOTHREAD (v2) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti Cc: "Edgar E. Iglesias" , Jan Kiszka , "qemu-devel@nongnu.org" On 02/17/2011 04:15 AM, Marcelo Tosatti wrote: > Yes, using qemu_icount_delta directly in tcg_wait_io_event timedwait > is explicit (partially the reason for confusion with my patch). > > So the reasoning for the patch is: > > With icount vm_timer timers expire on virtual CPU time. If a CPU halts, > you cannot expect passage of realtime to trigger vm_timers expiration. But if a CPU is halted, all_cpu_threads_idle() will still be true even if you signal the condition variable, and you'll be looping in the while condition. That's why I say that while (x) { cond_timedwait (cond, mutex); } (i.e. without checking the return value of cond_timedwait, and without polling something else upon return) is a broken idiom that can only work around missing signals/broadcasts. > So instead vm_timer expiration is converted to realtime, and used as > halt timeout. But vm_timer timers are only used by "-icount auto", which works in my tests [*]. It is "-icount N" which is broken and unfortunately your patch does not fix it. The CRIS image on qemu.org triggers the watchdog (and if I eliminate the watchdog I see that the CPU is hung). [*] Actually, it works but doesn't calibrate very well. It shows 25 bogomips, sometimes 50, compared to 250 without iothread. Paolo