From patchwork Tue Apr 6 20:16:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 49537 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1AEE4B7D64 for ; Wed, 7 Apr 2010 06:27:37 +1000 (EST) Received: from localhost ([127.0.0.1]:49623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzFF3-0002s2-2W for incoming@patchwork.ozlabs.org; Tue, 06 Apr 2010 16:19:21 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NzFC8-0002QN-PT for qemu-devel@nongnu.org; Tue, 06 Apr 2010 16:16:20 -0400 Received: from [140.186.70.92] (port=49673 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzFC2-0002NL-Rj for qemu-devel@nongnu.org; Tue, 06 Apr 2010 16:16:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NzFBy-0000qZ-57 for qemu-devel@nongnu.org; Tue, 06 Apr 2010 16:16:14 -0400 Received: from mail-fx0-f221.google.com ([209.85.220.221]:60462) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NzFBy-0000qO-0J for qemu-devel@nongnu.org; Tue, 06 Apr 2010 16:16:10 -0400 Received: by fxm21 with SMTP id 21so363110fxm.2 for ; Tue, 06 Apr 2010 13:16:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=AbX6INMLcQ0kDhs4s5Ua/kL2xQP2CbCf4BNZb/qQUpQ=; b=eEKKD32zw+ZTtrhHNebjHqUN8rsJv/QLpI4x1omCrOndkArl3E5lDQowIzjADkH34w 52v/w3ghe1shrK3G6G358TaXIwfQ5tQW0sJPfG2Zdb+5j3sEXMosj4L8xgfcNbxWWGBH +GLwjnTFVL1v8nnw2ifOvrv7XIQhPh8zmTGCU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=G18iM0ff0sP6y8oqChyhubVP2qL2kAvKBikm7kpDZl7SF8KUYpIwrrimcdLwxlB/qr edDllQsdOVss7rdS/vELO+We3wi/AbCVtN87fLuLsxYFQBHq8Sgy1OsA7S5LaeNYAmT7 7dXjaDUUgy3rwm7Y7dtRFA0f3daU+NWiMdsOk= Received: by 10.223.64.194 with SMTP id f2mr95134fai.2.1270584968935; Tue, 06 Apr 2010 13:16:08 -0700 (PDT) Received: from yakj.usersys.redhat.com (s209p8.home.99maxprogres.cz [85.93.118.17]) by mx.google.com with ESMTPS id 2sm10982861fks.42.2010.04.06.13.16.06 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 06 Apr 2010 13:16:07 -0700 (PDT) Message-ID: <4BBB9685.9090801@redhat.com> Date: Tue, 06 Apr 2010 22:16:05 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc12 Lightning/1.0b2pre Thunderbird/3.0.3 MIME-Version: 1.0 To: malc References: In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] fix 100% cpu utilization when cpu is stopped (was Re: d6f4ade214a9f74dca9495b83a24ff9c113e4f9a) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 04/05/2010 03:51 PM, malc wrote: > Hello, > > d6f4ade214a9f74dca9495b83a24ff9c113e4f9a: disentangle tcg and deadline calculation > introduces following regression(s): > > 100% cpu utilization when QEMU is invoked like: > qemu -S -s ... > > ditto when gdb takes control over the session via gdb-stub > (i.e. the breakpoint is hit or C-c is pressed inside gdb to > interrupt the attached qemu instance) The bug is that env->stopped is not really as comprehensive as it seems to be (and cpu_has_work thinks); it is only valid with iothread basically, and even then it is cleared by reset and it is not set when starting qemu with -S. Signed-off-by: Paolo Bonzini diff --git a/cpus.c b/cpus.c index a2e0642..0debe77 100644 --- a/cpus.c +++ b/cpus.c @@ -100,9 +100,7 @@ static int cpu_can_run(CPUState *env) { if (env->stop) return 0; - if (env->stopped) - return 0; - if (!vm_running) + if (env->stopped || !vm_running) return 0; return 1; } @@ -111,7 +109,7 @@ static int cpu_has_work(CPUState *env) { if (env->stop) return 1; - if (env->stopped) + if (env->stopped || !vm_running) return 0; if (!env->halted) return 1;