Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2544952rdh; Sun, 29 Oct 2023 23:22:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWolL6uUJMVXAEJSwYgsePhNolhPhOovzqReNORgn++H8x/cybCJMbvNzHY+2/baXzTU2P X-Received: by 2002:a17:902:f214:b0:1cc:32df:427a with SMTP id m20-20020a170902f21400b001cc32df427amr5034045plc.27.1698646948028; Sun, 29 Oct 2023 23:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698646948; cv=none; d=google.com; s=arc-20160816; b=pZnfOXQ3rdukRxiF0/1GDWAHNfGEWLEPyFf+7gA6hpHX+nx9WdN9VsyRhxA350yEBY ec9j7WGUudcQmvw0d5Vy+wzd2NOF5/MVu/H/IvtxoS0GDr1PF8KBrBWlfNheQ8DMLH6Z w284cHPP+Pb1DTnsmhOG+iDAKLoQDCjYFcg22v3qYYgYFzFEd4u03LAaX44v+oilZsES z0L2gXpIBUHmZ0194/O9UUq0nNm/b4tlWKBILrUoNkUjHdv742O7F2eAbxwPUWGbW/on VyRJoJ5aMOgXzjA0mEV1afcbe3j47nxpO5gNyv9C6gVNE+Q1LN3+lwyi8ST8fhflnq2P BE+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Q1VIEdzhKncO5mDDEIT7auhVMFDgAmrQckPhIhcK1V8=; fh=H5CgL2BDC6Lm4WQFZd/57RJDG4LR7xTIzvZNptOS2dI=; b=yvhRuHI7fSO+8YqA8ruazgJmU9KucEUZvdjbF1jNRjg1yE1r9BLz+VZhSrC17WVL+o KpHdlpd1ddsRhfSfWrrx0a1FLp1WFquDCIx8tP5LqCJCZGNp8MkBJKdl5Jz/31FdFbn+ 0xAobOep/d/Fx0HVEIAebOBLTe5FSvkPJOZ/u+nheCwFsCghKOLIEFe/hlbvTrAmgwpC YkKG2+If0RTOS4Yqzxz6fPzFSaG4NA5TcuA+Wrccu1v6Ozrq0Wf7+Jpm0m5OTSG1DWVQ uf0KlBhpr4+9qvZ8/0K3eIH5suxUJKh6S+QclHI9fOWJgPL4lSgY31NYskXwldtXUT+4 x+fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K3vmFdX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id j2-20020a170902da8200b001cc2f9d6a66si3421683plx.514.2023.10.29.23.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 23:22:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K3vmFdX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 093D080AEB06; Sun, 29 Oct 2023 23:22:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231393AbjJ3GWY (ORCPT + 99 others); Mon, 30 Oct 2023 02:22:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbjJ3GWX (ORCPT ); Mon, 30 Oct 2023 02:22:23 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49A279C for ; Sun, 29 Oct 2023 23:22:21 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EDAFC433C7; Mon, 30 Oct 2023 06:22:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698646940; bh=x/c6I6OK3ZtUw/+wssnpJw6q8FJ41rWL8uUeOHkfaj8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=K3vmFdX2YU/7WEbMZLogqJFTV7sa39AcFoGyadIjGmAACSONDkCyblUwz2G0OaNqD xVABimG3FDvyBCi8S5NxL8X8SZbxlIeLLLS+kEIraqjBrZXq1e6CHactgUfU/Cmo9w j6Le6jXmRL7+LzGO9+n7IKx7Z85Y2J7cPiSQTW7I= Date: Mon, 30 Oct 2023 07:22:12 +0100 From: Greg KH To: ariel marcovitch Cc: johan@kernel.org, linux-usb@vger.kernel.org, Linux Kernel Mailing List Subject: Re: Gaps in logs while using usb-serial as a console Message-ID: <2023103052-unpeeled-calibrate-ae48@gregkh> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 29 Oct 2023 23:22:27 -0700 (PDT) On Sun, Oct 29, 2023 at 08:21:21PM +0200, ariel marcovitch wrote: > Greetings! > > While using a usb-serial device as console, I've noticed some > significant gaps in the kernel logs it receives. > > The problem can be reproduced in qemu like this (the kernel is a > x86_64_defconfig with usb-serial enabled and with the ftdi_sio driver > enabled): > qemu-system-x86_64 -m 4G -kernel arch/x86_64/boot/bzImage -usb -device > usb-serial,chardev=ser -chardev pty,id=ser -append 'console=ttyUSB0' > (this will create a `pts` device that will connect to the other end of > the emulated usb-serial) > > Then the logs look something like this: > [ 1.006459] SELinux: Initializing. > [ 1.011620] Mount-cache hash table entries: 8192 (order: 4, 65536 > bytes, li[ 2.315341] ACPI: \_SB_.LNKD: Enabled at IRQ 11 > > This probably happens because of the code in > `usb_serial_generic_write` which tries to insert the data into the > fifo: > count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock); > Because added indications for when the result is less than expected > and it showed significant losses. > The return value is silently ignored in `usb_console_write` > Also making the fifo bigger in `setup_port_bulk_out` helped (I made it > 10 times bigger and there were no losses) > > The reason so much data is written at a short time is because > usb-serial is initialized rather late, and when it is registered as a > console, all the logs until this point are written to it. > > I'm not sure what the solution should be. Maybe we need to check > whether the write in `console_emit_next_record` was successful and not > increase the seq counter in this case. > > Any suggestions? Please realize that usb-serial console was the result of me loosing a drunken bet. It's amazing it works at all. For "fake" devices like this, that use the generic usb-serial code, yes, you will have overruns and other problems, that's just part of how it works (i.e. not well.) For something like qemu, please use a real console, like the serial port (i.e. a fake serial port), not the fake usb-serial port. So this is "working as designed" in that it wasn't designed at all and again, it is a miracle any data is flowing there at all :) sorry, greg k-h