From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751752AbdH2XuR (ORCPT ); Tue, 29 Aug 2017 19:50:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:38380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751368AbdH2XuQ (ORCPT ); Tue, 29 Aug 2017 19:50:16 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2B7021AF5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Tue, 29 Aug 2017 19:50:13 -0400 From: Steven Rostedt To: Linus Torvalds Cc: Sergey Senozhatsky , 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: <20170829195013.5048dc42@gandalf.local.home> In-Reply-To: References: <20170815025625.1977-1-sergey.senozhatsky@gmail.com> <20170828090521.GA25025@amd> <20170828102830.GA403@jagdpanzerIV.localdomain> <20170828122109.GA532@jagdpanzerIV.localdomain> <20170828124634.GD492@amd> <20170829134048.GA437@jagdpanzerIV.localdomain> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 29 Aug 2017 10:12:22 -0700 Linus Torvalds wrote: > On Tue, Aug 29, 2017 at 10:00 AM, Linus Torvalds > 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