From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751816AbdH2SJ0 (ORCPT ); Tue, 29 Aug 2017 14:09:26 -0400 Received: from smtprelay0145.hostedemail.com ([216.40.44.145]:44602 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751695AbdH2SJZ (ORCPT ); Tue, 29 Aug 2017 14:09:25 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:967:973:988:989:1260:1263:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2525:2553:2560:2563:2682:2685:2740:2828:2859:2898:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4470:5007:7514:7875:8599:8603:8985:9025:10004:10400:10848:11026:11232:11658:11914:12043:12555:12682:12700:12737:12740:12760:12895:13069:13311:13357:13439:14181:14659:14721:21080:21088:21451:21627:30012:30051:30054:30060:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: burst81_17959acffd416 X-Filterd-Recvd-Size: 3458 Message-ID: <1504030160.2040.35.camel@perches.com> Subject: Re: printk: what is going on with additional newlines? From: Joe Perches To: Linus Torvalds , Sergey Senozhatsky , Tejun Heo Cc: Sergey Senozhatsky , Pavel Machek , Petr Mladek , Steven Rostedt , Jan Kara , Andrew Morton , Jiri Slaby , Andreas Mohr , Tetsuo Handa , Linux Kernel Mailing List Date: Tue, 29 Aug 2017 11:09:20 -0700 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> <20170829173314.GA623@tigerII.localdomain> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2017-08-29 at 10:52 -0700, Linus Torvalds wrote: > On Tue, Aug 29, 2017 at 10:33 AM, Sergey Senozhatsky > wrote: > > > > ok. that's something several people asked for -- some sort of buffered > > printk mode; but people don't want to use a buffer allocated on the stack > > (or kmalloc-ed, etc.) to do sprintf() on it and then feed it to printk("%s"), > > because this adds some extra cost: > > I don't like the notion of per-cpu buffers either, because then you > suddenly get atomicity issues, and you really don't want that. > > My preference as a user is actually to just have a dynamically > re-sizable buffer (that's pretty much what I've done in *every* single > user space project I've had in the last decade), but because some > users might have atomicity issues I do suspect that we should just use > a stack buffer. > > And then perhaps say that the buffer size has to be capped at 80 characters. > > Because if you're printing more than 80 characters and expecting it > all to fit on a line, you're doing something else wrong anyway. > > And hide it not as a explicit "char buffer[80]]" allocation, but as a > "struct line_buffer" or similar, so that > > (a) people don't get the line size wrong > > (b) the buffering code can add a few fields for length etc in there too > > Introduce a few helper functions for it: > > init_line_buffer(&buf); > print_line(&buf, fmt, args); > vprint_line(&buf, fmt, vararg); > finish_line(&buf); > > or whatever, and it sounds like it should be pretty easy to use. Mostly true and not a new solution. You'll now need to add &buf to called functions that continue individual line output. Tejun Heo suggested the very similar mprintk back in 2008. http://thread.gmane.org/gmane.linux.ide/27199