Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp797243ybe; Fri, 13 Sep 2019 06:32:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0KSM5EOcwNraZ8tcujgrSUcJAyKyCppJmb6UnVEP9Teud/UakGgJvDopHTVcq/5uZuz8D X-Received: by 2002:a50:f616:: with SMTP id c22mr2302199edn.235.1568381550770; Fri, 13 Sep 2019 06:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568381550; cv=none; d=google.com; s=arc-20160816; b=gcS26aNG6mos5FO2T3G98l6t3zwrlkmypuG31RMHhOb6U1kAjiMNqFJqimmpvWgmHS Tdsvt02ElvGD4hPqMe2Jgwig4hGw3A7+OokvC7vGjkf66el64GR6FD6hKQTAi8h4kIU0 KLORoIQpXiOK0dF1bFgA3s/UqtgGaHx1CODOg/GawykS4+AXCkjojgqnuqSFRQ9Ce+S7 oTTLTgWuhl9sgYJxI9Nso70oA0DZ5CM16TIfQDp6TgBpdRMT7QmehXNJ4wXSDXSFd4Af R7UZUr84iRL0DRkqUJ8tQsdSv8ayRpVyU3D83YKyo2O6Nuw1pmGz6R0eUjm01ijoBnPG zSug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=Ts30zeudUYSVE2CQ2XBZYPUVLVX2HicZlWuWJTeojWc=; b=WmGXHFtp2u1QeF9JgnzinyPJwRg4yjbVGJjtzXmelCzaKYRYtp5l8p37awLh/hcbmw MHLiB52nH0GFA3YHJIOY4bYGO81pAAVCqw3svJDp+cJNl3gLMHoAGna/hWIhtIhgwId0 FjAjTtJp1whqbwsVGzLV2wjM856yhOCHXjVvHHPqm6U7NpOZcQS/GReMmkIpc3XEZdln /In0hd1Ni3jUPmNkiNxYLSnr7uSGrRqDSpoA84mru49hqigKOWEUCD5kAFvluxBUIcPB YnE6nke5lhGcTB/i2YjFffERYlcxMGwBlLWizCU3DzsUBQSaKxA6bPnTuLuV9gI471lh xqRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q15si14638706eja.36.2019.09.13.06.32.03; Fri, 13 Sep 2019 06:32:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391619AbfIMN1R (ORCPT + 99 others); Fri, 13 Sep 2019 09:27:17 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:34385 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391567AbfIMN0h (ORCPT ); Fri, 13 Sep 2019 09:26:37 -0400 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1i8lam-0000Ir-Cw; Fri, 13 Sep 2019 15:26:28 +0200 From: John Ogness To: Linus Torvalds Cc: Thomas Gleixner , Steven Rostedt , Peter Zijlstra , Petr Mladek , Andrea Parri , Sergey Senozhatsky , Sergey Senozhatsky , Brendan Higgins , Greg Kroah-Hartman , LKML , Theodore Ts'o , Paul Turner , Daniel Vetter , Prarit Bhargava Subject: Re: printk meeting at LPC References: <20190807222634.1723-1-john.ogness@linutronix.de> <20190904123531.GA2369@hirez.programming.kicks-ass.net> <20190905130513.4fru6yvjx73pjx7p@pathway.suse.cz> <20190905143118.GP2349@hirez.programming.kicks-ass.net> <20190905121101.60c78422@oasis.local.home> Date: Fri, 13 Sep 2019 15:26:26 +0200 In-Reply-To: (Thomas Gleixner's message of "Mon, 9 Sep 2019 15:11:52 +0100 (WEST)") Message-ID: <87k1acz5rx.fsf@linutronix.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-09-09, Thomas Gleixner wrote: > printk meeting at LPC Meeting Room - SAFIRA on Tuesday Sept 10. from > 2PM to 3PM. The meeting was very effective in letting us come to decisions on the direction to take. Thanks for the outstanding attendance! It certainly saved hundreds of hours of reading/writing emails! The slides[0] from my printk talk served as a _rough_ basis for the discussion. Here is a summary of the decisions: 1. As a new ringbuffer, the lockless state-based proof of concept posted[1] by Petr Mladek will be used. Since it has far fewer memory barriers in the code, it will be simpler to review. I posted[2] a patch to hack my RFCv4 into a fully functional version of Petr's PoC. So we know it will work. With this, printk() can be called from any context and the message will be put directly into the ringbuffer. 2. A kernel thread will be created for each registered console, each responsible for being the sole printers to their respective consoles. With this, console printing is _fully_ decoupled from printk() callers. 3. Rather than defining emergency _messages_, we define an emergency _state_ where the kernel wants to flush the messages immediately before dying. Unlike oops_in_progress, this state will not be visible to anything outside of the printk infrastructure. 4. When in emergency state, the kernel will use a new console callback write_atomic() to flush the messages in whatever context the CPU is in at that moment. Only consoles that implement the NMI-safe write_atomic() will be able to flush in this state. 5. LOG_CONT message pieces will be stored as individual records in the ringbuffer. They will be "assembled" by the ringbuffer reader (in kernel) before being copied to userspace or printed on the console. Since each record in the ringbuffer has its own sequence number, this has the effect for userspace that sequence numbers will appear to be skipped. (i.e. if there were LOG_CONT pieces with sequence numbers 4, 5, 6, the fully assembled message will appear only as sequence number 6 (and will have the timestamp from the first piece)). 6. A new may-sleep function pr_flush() will be made available to wait for all previously printk'd messages to be output on all consoles before proceeding. For example: pr_cont("Running test ABC... "); pr_flush(); do_test(); pr_cont("PASSED\n"); pr_flush(); 7. The ringbuffer raw data (log_buf) will be simplified to only consist of alignment-padded strings separated by a single unsigned long. All record meta-data (timestamp, loglevel, caller_id, etc.) will move into the record descriptors, which are located in an extra array. The appropriate crash tools will need to be adjusted for this. (FYI: The unsigned long in the string data is the descriptor ID.) 8. A CPU-reentrant spinlock (the so-called cpu-lock) will be used to synchronize/stop the kthreads during emergency state. 9. Support for printk dictionaries will be discontinued. I will look into who is using this and why. If printk dictionaries are important for you, speak up now! (There was also some talk about possibly discontinuing kdb, but that is not directly related to printk. I'm mentioning it here in case anyone wants to pursue that.) If I missed (or misunderstood) anything, please let me know! John Ogness [0] https://www.linuxplumbersconf.org/event/4/contributions/290/attachments/276/463/lpc2019_jogness_printk.pdf [1] https://lkml.kernel.org/r/20190704103321.10022-1-pmladek@suse.com [2] https://lkml.kernel.org/r/87lfvwcssu.fsf@linutronix.de