From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751358AbdH1Mqk (ORCPT ); Mon, 28 Aug 2017 08:46:40 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:32953 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751236AbdH1Mqi (ORCPT ); Mon, 28 Aug 2017 08:46:38 -0400 Date: Mon, 28 Aug 2017 14:46:34 +0200 From: Pavel Machek To: Sergey Senozhatsky Cc: Sergey Senozhatsky , Petr Mladek , Steven Rostedt , Jan Kara , Andrew Morton , Jiri Slaby , Andreas Mohr , Tetsuo Handa , linux-kernel@vger.kernel.org Subject: Re: printk: what is going on with additional newlines? Message-ID: <20170828124634.GD492@amd> References: <20170815025625.1977-1-sergey.senozhatsky@gmail.com> <20170828090521.GA25025@amd> <20170828102830.GA403@jagdpanzerIV.localdomain> <20170828122109.GA532@jagdpanzerIV.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="hoZxPH4CaxYzWscb" Content-Disposition: inline In-Reply-To: <20170828122109.GA532@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 --hoZxPH4CaxYzWscb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! On Mon 2017-08-28 21:21:09, Sergey Senozhatsky wrote: > On (08/28/17 19:28), Sergey Senozhatsky wrote: > > On (08/28/17 11:05), Pavel Machek wrote: > > > Hi! > > >=20 > > > In 4.13-rc, printk("foo"); printk("bar"); seems to produce > > > foo\nbar. That's... quite surprising/unwelcome. What is going on > > > there? Are timestamps responsible? > >=20 > > well, one thing we know for sure it is not related to this patch set ;) > >=20 > >=20 > > does any of the below patches fix the problem for you? > >=20 > > basically it sets up the rule -- if we don't have LOG_NEWLINE lflags > > then we enforce LOG_CONT. >=20 > [..] >=20 > > @@ -1670,7 +1670,9 @@ static size_t log_output(int facility, int level,= enum log_flags lflags, const c > > * write from the same process, try to add it to the buffer. > > */ > > if (cont.len) { > > if (cont.owner =3D=3D current && (lflags & LOG_CONT)) { >=20 >=20 > on the other hand... I don't think I like that check at all. > so I *probably* want to change it to -- !LOG_NEWLINE messages of the > same loglevel AND from the same task are getting concatenated. > a message with LOG_NEWLINE flushes the cont buffer. Looks good to me. > for example: >=20 > printk("foo"); printk("foo"); printk("bar\n"); This behaviour is important for me... and this sounds ok. > printk("buz"); printk("buz"); printk("buz"); pr_info("INFO msg\n"); > printk("buz"); printk("buz"); printk("buz"); pr_err("ERR msg\n"); > printk(KERN_CONT"foo"); printk(KERN_CONT"foo"); printk(KERN_CONT"b= ar\n"); > printk(KERN_CONT"foo"); printk(KERN_CONT"foo"); printk(KERN_ERR"ba= r\n"); > printk(KERN_CONT"foo"); printk(KERN_ERR"foo err"); printk(KERN_ERR= "bar err\n"); > >=20 > for instance, > printk(KERN_ERR"foo err"); printk(KERN_ERR"bar err\n"); >=20 > should produce "foo errbar err\n". from the same task and of > the same loglevel, no new line. must be cont messages with a missing > KERN_CONT. right? Not sure. Historically it produce foo err<9>bar err\n. Concatening is probably okay. > how about something like this? Umm.. No? printk(KERN_INFO "foo"); printk(KERN_CONT "bar\n"); should produce "foobar\n", right? Will not your patch insert newline there? Pavel > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index fc47863f629c..675febf84dc8 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -1670,10 +1670,9 @@ static size_t log_output(int facility, int level, = enum log_flags lflags, const c > * write from the same process, try to add it to the buffer. > */ > if (cont.len) { > - if (cont.owner =3D=3D current && (lflags & LOG_CONT)) { > + if (cont.owner =3D=3D current && cont.level =3D=3D level) > if (cont_add(facility, level, lflags, text, text_len)) > return text_len; > - } > /* Otherwise, make sure it's flushed */ > cont_flush(); > } > =20 --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --hoZxPH4CaxYzWscb Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlmkEKoACgkQMOfwapXb+vL2LgCcCLISeln+bkd7j/QZpZ1CxNfC fmcAn2RJF1bFOqWNyDWDVPaCtoSy6SsL =iWXp -----END PGP SIGNATURE----- --hoZxPH4CaxYzWscb--