Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2341499rdh; Sun, 29 Oct 2023 11:22:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqW4cQwrkDCumkMFEYphOyXDRB4qncaWd1Iyx20zI3R4y2g2Yk4DnweL0A1CTd7l9LTL89 X-Received: by 2002:a05:6358:e488:b0:168:e4d0:a743 with SMTP id by8-20020a056358e48800b00168e4d0a743mr8797858rwb.21.1698603722421; Sun, 29 Oct 2023 11:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698603722; cv=none; d=google.com; s=arc-20160816; b=vpkWTYeY8PGn661wnA7Znz+D25yBo1/n4+lcfs3RxYCGCTd7qNl4bQ0IeYZjAsnthd KfZ7eqgDtBSbQOojaexaW6xqQfixccUIDnRM4dRGuUo5hi7AxpKaqMb61LCjm8z5KRMm pNV4/OvQhCLIkKhCKmZ5qWLK4LzEGMoolKLEB96pkCcQ61aKmf6NUiuBuGxvi4SUjKMQ VJLhs5EkiCfVsVye0aKK/Kr1lBqWjvsMSuWJrUkORCK7J16SK9n1MEmXamZE9zs+U4EK 9g2Jam7IBUAyzpj1Xp/17WZ2FQrJ/zozUbT1qkCJyV2y1bjI4tW8ZLr1hj/iVAw9iNCc WY1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:mime-version :dkim-signature; bh=0K7gdIvXPk68vkSSta81KyHTb3uDVkYkVGmAdrIYgkc=; fh=kqE+fRBHK68RsnWp2Vt25HEsWEdgJ8pszrAhaqoW4+4=; b=Ax2C384ilLMKvhp2+9T1WlAfTqLILLMFiDGOIsXWdjzTsNhcWa5DpjqQl7MdflVuYy zdpi+otDVcTNRYYvrtRxEDklkEQEJ0mEunuBG8mSkhNNeZu/O2iMzg4nNhKLa+GpuMeP 5MNVs2Y+UwmLYPYHW2qKOtCHb4LUKCTYebsCY5xcemFx4YcUj1gIbpmSO98uKitoLeVO DRloTLvGK2g9YI+t5JTpORMUKgN1OwL2Aal/LgJMjITlBn/TKrdHzFA4Wbypc5F3IPaA VVi94GmWXZa+xcn+9zsG74BExYOss1ms9CEcRK4CspgQOPxYwklNDhipVwbw0WBaWqUe tY7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TkiMDHy+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bw30-20020a056a02049e00b005b8de051ac6si2093660pgb.111.2023.10.29.11.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 11:22:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TkiMDHy+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 054528087B46; Sun, 29 Oct 2023 11:22:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229795AbjJ2SVi (ORCPT + 99 others); Sun, 29 Oct 2023 14:21:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbjJ2SVh (ORCPT ); Sun, 29 Oct 2023 14:21:37 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05C80BA; Sun, 29 Oct 2023 11:21:35 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-507bd644a96so5413588e87.3; Sun, 29 Oct 2023 11:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698603693; x=1699208493; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=0K7gdIvXPk68vkSSta81KyHTb3uDVkYkVGmAdrIYgkc=; b=TkiMDHy+GCNhgJpTLIqWSGHWuByzwRNI8lds5ajwizCN0aHH89vDuUYyrnLum9MRtn kQYcoY8OiKRfKSp+tUNhp7Alw+Mr7BgAQr4F6KnTn6i5GT8ITgq+AbJaoQ64bi3WiLJ9 AitrLKnCQ/3th1yJ2CMopr0D0XMeIFWb3S14Y0/mkT/nQkDi+pnEJlK3uh6OWiLdAFd7 OBh7I3JgGk2TWuABzY6hxf4BzeFcHaYxi+4M+4bPaGEq24JwgNWkAj7wlu4+XUlq4NGO CsD7W5pafgIAwTD1JDvjYlJxBHJLrPJcX4bjiM1f3VhvdQicoxKMB8qsjYTG3rYkkJ6c ZgyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698603693; x=1699208493; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=0K7gdIvXPk68vkSSta81KyHTb3uDVkYkVGmAdrIYgkc=; b=tJWtV71PFH4I+pUJVbR7W0lkbnGLD0YmacORrozCat+9DfuvXRT+xMYPVgg/u2MJ7O CUZX8gEyWExUFwAj86bs3uX+0vEtHa/KNuL8SJeIMamCwEVeZL12kCqbfQRal/ibpqyQ fvuiFJaRvaN3rqWK9ezE+ONPv9zC9AksjGX/l9U6XZII/LwdOhAcP+RSDEhlPCwADmve MfE2rIU9dQEk8Sg76TI6fXIte0GmxarRejNHG94E3rW3rU1GxrQKwtt/6Veohy3/+rap k1rYZIF69YbIL1eJbp8tcS5eKDFjgjIzE4viE1bn8l5nSITR4gkVi4CpV6hAWVn6uwej dG7Q== X-Gm-Message-State: AOJu0YwtAvnRpTdb8gcJpLXeddyvGEgIRlDAxZCQu76rMazIabY44K4q cNeLMVC8+yS/wyu7DF0XfWtKMCPnV6FQm0MChFQc0lrP0KY= X-Received: by 2002:a05:6512:249:b0:503:fee:5849 with SMTP id b9-20020a056512024900b005030fee5849mr5762769lfo.53.1698603692931; Sun, 29 Oct 2023 11:21:32 -0700 (PDT) MIME-Version: 1.0 From: ariel marcovitch Date: Sun, 29 Oct 2023 20:21:21 +0200 Message-ID: Subject: Gaps in logs while using usb-serial as a console To: johan@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Sun, 29 Oct 2023 11:22:00 -0700 (PDT) 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?