Re: [PATCH] output the cpu number when printking.

2012-12-23 Thread he, bo
Thanks randy's comments, I will modifiy it.

On Sun, 2012-12-23 at 19:37 -0800, Randy Dunlap wrote:
> On 12/23/12 18:31, he, bo wrote:
> > From: "he, bo" 
> > 
> > We often hit kernel panic issues on SMP machines because processes race
> > on multiple cpu. By adding a new parameter printk.cpu, kernel prints
> > cpu number at printk information line. It’s useful to debug what cpus
> > are racing.
> > 
> > Signed-off-by: he, bo 
> > ---
> >  Documentation/kernel-parameters.txt |4 
> >  kernel/printk.c |   18 --
> >  2 files changed, 20 insertions(+), 2 deletions(-)
> > 
> > diff --git a/Documentation/kernel-parameters.txt 
> > b/Documentation/kernel-parameters.txt
> > index ddd84d6..ccd5266 100644
> > --- a/Documentation/kernel-parameters.txt
> > +++ b/Documentation/kernel-parameters.txt
> > @@ -2378,6 +2378,10 @@ bytes respectively. Such letter suffixes can also be 
> > entirely omitted.
> > printk.time=Show timing data prefixed to each printk message line
> > Format:   (1/Y/y=enable, 0/N/n=disable)
> >  
> > +   printk.cpu= Show cpu data prefixed to each printk message line
> > +   Format:   (1/Y/y=enable, 0/N/n=disable)
> > +   printk.cpu takes effect only when printk.time=y.
> 
> Above line needs to be indented more (beginning under "Format:").
> 
> > +
> > processor.max_cstate=   [HW,ACPI]
> > Limit processor to maximum C-state
> > max_cstate=9 overrides any DMI blacklist limit.
> > diff --git a/kernel/printk.c b/kernel/printk.c
> > index 19c0d7b..873a226 100644
> > --- a/kernel/printk.c
> > +++ b/kernel/printk.c
> > @@ -863,9 +863,14 @@ static bool printk_time;
> >  #endif
> >  module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
> >  
> > +static bool printk_cpu = 1;
> > +module_param_named(cpu, printk_cpu, bool, S_IRUGO | S_IWUSR);
> > +
> >  static size_t print_time(u64 ts, char *buf)
> >  {
> > unsigned long rem_nsec;
> > +   size_t len = 0;
> > +   int this_cpu;
> >  
> > if (!printk_time)
> > return 0;
> > @@ -874,8 +879,17 @@ static size_t print_time(u64 ts, char *buf)
> > return 15;
> >  
> > rem_nsec = do_div(ts, 10);
> > -   return sprintf(buf, "[%5lu.%06lu] ",
> > -  (unsigned long)ts, rem_nsec / 1000);
> > +
> > +   if (printk_cpu) {
> > +   this_cpu = raw_smp_processor_id();
> > +   len = sprintf(buf, "[%5lu.%06lu,%u] ",
> > +  (unsigned long)ts, rem_nsec / 1000, this_cpu);
> > +   } else {
> > +   len = sprintf(buf, "[%5lu.%06lu] ",
> > +  (unsigned long)ts, rem_nsec / 1000);
> > +   }
> > +
> > +   return len;
> >  }
> >  
> >  static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
> > 
> 
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] output the cpu number when printking.

2012-12-23 Thread Randy Dunlap
On 12/23/12 18:31, he, bo wrote:
> From: "he, bo" 
> 
> We often hit kernel panic issues on SMP machines because processes race
> on multiple cpu. By adding a new parameter printk.cpu, kernel prints
> cpu number at printk information line. It’s useful to debug what cpus
> are racing.
> 
> Signed-off-by: he, bo 
> ---
>  Documentation/kernel-parameters.txt |4 
>  kernel/printk.c |   18 --
>  2 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/kernel-parameters.txt 
> b/Documentation/kernel-parameters.txt
> index ddd84d6..ccd5266 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -2378,6 +2378,10 @@ bytes respectively. Such letter suffixes can also be 
> entirely omitted.
>   printk.time=Show timing data prefixed to each printk message line
>   Format:   (1/Y/y=enable, 0/N/n=disable)
>  
> + printk.cpu= Show cpu data prefixed to each printk message line
> + Format:   (1/Y/y=enable, 0/N/n=disable)
> + printk.cpu takes effect only when printk.time=y.

