lkml.org 
[lkml]   [2012]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH_V2 1/2] fix the bug that printk can't support printk(KERN_LEVEL)
From
Date
On Mon, 2012-03-26 at 09:36 +0800, he, bo wrote:
> From: he bo <bo.he@intel.com>
>
> Usually, there is a special scenario that developer wants to
> call printk to just set up a log level (might be transferred
> here as a parameter from upper level), then, later calling
> of printk prints out real string with the same log level
> continuously.
The patch fixes a real issue. See the function.

static void print_trace_address(void *data, unsigned long addr, int reliable)
{
touch_nmi_watchdog();
printk(data); <============= Here is to print the log level only
printk_address(addr, reliable);
}
Without the patch, printk(data) doesn't emit the log level,
so printk_address would use the default log level.

Besides above real issue, developer might write below codes to debug issues.
printk("%s", log_level);
for (i = 0; i < fields; i++) {
printk("one field");
}
I did so years ago and felt weird why the log level was incorrect. :)
>
> Current function vprintk has an issue to support this capability.
> When the whole string in one calling to printk is just a log level,
> it ignores it.
>
> Signed-off-by: he, bo <bo.he@intel.com>
> Reviewed-by: Zhang, Yanmin <yanmin.zhang@intel.com>
> ---
> kernel/printk.c | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/printk.c b/kernel/printk.c
> index b663c2c..473afdb 100644
> --- a/kernel/printk.c
> +++ b/kernel/printk.c
> @@ -909,7 +909,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
> * Copy the output into log_buf. If the caller didn't provide
> * the appropriate log prefix, we insert them here
> */
> - for (; *p; p++) {
> + for (; plen || *p; p++) {
> if (new_text_line) {
> new_text_line = 0;
>
> @@ -920,6 +920,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
> for (i = 0; i < plen; i++)
> emit_log_char(printk_buf[i]);
> printed_len += plen;
> + plen = 0;
> } else {
> /* Add log prefix */
> emit_log_char('<');
> @@ -946,10 +947,10 @@ asmlinkage int vprintk(const char *fmt, va_list args)
> printed_len += tlen;
> }
>
> - if (!*p)
> - break;
> }
>
> + if (!*p)
> + break;
> emit_log_char(*p);
> if (*p == '\n')
> new_text_line = 1;




\
 
 \ /
  Last update: 2012-03-28 05:33    [W:0.125 / U:0.520 seconds]
©2003-2014 Jasper Spaans. Advertise on this site