From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752006AbdH3C6K (ORCPT ); Tue, 29 Aug 2017 22:58:10 -0400 Received: from smtprelay0018.hostedemail.com ([216.40.44.18]:36747 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751318AbdH3C6G (ORCPT ); Tue, 29 Aug 2017 22:58:06 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2692:2693:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4250:4321:4605:5007:6742:10004:10400:10848:11026:11232:11473:11658:11914:12043:12296:12438:12740:12760:12895:13161:13229:13439:14659:14721:21080:21088:21433:21627:30054:30060:30075: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:1,LUA_SUMMARY:none X-HE-Tag: pies85_807a559f7d120 X-Filterd-Recvd-Size: 4260 Message-ID: <1504061881.2786.11.camel@perches.com> Subject: Re: printk: what is going on with additional newlines? From: Joe Perches To: Sergey Senozhatsky Cc: Steven Rostedt , Linus Torvalds , Pavel Machek , Sergey Senozhatsky , Petr Mladek , Jan Kara , Andrew Morton , Jiri Slaby , Andreas Mohr , Tetsuo Handa , Linux Kernel Mailing List Date: Tue, 29 Aug 2017 19:58:01 -0700 In-Reply-To: <20170830024703.GA17175@jagdpanzerIV.localdomain> References: <20170828124634.GD492@amd> <20170829134048.GA437@jagdpanzerIV.localdomain> <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> 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 Wed, 2017-08-30 at 11:47 +0900, Sergey Senozhatsky wrote: > On (08/29/17 19:31), Joe Perches wrote: > [..] > > > the idea is not to do printk() on that seq buffer at all, but to > > > log_store(), atomically, seq buffer messages > > > > > > spin_lock(&logbuf_lock) > > > while (offset < seq_buffer->len) { > > > ... > > > log_store(seq->buffer + offset); > > > ... > > > } > > > spin_unlock(&logbuf_unlock) > > > > 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. One use case already in place with seq_buf_init is in drivers/clk/tegra/clk-bpmp.c Basically, it's static void tegra_bpmp_clk_info_dump(struct tegra_bpmp *bpmp, const char *level, const struct tegra_bpmp_clk_info *info) { const char *prefix = ""; struct seq_buf buf; unsigned int i; char flags[64]; seq_buf_init(&buf, flags, sizeof(flags)); if (info->flags) seq_buf_printf(&buf, "("); if (info->flags & TEGRA_BPMP_CLK_HAS_MUX) { seq_buf_printf(&buf, "%smux", prefix); prefix = ", "; } if ((info->flags & TEGRA_BPMP_CLK_HAS_SET_RATE) == 0) { seq_buf_printf(&buf, "%sfixed", prefix); prefix = ", "; } if (info->flags & TEGRA_BPMP_CLK_IS_ROOT) { seq_buf_printf(&buf, "%sroot", prefix); prefix = ", "; } if (info->flags) seq_buf_printf(&buf, ")"); [...] dev_printk(level, bpmp->dev, " flags: %lx %s\n", info->flags, flags); so that the dev_printk is simply emitting a buffer from concatenated strings via the seq_buf_printf uses. The other use case would be an entire printk buffer all at once. ala: seq_buf_init(seq, buf, sizeof(buf)); seq_buf_printf(&buf, "KERN_ fmt...", args...) for (i = 0; i < bar; i++) seq_buf_printf(&buf, fmt, ...) seq_buf_printk(&buf); or: seq_buf_init(seq, buf, sizeof(buf)); seq_buf_printf(&buf, fmt, args...) for (i = 0; i < bar; i++) seq_buf_printf(&bu f, fmt, args...) seq_buf_printk(&buf, KERN_); I can't think of another use case. Can you?