Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3258493iog; Mon, 20 Jun 2022 15:26:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vSpIScQ6xtnq6w9AUzIqM6zxBESqHpypfiX/aMQtDITtqHRZP8VqTPCxvq5dcEMPBQw4sK X-Received: by 2002:a17:906:b150:b0:711:c6a5:c5c1 with SMTP id bt16-20020a170906b15000b00711c6a5c5c1mr23329953ejb.177.1655764018864; Mon, 20 Jun 2022 15:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655764018; cv=none; d=google.com; s=arc-20160816; b=tUSdO3Pi7qFbqhT/cusOp+yMtsFQHA7YEW1WrC6NhYVJWbjEuGxVkG8Y+fpSAPp/PQ li4uwFoClzD3y/Ls66VsjGomKrXAWqJ/IRDps3sYM/Y4SQUt+8jaXOLakBNTkDpnxKYW XEU0qFCIFjACB0rl7W7mc8hH1+I79NqIwnNnY3i9tWwqmX7I50VIBC99NME1T/VdHqaO T8xIn6XiO0nVWzklPqQrw81nYSTDxlZEeS5kTYmg0U8+RTh442QlyI1MK/7pNcvHaWPZ 7oCLnkaMzwOT94lshjF2SxWc/r36C2/nAiGwZHhBKJp9VFaRQd2dbO60QSoFJXBKkBaE 0SzQ== 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=PJ0iztHxsK8a+Ha9h5rHbJfy+QtzjyiswzEJIkBJEYg=; b=nAOp1MaaX3gk0D2c51fkpCZ8PK9+pqqxcMvCWH6wShDZMCuv3zrsUIYPumrH9/5Fqw JOf9inFDdF8jeKKQsbi59qtiwC/JR9YQVWBBim95JHVD91VirJwTv/mc01ltD14RIAde 0cS3tx5ULZNM35ZJs1gLmZ4oVe3iA5xbVJDAfy2yQm/XxJ4JWy9CF8YXeK8Wlc/CDXIG qeIKpXqINP/yM42dL1A8psGCLxsKPwAz/Rfnou7e2r9mDWtb3masA+Serv4wc3jxRSvm DH0g/n2foeg3fzFdiUpakqVt49oGuk+ddlRskq39hI05Os0pb6Yz1tEo5EncKIO2bRmp v7Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Lou7oJk0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j18-20020a056402239200b0043583f0f23bsi3538573eda.495.2022.06.20.15.26.34; Mon, 20 Jun 2022 15:26:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Lou7oJk0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242793AbiFTWZK (ORCPT + 99 others); Mon, 20 Jun 2022 18:25:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242768AbiFTWZI (ORCPT ); Mon, 20 Jun 2022 18:25:08 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 340A113E3F for ; Mon, 20 Jun 2022 15:25:07 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 3E74E1F9D0; Mon, 20 Jun 2022 22:25:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655763905; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PJ0iztHxsK8a+Ha9h5rHbJfy+QtzjyiswzEJIkBJEYg=; b=Lou7oJk0l21cmXaZoH5uz/345ApgwxkXV3JrYfjJ3Fxse7kAMVwnYzhoECxQEy7NK1+TbP lvceRmr6MG7ZQUkmE76xbGdfFvw6NMBdnu8FetBVz9b1z5vhSDp0F/ndcTT5qKnxx5WPb5 50+tyeKnw/McWVROCIfEKqCSuUOrSzg= Received: from suse.cz (unknown [10.100.201.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id A38E02C141; Mon, 20 Jun 2022 22:25:04 +0000 (UTC) Date: Tue, 21 Jun 2022 00:25:01 +0200 From: Petr Mladek To: Linus Torvalds Cc: Marek =?iso-8859-1?Q?Beh=FAn?= , John Ogness , Linux Kernel Mailing List , Sergey Senozhatsky , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Jan Kara , Peter Zijlstra Subject: Re: [PATCH] printk/console: Enable console kthreads only when there is no boot console left Message-ID: References: <20220619204949.50d9154d@thinkpad> <87r13kwawb.fsf@jogness.linutronix.de> <20220620112936.48fcb2a4@thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Mon 2022-06-20 14:10:20, Linus Torvalds wrote: > On Mon, Jun 20, 2022 at 10:14 AM Petr Mladek wrote: > > > > The console kthreads uncovered several races in console drivers. > > I really want to make it clear that this was NOT some kind of "races > in drivers". > > Console drivers may very well have intentionally avoided taking locks > for console output, since the printk output was supposed to be > serialized by printk. > > Don't try to make this some kind of "buggy drivers" thing. This is on > printk, not on anything else. OK, I see that uart_console_write() is used by early_serial8250_write() without port->lock. It means that it is racy against serial8250_console_write(). It might cause problems reported by this thread. And you are right that it has never been used in parallel before the kthreads. But I believe that it might cause real problems. serial8250_console_write() takes port->lock to get serialized against other operations on the port. And there might be some when the same port is added as a proper serial console. Today I found that probe_baud() is called from serial8250_console_setup() without port->lock. It does reads and writes. I believe that it might break with the earlycon. Also the commit 589f892ac8ef244e47c5a ("serial: meson: acquire port->lock in startup()") fixes a race between meson_serial_port_write() and meson_uart_startup(), where meson_serial_port_write() is used by both early and proper console driver. The problem was there even without kthreads. They just made it more visible. My colleagues familiar with ARM told me that they heard about boot freezes with early consoles before threads. The kthreads allow to reproduce and fix them. In the end, they make the early consoles more reliable. > Assuming this solves all issues, I'm ok with this approach, but I > really want this to be clearly about printk being buggy, no "blame the > drivers" garbage. > > And if there are other issues coming up, we revert the whole thing entirely. > > Because printk is too important to play games with, and too important > to try to blame drivers. I take printk() really seriously. And I definitely do not want to wave out problems as others problem. I do not want to release 5.19 with broken printk(). But the kthreads solve real bugs where printk() put the system into knees. I want to invest much more time on improving them and fixing related problems. Unfortunately, linux-next was not able to catch the recently reported problems and we were not able to fix them in advance. All the recent fixes were generic and should make printk() with kthreads much more reliable. I can't be sure if it will be enough. I could only say that I am going to fix any new ones. Of course, if people continue reporting problems, we would need to revert it for 5.19. But I would really like to give it another chance later. Best Regards, Petr