Above line needs to be indented more (beginning under "Format:").

> +
>   processor.max_cstate=   [HW,ACPI]
>   Limit processor to maximum C-state
>   max_cstate=9 overrides any DMI blacklist limit.
> diff --git a/kernel/printk.c b/kernel/printk.c
> index 19c0d7b..873a226 100644
> --- a/kernel/printk.c
> +++ b/kernel/printk.c
> @@ -863,9 +863,14 @@ static bool printk_time;
>  #endif
>  module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
>  
> +static bool printk_cpu = 1;
> +module_param_named(cpu, printk_cpu, bool, S_IRUGO | S_IWUSR);
> +
>  static size_t print_time(u64 ts, char *buf)
>  {
>   unsigned long rem_nsec;
> + size_t len = 0;
> + int this_cpu;
>  
>   if (!printk_time)
>   return 0;
> @@ -874,8 +879,17 @@ static size_t print_time(u64 ts, char *buf)
>   return 15;
>  
>   rem_nsec = do_div(ts, 10);
> - return sprintf(buf, "[%5lu.%06lu] ",
> -(unsigned long)ts, rem_nsec / 1000);
> +
> + if (printk_cpu) {
> + this_cpu = raw_smp_processor_id();
> + len = sprintf(buf, "[%5lu.%06lu,%u] ",
> +(unsigned long)ts, rem_nsec / 1000, this_cpu);
> + } else {
> + len = sprintf(buf, "[%5lu.%06lu] ",
> +(unsigned long)ts, rem_nsec / 1000);
> + }
> +
> + return len;
>  }
>  
>  static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
> 


-- 
~Randy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] output the cpu number when printking.

2012-12-23 Thread he, bo
From: "he, bo" 

We often hit kernel panic issues on SMP machines because processes race
on multiple cpu. By adding a new parameter printk.cpu, kernel prints
cpu number at printk information line. It’s useful to debug what cpus
are racing.

Signed-off-by: he, bo 
---
 Documentation/kernel-parameters.txt |4 
 kernel/printk.c |   18 --
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index ddd84d6..ccd5266 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2378,6 +2378,10 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
printk.time=Show timing data prefixed to each printk message line
Format:   (1/Y/y=enable, 0/N/n=disable)
 
+   printk.cpu= Show cpu data prefixed to each printk message line
+   Format:   (1/Y/y=enable, 0/N/n=disable)
+   printk.cpu takes effect only when printk.time=y.
+
processor.max_cstate=   [HW,ACPI]
Limit processor to maximum C-state
max_cstate=9 overrides any DMI blacklist limit.
diff --git a/kernel/printk.c b/kernel/printk.c
index 19c0d7b..873a226 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -863,9 +863,14 @@ static bool printk_time;
 #endif
 module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
 
+static bool printk_cpu = 1;
+module_param_named(cpu, printk_cpu, bool, S_IRUGO | S_IWUSR);
+
 static size_t print_time(u64 ts, char *buf)
 {
unsigned long rem_nsec;
+   size_t len = 0;
+   int this_cpu;
 
if (!printk_time)
return 0;
@@ -874,8 +879,17 @@ static size_t print_time(u64 ts, char *buf)
return 15;
 
rem_nsec = do_div(ts, 10);
-   return sprintf(buf, "[%5lu.%06lu] ",
-  (unsigned long)ts, rem_nsec / 1000);
+
+   if (printk_cpu) {
+   this_cpu = raw_smp_processor_id();
+   len = sprintf(buf, "[%5lu.%06lu,%u] ",
+  (unsigned long)ts, rem_nsec / 1000, this_cpu);
+   } else {
+   len = sprintf(buf, "[%5lu.%06lu] ",
+  (unsigned long)ts, rem_nsec / 1000);
+   }
+
+   return len;
 }
 
 static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
