From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Date: Mon, 09 Apr 2007 21:23:22 +0000 Subject: Re: [KJ] [PATCH] include KERN_* constant in printk() calls in Message-Id: <20070409212322.GB26692@parisc-linux.org> List-Id: References: <20070409194151.GG4262@traven> In-Reply-To: <20070409194151.GG4262@traven> To: kernel-janitors@vger.kernel.org On Mon, Apr 09, 2007 at 04:02:09PM -0400, Dave Jones wrote: > > --- a/mm/slab.c > > +++ b/mm/slab.c > > @@ -1732,9 +1732,9 @@ static void dump_line(char *data, int offset, int limit) > > error = data[offset + i]; > > bad_count++; > > } > > - printk(" %02x", (unsigned char)data[offset + i]); > > + printk(KERN_ERR " %02x", (unsigned char)data[offset + i]); > > } > > This one is wrong. It's printing a bunch of numbers in a loop, so with your change > it'll print for example... > > KERN_ERR 00 KERN_ERR 01 KERN_ERR 02 KERN_ERR etc etc.. > > you only want the KERN_ERR at the beginning of each line. Another point is that if you have two CPUs calling printk, the output can get interleaved if you don't print everything in one go. If you come across something like this (printing things in a loop), it's a good idea to take a hard look at it and see if you can see a way to do it without the loop so you can print everything on one line. You can see one example of this here: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blobdiff;f=drivers/scsi/scsi_scan.c;h0399406510917111b7580dfc8f3a5f1ce7d95d;hpd92b9b46d9ccc5209103beb59cfb75ccafdb5d;hbOf36718ede26ee2da73f2dae94d71e2b06845fc;hpb8cd5bbfb4763322837cd1f7c621f02ebe22fef I don't see a clean way to fix this one up, to be honest. I think it has to be left as a loop. _______________________________________________ Kernel-janitors mailing list Kernel-janitors@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors