From patchwork Fri Jul 13 14:55:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 10523531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2CF846032C for ; Fri, 13 Jul 2018 14:56:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A334296CD for ; Fri, 13 Jul 2018 14:56:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E4022973E; Fri, 13 Jul 2018 14:56:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,FROM_EXCESS_BASE64,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9F92E296CD for ; Fri, 13 Jul 2018 14:56:07 +0000 (UTC) Received: from localhost ([::1]:37729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdzUM-0004H3-VT for patchwork-qemu-devel@patchwork.kernel.org; Fri, 13 Jul 2018 10:56:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdzTb-0003om-RQ for qemu-devel@nongnu.org; Fri, 13 Jul 2018 10:55:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdzTa-0007eM-Ik for qemu-devel@nongnu.org; Fri, 13 Jul 2018 10:55:19 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:37878) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fdzTa-0007dI-5w for qemu-devel@nongnu.org; Fri, 13 Jul 2018 10:55:18 -0400 Received: by mail-wm0-x243.google.com with SMTP id n17-v6so9716154wmh.2 for ; Fri, 13 Jul 2018 07:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=YCsaxkRGsrc+q/QzA/HfUH4EF3M4OdPv9yHu1iaFm4I=; b=LGUtrBC5jb86uWCNByheStrkAvNvxuyxP23M5EAzkXEnnp+44wD1QdvsJKa3ApPhe5 CkEsdYTYlv3Pya8lgpeQwGyZSpJX0Msn5Hpc5rnCFiwAqJCz5WM6qma6lquT1GN47C7Q Y+Aq5hPSWONNFDqHIbYEJcej57KKR75/xJe4HNdk8tPQq+sNAQH6i5TRaT52EICQJirl MyzQeEgoIKIdrFwZTbv6imkCBsWwi2ukP4oRzr89bOQulHBSOP2eCzo6Ygnfemf/UTra 0dO1odNXbY2Op8F8euLfXtMLW21tXTU+zU2nybdYTMo63DOyssB/mhHKrxOw+Cg7+INW LVsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=YCsaxkRGsrc+q/QzA/HfUH4EF3M4OdPv9yHu1iaFm4I=; b=PwZuhs/QvBx6ej0H1LfJBprX4UNgL2IncOqVPyqDzNhgsCHDf096peiYPNp7jC6t72 CYyLyrqRBZWMW+OKHw9QoA2BK45d2PwT/X/OsPRiX1mAKcGl1rx8cYhlEtW+bzq8Wz91 CfMxItfcfDyU76dKqY7Y5lf6sKXZ2Z47eN5iGuM+P9UX1TifZ8aQG4IavVaFMMezX4e4 EjxwMuoRv5vW8p+uqshZ0PAG7WCxvBUDUwq44tLmQ7fti4W1bU3yTzRXWU23+Y1gBXuc uDudt6IBUlPoEo8SekcW0lEohLNJOw0JY9osPIl/RxTW5PmDTYmY5pqq0/FdWjcduYKn tZMA== X-Gm-Message-State: AOUpUlHR0zNv2C2zodYpfAS+90dLIDhTyso1UgzaMR0GKSIKtuK81kQd uSl3TDpGE/blfRQYd++uHVYT2c+vg4Waogbi000= X-Google-Smtp-Source: AAOMgpev3FhgNHwEsX3cZrWNHg/vwFrx0q4pGFuStHIVheY/va5R64PC8Mp0PrOcH+hIifqjHvfMicLzHefxvd50OXY= X-Received: by 2002:a1c:8406:: with SMTP id g6-v6mr3914802wmd.18.1531493716227; Fri, 13 Jul 2018 07:55:16 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:adf:f012:0:0:0:0:0 with HTTP; Fri, 13 Jul 2018 07:55:15 -0700 (PDT) In-Reply-To: <20180710154800.7ea50b73@redhat.com> References: <1528185295-14199-1-git-send-email-slp@redhat.com> <4e35ea24-147d-1b51-fa1b-0f1cc32966e0@redhat.com> <20180710154800.7ea50b73@redhat.com> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Fri, 13 Jul 2018 16:55:15 +0200 Message-ID: To: Igor Mammedov X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: Re: [Qemu-devel] [PATCH] hw/char/serial: Only retry if qemu_chr_fe_write returns 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Paolo Bonzini , QEMU , Sergio Lopez , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hi On Tue, Jul 10, 2018 at 3:48 PM, Igor Mammedov wrote: > On Tue, 5 Jun 2018 11:18:35 +0200 > Paolo Bonzini wrote: > >> On 05/06/2018 09:54, Sergio Lopez wrote: >> > Only retry on serial_xmit if qemu_chr_fe_write returns 0, as this is the >> > only recoverable error. >> > >> > Retrying with any other scenario, in addition to being a waste of CPU >> > cycles, can compromise the Guest stability if by the vCPU issuing the >> > write and the main loop thread are, by chance or explicit pinning, >> > running on the same pCPU. >> > >> > Previous discussion: >> > >> > https://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg06998.html >> > >> > Signed-off-by: Sergio Lopez >> > --- >> > hw/char/serial.c | 2 +- >> > 1 file changed, 1 insertion(+), 1 deletion(-) >> > >> > diff --git a/hw/char/serial.c b/hw/char/serial.c >> > index 605b0d0..6de6c29 100644 >> > --- a/hw/char/serial.c >> > +++ b/hw/char/serial.c >> > @@ -260,7 +260,7 @@ static void serial_xmit(SerialState *s) >> > if (s->mcr & UART_MCR_LOOP) { >> > /* in loopback mode, say that we just received a char */ >> > serial_receive1(s, &s->tsr, 1); >> > - } else if (qemu_chr_fe_write(&s->chr, &s->tsr, 1) != 1 && >> > + } else if (qemu_chr_fe_write(&s->chr, &s->tsr, 1) == 0 && >> > s->tsr_retry < MAX_XMIT_RETRY) { >> > assert(s->watch_tag == 0); >> > s->watch_tag = >> > > Hi Sergio, Paolo, > > it looks like commit > commit 019288bf137183bf3407c9824655b753bfafc99f > Author: Sergio Lopez > Date: Tue Jun 5 03:54:55 2018 -0400 > > hw/char/serial: Only retry if qemu_chr_fe_write returns 0 > > introduced regression wrt 2.12 and broke windows guest remote kernel debug over > serial, where windbg can't connect to target and target hangs when windbg tries > to connect to it. > > Reverting the commit fixes issue > is this a possible solution? diff --git a/hw/char/serial.c b/hw/char/serial.c index cd7d747c68..046c4684ff 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -261,15 +261,20 @@ static void serial_xmit(SerialState *s) if (s->mcr & UART_MCR_LOOP) { /* in loopback mode, say that we just received a char */ serial_receive1(s, &s->tsr, 1); - } else if (qemu_chr_fe_write(&s->chr, &s->tsr, 1) == 0 && - s->tsr_retry < MAX_XMIT_RETRY) { - assert(s->watch_tag == 0); - s->watch_tag = - qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP, - serial_watch_cb, s); - if (s->watch_tag > 0) { - s->tsr_retry++; - return; + } else { + int rc = qemu_chr_fe_write(&s->chr, &s->tsr, 1); + + if ((rc == 0 || + (rc == -1 && (errno == EAGAIN || errno == EINTR))) && + s->tsr_retry < MAX_XMIT_RETRY) { + assert(s->watch_tag == 0); + s->watch_tag = + qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP, + serial_watch_cb, s); + if (s->watch_tag > 0) { + s->tsr_retry++; + return; + } } } s->tsr_retry = 0;