From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750890AbdH3FfN (ORCPT ); Wed, 30 Aug 2017 01:35:13 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:36825 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750756AbdH3FfL (ORCPT ); Wed, 30 Aug 2017 01:35:11 -0400 Date: Wed, 30 Aug 2017 14:37:34 +0900 From: Sergey Senozhatsky To: Joe Perches Cc: Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Pavel Machek , Sergey Senozhatsky , Petr Mladek , Jan Kara , Andrew Morton , Jiri Slaby , Andreas Mohr , Tetsuo Handa , Linux Kernel Mailing List Subject: Re: printk: what is going on with additional newlines? Message-ID: <20170830053734.GB432@jagdpanzerIV.localdomain> References: <20170829195013.5048dc42@gandalf.local.home> <20170830010348.GB654@jagdpanzerIV.localdomain> <20170829211046.74644c8a@gandalf.local.home> <1504057959.2786.4.camel@perches.com> <20170830022528.GA17968@jagdpanzerIV.localdomain> <1504060296.2786.8.camel@perches.com> <20170830024703.GA17175@jagdpanzerIV.localdomain> <1504061881.2786.11.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1504061881.2786.11.camel@perches.com> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (08/29/17 19:58), Joe Perches wrote: > > > > > > Why? > > > > > > What's wrong with a simple printk? > > > It'd still do a log_store. > > > > sure, it will. but in separate logbuf entries, and between two > > consequent printk calls on the same CPU a lot of stuff can happen: > > I think you don't quite understand how this would work. > The idea is that the entire concatenated bit would be emitted > in one go. may be :) I was thinking about the way to make it work in similar way with printk-safe/printk-nmi. basically seq buffer should hold both continuation and "normal" lines, IMHO. when we emit the buffer we do something like this /* Print line by line. */ while (c < end) { if (*c == '\n') { printk_safe_flush_line(start, c - start + 1); start = ++c; header = true; continue; } /* Handle continuous lines or missing new line. */ if ((c + 1 < end) && printk_get_level(c)) { if (header) { c = printk_skip_level(c); continue; } printk_safe_flush_line(start, c - start); start = c++; header = true; continue; } header = false; c++; } except that instead of printk_safe_flush_line() we will call log_store() and the whole loop will be under logbuf_lock. for that to work, we need API to require header/loglevel etc for every message. so the use case can look like this: init_printk_buffer(&buf); print_line(&buf, KERN_ERR "Oops....\n"); print_line(&buf, KERN_ERR "continuation line: foo"); print_line(&buf, KERN_CONT "bar"); print_line(&buf, KERN_CONT "baz\n"); ... print_line(&buf, KERN_ERR "....\n"); ... print_line(&buf, KERN_ERR "--- end of oops ---\n"); emit_printk_buffer(&buf); so that not only concatenated continuation lines will be handled, but also more complex things. like backtraces or whatever someone might want to handle. -ss