-- 
1.7.6



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] output the cpu number when printking.

2012-12-23 Thread he, bo
From: he, bo bo...@intel.com

We often hit kernel panic issues on SMP machines because processes race
on multiple cpu. By adding a new parameter printk.cpu, kernel prints
cpu number at printk information line. It’s useful to debug what cpus
are racing.

Signed-off-by: he, bo bo...@intel.com
---
 Documentation/kernel-parameters.txt |4 
 kernel/printk.c |   18 --
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index ddd84d6..ccd5266 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2378,6 +2378,10 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
printk.time=Show timing data prefixed to each printk message line
Format: bool  (1/Y/y=enable, 0/N/n=disable)
 
+   printk.cpu= Show cpu data prefixed to each printk message line
+   Format: bool  (1/Y/y=enable, 0/N/n=disable)
+   printk.cpu takes effect only when printk.time=y.
+
processor.max_cstate=   [HW,ACPI]
Limit processor to maximum C-state
max_cstate=9 overrides any DMI blacklist limit.
diff --git a/kernel/printk.c b/kernel/printk.c
index 19c0d7b..873a226 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -863,9 +863,14 @@ static bool printk_time;
 #endif
 module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
 
+static bool printk_cpu = 1;
+module_param_named(cpu, printk_cpu, bool, S_IRUGO | S_IWUSR);
+
 static size_t print_time(u64 ts, char *buf)
 {
unsigned long rem_nsec;
+   size_t len = 0;
+   int this_cpu;
 
if (!printk_time)
return 0;
@@ -874,8 +879,17 @@ static size_t print_time(u64 ts, char *buf)
return 15;
 
rem_nsec = do_div(ts, 10);
-   return sprintf(buf, [%5lu.%06lu] ,
-  (unsigned long)ts, rem_nsec / 1000);
+
+   if (printk_cpu) {
+   this_cpu = raw_smp_processor_id();
+   len = sprintf(buf, [%5lu.%06lu,%u] ,
+  (unsigned long)ts, rem_nsec / 1000, this_cpu);
+   } else {
+   len = sprintf(buf, [%5lu.%06lu] ,
+  (unsigned long)ts, rem_nsec / 1000);
+   }
+
+   return len;
 }
 
 static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
-- 
1.7.6



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] output the cpu number when printking.

2012-12-23 Thread Randy Dunlap
On 12/23/12 18:31, he, bo wrote:
 From: he, bo bo...@intel.com
 
 We often hit kernel panic issues on SMP machines because processes race
 on multiple cpu. By adding a new parameter printk.cpu, kernel prints
 cpu number at printk information line. It’s useful to debug what cpus
 are racing.
 
 Signed-off-by: he, bo bo...@intel.com
 ---
  Documentation/kernel-parameters.txt |4 
  kernel/printk.c |   18 --
  2 files changed, 20 insertions(+), 2 deletions(-)
 
 diff --git a/Documentation/kernel-parameters.txt 
 b/Documentation/kernel-parameters.txt
 index ddd84d6..ccd5266 100644
 --- a/Documentation/kernel-parameters.txt
 +++ b/Documentation/kernel-parameters.txt
 @@ -2378,6 +2378,10 @@ bytes respectively. Such letter suffixes can also be 
 entirely omitted.
   printk.time=Show timing data prefixed to each printk message line
   Format: bool  (1/Y/y=enable, 0/N/n=disable)
  
 + printk.cpu= Show cpu data prefixed to each printk message line
 + Format: bool  (1/Y/y=enable, 0/N/n=disable)
 + printk.cpu takes effect only when printk.time=y.

