From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753325AbdIHKSE (ORCPT ); Fri, 8 Sep 2017 06:18:04 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:36064 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751077AbdIHKSD (ORCPT ); Fri, 8 Sep 2017 06:18:03 -0400 Date: Fri, 8 Sep 2017 12:18:01 +0200 From: Pavel Machek To: Sergey Senozhatsky Cc: Joe Perches , Steven Rostedt , Linus Torvalds , 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: <20170908101801.GG18365@amd> 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> <20170830053734.GB432@jagdpanzerIV.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lQSB8Tqijvu1+4Ba" Content-Disposition: inline In-Reply-To: <20170830053734.GB432@jagdpanzerIV.localdomain> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --lQSB8Tqijvu1+4Ba Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed 2017-08-30 14:37:34, Sergey Senozhatsky wrote: > On (08/29/17 19:58), Joe Perches wrote: > > > >=20 > > > > Why? > > > >=20 > > > > What's wrong with a simple printk? > > > > It'd still do a log_store. > > >=20 > > > sure, it will. but in separate logbuf entries, and between two > > > consequent printk calls on the same CPU a lot of stuff can happen: > >=20 > > 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. >=20 > may be :) >=20 > 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 >=20 > /* Print line by line. */ > while (c < end) { > if (*c =3D=3D '\n') { > printk_safe_flush_line(start, c - start + 1); > start =3D ++c; > header =3D true; > continue; > } >=20 > /* Handle continuous lines or missing new line. */ > if ((c + 1 < end) && printk_get_level(c)) { > if (header) { > c =3D printk_skip_level(c); > continue; > } >=20 > printk_safe_flush_line(start, c - start); > start =3D c++; > header =3D true; > continue; > } >=20 > header =3D false; > c++; > } >=20 > except that instead of printk_safe_flush_line() we will call log_store() > and the whole loop will be under logbuf_lock. >=20 > for that to work, we need API to require header/loglevel etc for every > message. so the use case can look like this: >=20 > init_printk_buffer(&buf); > print_line(&buf, KERN_ERR "Oops....\n"); >=20 > print_line(&buf, KERN_ERR "continuation line: foo"); > print_line(&buf, KERN_CONT "bar"); > print_line(&buf, KERN_CONT "baz\n"); > ... >=20 > print_line(&buf, KERN_ERR "....\n"); > ... > print_line(&buf, KERN_ERR "--- end of oops ---\n"); > emit_printk_buffer(&buf); >=20 > so that not only concatenated continuation lines will be handled, > but also more complex things. like backtraces or whatever someone > might want to handle. For oopses... please don't. It is quite important that Oops goes out "as soon as possible". I have seen oopses cut in half, etc... They are still quite helpful. Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --lQSB8Tqijvu1+4Ba Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlmyblkACgkQMOfwapXb+vKBrwCbBcYN+RsvfkQu3sw5VCYmE/ZE yrUAn3BG0MCEhftNUD6i1cpmUfja1jj7 =+DKq -----END PGP SIGNATURE----- --lQSB8Tqijvu1+4Ba--