[go: up one dir, main page]

|
|
Log in / Subscribe / Register

Re: printk: what is going on with additional newlines?

From:  Steven Rostedt <rostedt-AT-goodmis.org>
To:  Linus Torvalds <torvalds-AT-linux-foundation.org>
Subject:  Re: printk: what is going on with additional newlines?
Date:  Tue, 29 Aug 2017 19:50:13 -0400
Message-ID:  <20170829195013.5048dc42@gandalf.local.home>
Cc:  Sergey Senozhatsky <sergey.senozhatsky.work-AT-gmail.com>, Pavel Machek <pavel-AT-ucw.cz>, Sergey Senozhatsky <sergey.senozhatsky-AT-gmail.com>, Petr Mladek <pmladek-AT-suse.com>, Jan Kara <jack-AT-suse.cz>, Andrew Morton <akpm-AT-linux-foundation.org>, Jiri Slaby <jslaby-AT-suse.com>, Andreas Mohr <andi-AT-lisas.de>, Tetsuo Handa <penguin-kernel-AT-i-love.sakura.ne.jp>, Linux Kernel Mailing List <linux-kernel-AT-vger.kernel.org>

On Tue, 29 Aug 2017 10:12:22 -0700
Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Tue, Aug 29, 2017 at 10:00 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > I refuse to help those things. We mis-designed things  
> 
> Actually, let me rephrase that:
> 
> It might actually be a good idea to help those things, by making
> helper functions available that do the marshalling.
> 
> So not calling "printk()" directly, but having a set of simple
> "buffer_print()" functions where each user has its own buffer, and
> then the "buffer_print()" functions will help people do nicely output
> data.
> 
> So if the issue is that people want to print (for example) hex dumps
> one character at a time, but don't want to have each character show up
> on a line of their own, I think we might well add a few functions to
> help dop that.
> 
> But they wouldn't be "printk". They would be the buffering functions
> that then call printk when tyhey have buffered a line.
> 
> That avoids the whole nasty issue with printk - printk wants to show
> stuff early (because _maybe_ it's critical) and printk wants to make
> log records with timestamps and loglevels. And printk has serious
> locking issues that are really nasty and fundamental.
> 
> A private buffer has none of those issues.

What about using the seq_buf*() then?

	struct seq_buf s;

	buf = kmalloc(mysize);
	seq_buf_init(&s, buf, mysize);

	seq_printf(&s,"blah blah %d", bah_blah);
	[...]
	seq_printf(&s, "my last print\n");

	printk("%.*s", s.len, s.buffer);

	kfree(buf);

This is what the NMI "safe" printks basically do.

-- Steve



to post comments


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds