From patchwork Mon Dec 7 14:17:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 553407 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 07E7D1402B4 for ; Tue, 8 Dec 2015 01:18:15 +1100 (AEDT) Received: from localhost ([::1]:54852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5wcG-0000nm-Vj for incoming@patchwork.ozlabs.org; Mon, 07 Dec 2015 09:18:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5wbp-0008UU-Oe for qemu-devel@nongnu.org; Mon, 07 Dec 2015 09:17:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a5wbm-0001D8-Gp for qemu-devel@nongnu.org; Mon, 07 Dec 2015 09:17:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59984) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5wbm-0001D4-BT for qemu-devel@nongnu.org; Mon, 07 Dec 2015 09:17:42 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id CABA85B; Mon, 7 Dec 2015 14:17:41 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (vpn1-5-152.pek2.redhat.com [10.72.5.152]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tB7EHK4f032003; Mon, 7 Dec 2015 09:17:32 -0500 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 7 Dec 2015 22:17:08 +0800 Message-Id: <1449497833-15074-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1449497833-15074-1-git-send-email-jasowang@redhat.com> References: <1449497833-15074-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: "Denis V. Lunev" , Jason Wang , Stefan Hajnoczi , Vincenzo Maffione Subject: [Qemu-devel] [PULL V2 for 2.5 1/6] e1000: fix hang of win2k12 shutdown with flood ping X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Denis V. Lunev" e1000 driver in Win2k12 is really well rotten. It 100% hangs on shutdown of UP VM under flood ping. The guest checks card state and reinjects itself interrupt in a loop. This is fatal for UP machine. There is no good way to fix this misbehavior but to kludge it. The emulation has interrupt throttling register aka ITR which limits interrupt rate and allows the guest to proceed this phase. There is no problem with this kludge for Linux guests - it adjust the value of it itself. On the other hand according to the initial research in commit e9845f0985f088dd01790f4821026df0afba5795 Author: Vincenzo Maffione Date: Fri Aug 2 18:30:52 2013 +0200 e1000: add interrupt mitigation support ... Interrupt mitigation boosts performance when the guest suffers from an high interrupt rate (i.e. receiving short UDP packets at high packet rate). For some numerical results see the following link http://info.iet.unipi.it/~luigi/papers/20130520-rizzo-vm.pdf this should also boost performance a bit. See https://bugzilla.redhat.com/show_bug.cgi?id=874406 for additional details. Signed-off-by: Denis V. Lunev CC: Vincenzo Maffione CC: Stefan Hajnoczi Signed-off-by: Jason Wang --- hw/net/e1000.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 910de3a..1531244 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -426,6 +426,11 @@ static void e1000_reset(void *opaque) e1000_link_down(d); } + /* Throttle interrupts to prevent guest (e.g Win 2012) from + * reinjecting interrupts endlessly. TODO: fix non ITR case. + */ + d->mac_reg[ITR] = 250; + /* Some guests expect pre-initialized RAH/RAL (AddrValid flag + MACaddr) */ d->mac_reg[RA] = 0; d->mac_reg[RA + 1] = E1000_RAH_AV;