Above line needs to be indented more (beginning under Format:).

 +
   processor.max_cstate=   [HW,ACPI]
   Limit processor to maximum C-state
   max_cstate=9 overrides any DMI blacklist limit.
 diff --git a/kernel/printk.c b/kernel/printk.c
 index 19c0d7b..873a226 100644
 --- a/kernel/printk.c
 +++ b/kernel/printk.c
 @@ -863,9 +863,14 @@ static bool printk_time;
  #endif
  module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
  
 +static bool printk_cpu = 1;
 +module_param_named(cpu, printk_cpu, bool, S_IRUGO | S_IWUSR);
 +
  static size_t print_time(u64 ts, char *buf)
  {
   unsigned long rem_nsec;
 + size_t len = 0;
 + int this_cpu;
  
   if (!printk_time)
   return 0;
 @@ -874,8 +879,17 @@ static size_t print_time(u64 ts, char *buf)
   return 15;
  
   rem_nsec = do_div(ts, 10);
 - return sprintf(buf, [%5lu.%06lu] ,
 -(unsigned long)ts, rem_nsec / 1000);
 +
 + if (printk_cpu) {
 + this_cpu = raw_smp_processor_id();
 + len = sprintf(buf, [%5lu.%06lu,%u] ,
 +(unsigned long)ts, rem_nsec / 1000, this_cpu);
 + } else {
 + len = sprintf(buf, [%5lu.%06lu] ,
 +(unsigned long)ts, rem_nsec / 1000);
 + }
 +
 + return len;
  }
  
  static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
 


-- 
~Randy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] output the cpu number when printking.

2012-12-23 Thread he, bo
Thanks randy's comments, I will modifiy it.

On Sun, 2012-12-23 at 19:37 -0800, Randy Dunlap wrote:
 On 12/23/12 18:31, he, bo wrote:
  From: he, bo bo...@intel.com
  
  We often hit kernel panic issues on SMP machines because processes race
  on multiple cpu. By adding a new parameter printk.cpu, kernel prints
  cpu number at printk information line. It’s useful to debug what cpus
  are racing.
  
  Signed-off-by: he, bo bo...@intel.com
  ---
   Documentation/kernel-parameters.txt |4 
   kernel/printk.c |   18 --
   2 files changed, 20 insertions(+), 2 deletions(-)
  
  diff --git a/Documentation/kernel-parameters.txt 
  b/Documentation/kernel-parameters.txt
  index ddd84d6..ccd5266 100644
  --- a/Documentation/kernel-parameters.txt
  +++ b/Documentation/kernel-parameters.txt
  @@ -2378,6 +2378,10 @@ bytes respectively. Such letter suffixes can also be 
  entirely omitted.
  printk.time=Show timing data prefixed to each printk message line
  Format: bool  (1/Y/y=enable, 0/N/n=disable)
   
  +   printk.cpu= Show cpu data prefixed to each printk message line
  +   Format: bool  (1/Y/y=enable, 0/N/n=disable)
  +   printk.cpu takes effect only when printk.time=y.
 
 Above line needs to be indented more (beginning under Format:).
 
  +
  processor.max_cstate=   [HW,ACPI]
  Limit processor to maximum C-state
  max_cstate=9 overrides any DMI blacklist limit.
  diff --git a/kernel/printk.c b/kernel/printk.c
  index 19c0d7b..873a226 100644
  --- a/kernel/printk.c
  +++ b/kernel/printk.c
  @@ -863,9 +863,14 @@ static bool printk_time;
   #endif
   module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
   
  +static bool printk_cpu = 1;
  +module_param_named(cpu, printk_cpu, bool, S_IRUGO | S_IWUSR);
  +
   static size_t print_time(u64 ts, char *buf)
   {
  unsigned long rem_nsec;
  +   size_t len = 0;
  +   int this_cpu;
   
  if (!printk_time)
  return 0;
  @@ -874,8 +879,17 @@ static size_t print_time(u64 ts, char *buf)
  return 15;
   
  rem_nsec = do_div(ts, 10);
  -   return sprintf(buf, [%5lu.%06lu] ,
  -  (unsigned long)ts, rem_nsec / 1000);
  +
  +   if (printk_cpu) {
  +   this_cpu = raw_smp_processor_id();
  +   len = sprintf(buf, [%5lu.%06lu,%u] ,
  +  (unsigned long)ts, rem_nsec / 1000, this_cpu);
  +   } else {
  +   len = sprintf(buf, [%5lu.%06lu] ,
  +  (unsigned long)ts, rem_nsec / 1000);
  +   }
  +
  +   return len;
   }
   
   static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
  
 
 


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/