Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp929918pxt; Thu, 5 Aug 2021 15:35:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpQY8/4O4DdGWtKOMiYE23pPTMfNlltl/3T8c8fYNFhSH6epV07KaULTbk/6rp5txiIDki X-Received: by 2002:a92:d944:: with SMTP id l4mr648894ilq.102.1628202934999; Thu, 05 Aug 2021 15:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628202934; cv=none; d=google.com; s=arc-20160816; b=GQ+k0caoFpZQg9WEDbtZC17k+uBifE7pO2FJhXK4jML8so4KzRAGuHY7VDvYttWpr+ aalXLDY0yDLe8mHaPsf98rrZ1ujCgXAzVVpgkj6ENmqHdMehfT7cKLWHS3gvBV7DKRfQ E4ED2oBOyv+X7mkC6O0GyNBRtYlX5YAGA+IyI4pPoPWzJJ2xW494seWjjnPHDEiMHJme /vNAThfmj3/YQJbOCDB78K6EwdfPKeONbqKO8eIuYyFT31QDPzQvmvxwXebkt4Z6+LMH IOH10zeRTdtABfNVMSbrUNrCETZ7YyPNRdYqGrIwN+wLi4qZxrKtTdMsOuJykiiW4CK3 MQQA== 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=xjyShzouPrJcHBbruWtTQutmAQhza4mB7qEDF4um5Mg=; b=TDuEwX90Fyh9iIMlRmy0gKMKU/153e7b4SztNxlbSHkb9EF9kpQN/S3v2euLQiW6lU LW+lxiKfwXKe/gZQWZc4ASLYkT5euspYktYdZFFkh4+T/My3Xar5h5oRaPRM5raySnc0 QZr1mRm/aZ5v6wjeNsL1iZX5Nzp4vAM901pHopvZU8zh7lrhBrrfCcFgi//CyG63PJCi PrG1HDzAnQ2AUCAk65oZNmL4QhoiAJ5iipfeLfGpjwt2xZFG9nvJLH4naV09su02oDY5 6ejC88yHE75AaxRBtct3/hWksctsi6sLiqKhjX/e/015T1oW5A1RlDI1n3hjkZWr6pcx JqZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=HFFKv1lO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z10si7222597ioq.16.2021.08.05.15.35.23; Thu, 05 Aug 2021 15:35:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=HFFKv1lO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242667AbhHEPrp (ORCPT + 99 others); Thu, 5 Aug 2021 11:47:45 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:35250 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242471AbhHEPri (ORCPT ); Thu, 5 Aug 2021 11:47:38 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 05DC41FE69; Thu, 5 Aug 2021 15:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1628178443; 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=xjyShzouPrJcHBbruWtTQutmAQhza4mB7qEDF4um5Mg=; b=HFFKv1lODf3gm58MqBGWAh8qSB3SjD0CWH1FfzIS9Ttb2ITfRIGZdfCH1BtAnoyP4ESIec etQbWzYl+6ASAoafzEiq37hiOIvpPGQL0Maxr2rIGqwGWJypE77o36bBPH1bIEeFynFgxE JPgwV+WeWHfe1PUy2fE9+HyrOT/gvco= Received: from suse.cz (pmladek.udp.ovpn1.prg.suse.de [10.100.224.162]) (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 9259EA3EC0; Thu, 5 Aug 2021 15:47:22 +0000 (UTC) Date: Thu, 5 Aug 2021 17:47:22 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Andrew Morton , Peter Zijlstra , "Paul E. McKenney" , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Jason Wessel , Daniel Thompson , Douglas Anderson , Srikar Dronamraju , "Gautham R. Shenoy" , Chengyang Fan , Christophe Leroy , Bhaskar Chowdhury , Nicholas Piggin , =?iso-8859-1?Q?C=E9dric?= Le Goater , "Gustavo A. R. Silva" , linuxppc-dev@lists.ozlabs.org, kgdb-bugreport@lists.sourceforge.net, Greg Kroah-Hartman , Masahiro Yamada , Nick Desaulniers , Andy Shevchenko , Tetsuo Handa , Vitor Massaru Iha , Sedat Dilek , Changbin Du , Sumit Garg , Cengiz Can , Jiri Slaby , Paul Cercueil , Matthias Brugger , Andrew Jeffery , Christophe JAILLET , kuldip dwivedi , Wang Qing , Andrij Abyzov , Johan Hovold , Eddie Huang , Claire Chang , Hsin-Yi Wang , Zhang Qilong , "Maciej W. Rozycki" , Guenter Roeck , Sergey Senozhatsky , Al Cooper , linux-serial@vger.kernel.org, linux-mips@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH printk v1 00/10] printk: introduce atomic consoles and sync mode Message-ID: References: <20210803131301.5588-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210803131301.5588-1-john.ogness@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2021-08-03 15:18:51, John Ogness wrote: > Hi, > > This is the next part of our printk-rework effort (points 3 and > 4 of the LPC 2019 summary [0]). > > Here the concept of "atomic consoles" is introduced through a > new (optional) write_atomic() callback for console drivers. This > callback must be implemented as an NMI-safe variant of the > write() callback, meaning that it can function from any context > without relying on questionable tactics such as ignoring locking > and also without relying on the synchronization of console > semaphore. > > As an example of how such an atomic console can look like, this > series implements write_atomic() for the 8250 UART driver. > > This series also introduces a new console printing mode called > "sync mode" that is only activated when the kernel is about to > end (such as panic, oops, shutdown, reboot). Sync mode can only > be activated if atomic consoles are available. A system without > registered atomic consoles will be unaffected by this series. > > When in sync mode, the console printing behavior becomes: > > - only consoles implementing write_atomic() will be called > > - printing occurs within vprintk_store() instead of > console_unlock(), since the console semaphore is irrelevant > for atomic consoles I am fine with the new behavior at this stage. It is a quite clear win when (only) the atomic console is used. And it does not make any difference when atomic consoles are disabled. But I am not sure about the proposed terms and implementation. I want to be sure that we are on the right way for introducing console kthreads. Let me try to compare the behavior: 1. before this patchset(): /* printk: store immediately; try all consoles immediately */ int printk(...) { vprintk_store(); if (console_try_lock()) { /* flush pending messages to the consoles */ console_unlock(); } } /* panic: try hard to flush messages to the consoles and avoid deadlock */ void panic() { /* Ignore locks in console drivers */ bust_spinlocks(1); printk("Kernel panic ...); dump_stack(); smp_send_stop(); /* ignore console lock */ console_flush_on_panic(); } 2. after this patchset(): + same as before in normal mode or when there is no atomic console + in panic with atomic console; it modifies the behavior: /* * printk: store immediately; immediately flush atomic consoles; * unsafe consoles are not used anymore; */ int printk(...) { vprintk_store(); flush_atomic_consoles(); } /* panic: no hacks; only atomic consoles are used */ void panic() { printk("Kernel panic ...); dump_stack(); } 3. After introducing console kthread(s): int printk(...) { vprintk_store(); wake_consoles_via_irqwork(); } + in panic: + with atomic console like after this patchset? + without atomic consoles? + during early boot? I guess that we will need another sync mode for the early boot, panic, suspend, kexec, etc.. It must be posible to debug these states even wihtout atomic console and working kthreads. Best Regards, Petr