From patchwork Sun May 8 13:09:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 765782 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p48DBfZe019856 for ; Sun, 8 May 2011 13:11:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753442Ab1EHNLd (ORCPT ); Sun, 8 May 2011 09:11:33 -0400 Received: from mail-px0-f173.google.com ([209.85.212.173]:32996 "EHLO mail-px0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753392Ab1EHNLa (ORCPT ); Sun, 8 May 2011 09:11:30 -0400 Received: by mail-px0-f173.google.com with SMTP id 16so3105032pxi.4 for ; Sun, 08 May 2011 06:11:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=YPNAdQ5+FH5dzPRxpn/WbwDnT2XI8iGGDf+FEGL/890=; b=hKjtdCmrWoMp95gbvs3hBGFo6JR8L96hm9Z1doUzFEdDriYcWJ8L/SyWvtZZJgX47a X6DG200pngcqeg/r7kzXSabanb5wMfSwBUx09o/HbMKktXZ3Ao41xlxzpB0PcfjArAWI iUMO734DS1xGn4WZY4GlVy4yzMV+swTTfgYNk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=mbrFkelbpcnkqWKq7O6+iRqpONE+KecEMMezD8T0+WFpSbJngp8/3SiwmfZ3q2jRAH g4ROMK36WM1I6mC3ioawPj9tUYvUC++imSSlJsoDGDeXSI62TCnx4KwPk82iyCS/Q7f/ RVHkLG+ItAs/4cT5mBX2WqOW73UJFVRhNUev4= Received: by 10.68.32.226 with SMTP id m2mr8175652pbi.444.1304860290048; Sun, 08 May 2011 06:11:30 -0700 (PDT) Received: from localhost.localdomain ([202.112.128.133]) by mx.google.com with ESMTPS id y7sm3442117pbk.30.2011.05.08.06.11.22 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 08 May 2011 06:11:29 -0700 (PDT) From: Asias He To: Pekka Enberg , Cyrill Gorcunov , Ingo Molnar , Sasha Levin , Prasad Joshi Cc: kvm@vger.kernel.org, Asias He Subject: [PATCH v2 4/4] kvm tools: Fix virtio console hangs by removing IRQ injection for tx path Date: Sun, 8 May 2011 21:09:25 +0800 Message-Id: <1304860165-28810-5-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <1304860165-28810-1-git-send-email-asias.hejun@gmail.com> References: <1304860165-28810-1-git-send-email-asias.hejun@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sun, 08 May 2011 13:11:42 +0000 (UTC) As virtio spec says: """ Because this is high importance and low bandwidth, the current Linux implementation polls for the buffer to be used, rather than waiting for an interrupt, simplifying the implementation signicantly. """ drivers/char/virtio_console.c send_buf() { ... /* Tell Host to go! */ virtqueue_kick(out_vq); ... while (!virtqueue_get_buf(out_vq, &len)) cpu_relax(); ... } The console hangs can simply be reproduced by yes command which gives tremendous console IOs and IRQs. [ 16.786440] irq 4: nobody cared (try booting with the "irqpoll" option) [ 16.786440] Pid: 1437, comm: yes Tainted: G W 2.6.39-rc6+ #56 [ 16.786440] Call Trace: [ 16.786440] [] __report_bad_irq+0x30/0x89 [ 16.786440] [] note_interrupt+0x118/0x17a [ 16.786440] [] handle_irq_event_percpu+0x168/0x179 [ 16.786440] [] handle_irq_event+0x2c/0x46 [ 16.786440] [] ? unmask_irq+0x1e/0x1e [ 16.786440] [] handle_level_irq+0x50/0x6e [ 16.786440] [] ? do_IRQ+0x35/0x7f [ 16.786440] [] ? common_interrupt+0x29/0x30 [ 16.786440] [] ? _raw_spin_unlock_irqrestore+0x7/0x28 [ 16.786440] [] ? hvc_write+0x88/0x9e [ 16.786440] [] ? do_output_char+0x88/0x18a [ 16.786440] [] ? process_output+0x2f/0x42 [ 16.786440] [] ? n_tty_write+0x211/0x2dc [ 16.786440] [] ? try_to_wake_up+0x226/0x226 [ 16.786440] [] ? tty_write+0x15e/0x1d1 [ 16.786440] [] ? security_file_permission+0x22/0x26 [ 16.786440] [] ? process_echoes+0x241/0x241 [ 16.786440] [] ? vfs_write+0x84/0xd7 [ 16.786440] [] ? tty_write_lock+0x3d/0x3d [ 16.786440] [] ? sys_write+0x3b/0x5d [ 16.786440] [] ? sysenter_do_call+0x12/0x22 [ 16.786440] handlers: [ 16.786440] [] (vp_interrupt+0x0/0x3a) [ 16.786440] Disabling IRQ #4 Signed-off-by: Asias He --- tools/kvm/virtio/console.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/tools/kvm/virtio/console.c b/tools/kvm/virtio/console.c index f5449ba..f9031cb 100644 --- a/tools/kvm/virtio/console.c +++ b/tools/kvm/virtio/console.c @@ -166,13 +166,18 @@ static void virtio_console_handle_callback(struct kvm *self, void *param) vq = param; + /* + * The current Linux implementation polls for the buffer + * to be used, rather than waiting for an interrupt. + * So there is no need to inject an interrupt for the tx path. + */ + while (virt_queue__available(vq)) { head = virt_queue__get_iov(vq, iov, &out, &in, self); len = term_putc_iov(CONSOLE_VIRTIO, iov, out); virt_queue__set_used_elem(vq, head, len); } - virt_queue__trigger_irq(vq, virtio_console_pci_device.irq_line, &cdev.isr, self); } static bool virtio_console_pci_io_out(struct kvm *self, u16 port, void *data, int size, u32 count)