public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 16/21] kernel/kexec.c: use pr_<level> and add pr_fmt(fmt)
  2009-10-05  1:18 [PATCH 00/21] pr_dbg, pr_fmt Joe Perches
@ 2009-10-05  0:53 ` Joe Perches
  2009-10-05 12:01   ` Eric W. Biederman
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2009-10-05  0:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: kexec, Eric Biederman

Added #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Converted printk(KERN_<level> to pr_<level>(
Added KERN_ERR to allocation failure message

Signed-off-by: Joe Perches <joe@perches.com>
---
 kernel/kexec.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/kernel/kexec.c b/kernel/kexec.c
index f336e21..e805351 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -6,6 +6,8 @@
  * Version 2.  See the file COPYING for more details.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/capability.h>
 #include <linux/mm.h>
 #include <linux/file.h>
@@ -245,13 +247,13 @@ static int kimage_normal_alloc(struct kimage **rimage, unsigned long entry,
 	image->control_code_page = kimage_alloc_control_pages(image,
 					   get_order(KEXEC_CONTROL_PAGE_SIZE));
 	if (!image->control_code_page) {
-		printk(KERN_ERR "Could not allocate control_code_buffer\n");
+		pr_err("Could not allocate control_code_buffer\n");
 		goto out;
 	}
 
 	image->swap_page = kimage_alloc_control_pages(image, 0);
 	if (!image->swap_page) {
-		printk(KERN_ERR "Could not allocate swap buffer\n");
+		pr_err("Could not allocate swap buffer\n");
 		goto out;
 	}
 
@@ -320,7 +322,7 @@ static int kimage_crash_alloc(struct kimage **rimage, unsigned long entry,
 	image->control_code_page = kimage_alloc_control_pages(image,
 					   get_order(KEXEC_CONTROL_PAGE_SIZE));
 	if (!image->control_code_page) {
-		printk(KERN_ERR "Could not allocate control_code_buffer\n");
+		pr_err("Could not allocate control_code_buffer\n");
 		goto out;
 	}
 
@@ -1141,8 +1143,7 @@ static int __init crash_notes_memory_init(void)
 	/* Allocate memory for saving cpu registers. */
 	crash_notes = alloc_percpu(note_buf_t);
 	if (!crash_notes) {
-		printk("Kexec: Memory allocation for saving cpu register"
-		" states failed\n");
+		pr_err("Memory allocation for saving cpu register states failed\n");
 		return -ENOMEM;
 	}
 	return 0;
@@ -1192,8 +1193,7 @@ static int __init parse_crashkernel_mem(char 			*cmdline,
 		if (*cur != ':') {
 			end = memparse(cur, &tmp);
 			if (cur == tmp) {
-				pr_warning("crashkernel: Memory "
-						"value expected\n");
+				pr_warning("crashkernel: Memory value expected\n");
 				return -EINVAL;
 			}
 			cur = tmp;
@@ -1211,7 +1211,7 @@ static int __init parse_crashkernel_mem(char 			*cmdline,
 
 		size = memparse(cur, &tmp);
 		if (cur == tmp) {
-			pr_warning("Memory value expected\n");
+			pr_warning("crashkernel: Memory value expected\n");
 			return -EINVAL;
 		}
 		cur = tmp;
@@ -1234,8 +1234,7 @@ static int __init parse_crashkernel_mem(char 			*cmdline,
 			cur++;
 			*crash_base = memparse(cur, &tmp);
 			if (cur == tmp) {
-				pr_warning("Memory value expected "
-						"after '@'\n");
+				pr_warning("crashkernel: Memory value expected after '@'\n");
 				return -EINVAL;
 			}
 		}
@@ -1473,7 +1472,7 @@ int kernel_kexec(void)
 #endif
 	{
 		kernel_restart_prepare(NULL);
-		printk(KERN_EMERG "Starting new kernel\n");
+		pr_emerg("Starting new kernel\n");
 		machine_shutdown();
 	}
 
-- 
1.6.3.1.10.g659a0.dirty


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 00/21] pr_dbg, pr_fmt
@ 2009-10-05  1:18 Joe Perches
  2009-10-05  0:53 ` [PATCH 16/21] kernel/kexec.c: use pr_<level> and add pr_fmt(fmt) Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2009-10-05  1:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: amd64-microcode, kvm, netdev, kexec, iommu, linux-crypto,
	linux-pm, bonding-devel

One possible long term goal is to stop adding
    #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
to source files to prefix modulename to logging output.

It might be useful to eventually have kernel.h
use a standard #define pr_fmt which includes KBUILD_MODNAME
instead of a blank or empty define.

Perhaps over time, the source modules that use pr_<level>
with prefixes can be converted to use pr_fmt.

If all modules are converted, that will allow the printk
routine to add module/filename/line/offset to the logging
lines using some function similar to dynamic_debug and
substantially reduct object string use by removing the
repeated prefixes.

This patchset does not get to that result.  The patches
right now uses _more_ string space because all logging
messages have unshared prefixes but it may be a useful start.

The patchset strips prefixes from printks and adds pr_fmt to
arch/x86, crypto, kernel, and a few drivers.

It also converts printk(KERN_<level> to pr_<level> in a few files
that already had some pr_<level> uses.

The conversion also generally used long length format strings
in the place of multiple short strings to ease any grep/search.
 
Joe Perches (21):
  include/linux/ dynamic_debug.h kernel.h: Remove KBUILD_MODNAME from dynamic_pr_debug, add #define pr_dbg
  ftrace.c: Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  mtrr: use pr_<level> and pr_fmt
  microcode: use pr_<level> and add pr_fmt
  amd_iommu.c: use pr_<level> and add pr_fmt(fmt)
  es7000_32.c: use pr_<level> and add pr_fmt(fmt)
  arch/x86/kernel/apic/: use pr_<level> and add pr_fmt(fmt)
  mcheck/: use pr_<level> and add pr_fmt(fmt)
  arch/x86/kernel/setup_percpu.c: use pr_<level> and add pr_fmt(fmt)
  arch/x86/kernel/cpu/: use pr_<level> and add pr_fmt(fmt)
  i8254.c: Add pr_fmt(fmt)
  kmmio.c: Add and use pr_fmt(fmt)
  testmmiotrace.c: Add and use pr_fmt(fmt)
  crypto/: use pr_<level> and add pr_fmt(fmt)
  kernel/power/: use pr_<level> and add pr_fmt(fmt)
  kernel/kexec.c: use pr_<level> and add pr_fmt(fmt)
  crypto/async_tx/raid6test.c: use pr_<level> and add pr_fmt(fmt)
  arch/x86/mm/mmio-mod.c: use pr_fmt
  drivers/net/bonding/: : use pr_fmt
  drivers/net/tlan: use pr_<level> and add pr_fmt(fmt)
  drivers/net/tlan.h: Convert printk(KERN_DEBUG to pr_dbg(

 arch/x86/kernel/amd_iommu.c                |   71 ++--
 arch/x86/kernel/apic/apic.c                |   48 ++--
 arch/x86/kernel/apic/apic_flat_64.c        |    5 +-
 arch/x86/kernel/apic/bigsmp_32.c           |    8 +-
 arch/x86/kernel/apic/es7000_32.c           |   12 +-
 arch/x86/kernel/apic/io_apic.c             |  239 ++++++------
 arch/x86/kernel/apic/nmi.c                 |   29 +-
 arch/x86/kernel/apic/numaq_32.c            |   53 ++--
 arch/x86/kernel/apic/probe_32.c            |   18 +-
 arch/x86/kernel/apic/probe_64.c            |    8 +-
 arch/x86/kernel/apic/summit_32.c           |   23 +-
 arch/x86/kernel/apic/x2apic_uv_x.c         |   26 +-
 arch/x86/kernel/cpu/addon_cpuid_features.c |    9 +-
 arch/x86/kernel/cpu/amd.c                  |   26 +-
 arch/x86/kernel/cpu/bugs.c                 |   23 +-
 arch/x86/kernel/cpu/bugs_64.c              |    4 +-
 arch/x86/kernel/cpu/centaur.c              |   12 +-
 arch/x86/kernel/cpu/common.c               |   54 ++--
 arch/x86/kernel/cpu/cpu_debug.c            |    4 +-
 arch/x86/kernel/cpu/cyrix.c                |   12 +-
 arch/x86/kernel/cpu/intel.c                |   14 +-
 arch/x86/kernel/cpu/intel_cacheinfo.c      |   14 +-
 arch/x86/kernel/cpu/mcheck/mce-inject.c    |   20 +-
 arch/x86/kernel/cpu/mcheck/mce.c           |   59 ++--
 arch/x86/kernel/cpu/mcheck/mce_intel.c     |    8 +-
 arch/x86/kernel/cpu/mcheck/p5.c            |   21 +-
 arch/x86/kernel/cpu/mcheck/therm_throt.c   |   21 +-
 arch/x86/kernel/cpu/mcheck/threshold.c     |    7 +-
 arch/x86/kernel/cpu/mcheck/winchip.c       |    8 +-
 arch/x86/kernel/cpu/mtrr/centaur.c         |    4 +-
 arch/x86/kernel/cpu/mtrr/cleanup.c         |   59 ++--
 arch/x86/kernel/cpu/mtrr/generic.c         |   39 +-
 arch/x86/kernel/cpu/mtrr/main.c            |   32 +-
 arch/x86/kernel/cpu/perf_event.c           |   10 +-
 arch/x86/kernel/cpu/perfctr-watchdog.c     |   11 +-
 arch/x86/kernel/cpu/transmeta.c            |   20 +-
 arch/x86/kernel/cpu/vmware.c               |   11 +-
 arch/x86/kernel/ftrace.c                   |    8 +-
 arch/x86/kernel/microcode_amd.c            |    5 +-
 arch/x86/kernel/microcode_core.c           |   23 +-
 arch/x86/kernel/microcode_intel.c          |   47 +--
 arch/x86/kernel/setup_percpu.c             |   13 +-
 arch/x86/kvm/i8254.c                       |   12 +-
 arch/x86/mm/kmmio.c                        |   40 +-
 arch/x86/mm/mmio-mod.c                     |   71 ++--
 arch/x86/mm/testmmiotrace.c                |   29 +-
 crypto/algapi.c                            |    4 +-
 crypto/ansi_cprng.c                        |   39 +-
 crypto/async_tx/async_tx.c                 |    5 +-
 crypto/async_tx/raid6test.c                |   30 +-
 crypto/fips.c                              |    4 +-
 crypto/tcrypt.c                            |   75 ++--
 crypto/testmgr.c                           |  286 ++++++--------
 crypto/xor.c                               |   17 +-
 drivers/net/bonding/bond_3ad.c             |  171 +++++----
 drivers/net/bonding/bond_alb.c             |   38 +--
 drivers/net/bonding/bond_ipv6.c            |   12 +-
 drivers/net/bonding/bond_main.c            |  608 +++++++++++-----------------
 drivers/net/bonding/bond_sysfs.c           |  322 ++++++---------
 drivers/net/tlan.c                         |  135 +++---
 drivers/net/tlan.h                         |    2 +-
 include/linux/dynamic_debug.h              |   13 +-
 include/linux/kernel.h                     |    7 +-
 kernel/kexec.c                             |   21 +-
 kernel/power/hibernate.c                   |   46 +--
 kernel/power/hibernate_nvs.c               |    6 +-
 kernel/power/process.c                     |   29 +-
 kernel/power/snapshot.c                    |   36 +-
 kernel/power/suspend.c                     |   18 +-
 kernel/power/suspend_test.c                |   18 +-
 kernel/power/swap.c                        |   42 +-
 kernel/power/swsusp.c                      |   10 +-
 kernel/power/user.c                        |    8 +-
 73 files changed, 1543 insertions(+), 1749 deletions(-)


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 16/21] kernel/kexec.c: use pr_<level> and add pr_fmt(fmt)
  2009-10-05  0:53 ` [PATCH 16/21] kernel/kexec.c: use pr_<level> and add pr_fmt(fmt) Joe Perches
@ 2009-10-05 12:01   ` Eric W. Biederman
  2009-10-05 17:57     ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Eric W. Biederman @ 2009-10-05 12:01 UTC (permalink / raw)
  To: Joe Perches; +Cc: kexec, linux-kernel

Joe Perches <joe@perches.com> writes:

> Added #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> Converted printk(KERN_<level> to pr_<level>(
> Added KERN_ERR to allocation failure message

I'm dense and I haven't seen the discussions.  What
is the point of adding a prefix string where none exists
into a bunch of printks?

> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  kernel/kexec.c |   21 ++++++++++-----------
>  1 files changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/kernel/kexec.c b/kernel/kexec.c
> index f336e21..e805351 100644
> --- a/kernel/kexec.c
> +++ b/kernel/kexec.c
> @@ -6,6 +6,8 @@
>   * Version 2.  See the file COPYING for more details.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/capability.h>
>  #include <linux/mm.h>
>  #include <linux/file.h>
> @@ -245,13 +247,13 @@ static int kimage_normal_alloc(struct kimage **rimage, unsigned long entry,
>  	image->control_code_page = kimage_alloc_control_pages(image,
>  					   get_order(KEXEC_CONTROL_PAGE_SIZE));
>  	if (!image->control_code_page) {
> -		printk(KERN_ERR "Could not allocate control_code_buffer\n");
> +		pr_err("Could not allocate control_code_buffer\n");
>  		goto out;
>  	}
>  
>  	image->swap_page = kimage_alloc_control_pages(image, 0);
>  	if (!image->swap_page) {
> -		printk(KERN_ERR "Could not allocate swap buffer\n");
> +		pr_err("Could not allocate swap buffer\n");
>  		goto out;
>  	}
>  
> @@ -320,7 +322,7 @@ static int kimage_crash_alloc(struct kimage **rimage, unsigned long entry,
>  	image->control_code_page = kimage_alloc_control_pages(image,
>  					   get_order(KEXEC_CONTROL_PAGE_SIZE));
>  	if (!image->control_code_page) {
> -		printk(KERN_ERR "Could not allocate control_code_buffer\n");
> +		pr_err("Could not allocate control_code_buffer\n");
>  		goto out;
>  	}
>  
> @@ -1141,8 +1143,7 @@ static int __init crash_notes_memory_init(void)
>  	/* Allocate memory for saving cpu registers. */
>  	crash_notes = alloc_percpu(note_buf_t);
>  	if (!crash_notes) {
> -		printk("Kexec: Memory allocation for saving cpu register"
> -		" states failed\n");
> +		pr_err("Memory allocation for saving cpu register states failed\n");
>  		return -ENOMEM;
>  	}
>  	return 0;
> @@ -1192,8 +1193,7 @@ static int __init parse_crashkernel_mem(char 			*cmdline,
>  		if (*cur != ':') {
>  			end = memparse(cur, &tmp);
>  			if (cur == tmp) {
> -				pr_warning("crashkernel: Memory "
> -						"value expected\n");
> +				pr_warning("crashkernel: Memory value expected\n");
>  				return -EINVAL;
>  			}
>  			cur = tmp;
> @@ -1211,7 +1211,7 @@ static int __init parse_crashkernel_mem(char 			*cmdline,
>  
>  		size = memparse(cur, &tmp);
>  		if (cur == tmp) {
> -			pr_warning("Memory value expected\n");
> +			pr_warning("crashkernel: Memory value expected\n");
>  			return -EINVAL;
>  		}
>  		cur = tmp;
> @@ -1234,8 +1234,7 @@ static int __init parse_crashkernel_mem(char 			*cmdline,
>  			cur++;
>  			*crash_base = memparse(cur, &tmp);
>  			if (cur == tmp) {
> -				pr_warning("Memory value expected "
> -						"after '@'\n");
> +				pr_warning("crashkernel: Memory value expected after '@'\n");
>  				return -EINVAL;
>  			}
>  		}
> @@ -1473,7 +1472,7 @@ int kernel_kexec(void)
>  #endif
>  	{
>  		kernel_restart_prepare(NULL);
> -		printk(KERN_EMERG "Starting new kernel\n");
> +		pr_emerg("Starting new kernel\n");
>  		machine_shutdown();
>  	}
>  
> -- 
> 1.6.3.1.10.g659a0.dirty
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 16/21] kernel/kexec.c: use pr_<level> and add pr_fmt(fmt)
  2009-10-05 12:01   ` Eric W. Biederman
@ 2009-10-05 17:57     ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2009-10-05 17:57 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: kexec, linux-kernel

On Mon, 2009-10-05 at 05:01 -0700, Eric W. Biederman wrote:
> Joe Perches <joe@perches.com> writes:
> > Added #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > Converted printk(KERN_<level> to pr_<level>(
> > Added KERN_ERR to allocation failure message
> I'm dense and I haven't seen the discussions.  What
> is the point of adding a prefix string where none exists
> into a bunch of printks?

Hi Eric.

There have been a few messages on lkml with little comment,
so I thought I'd get a few more by submitting some patches.

There is a [0/21] message that you might have received directly.
http://lkml.org/lkml/2009/10/4/198

I believe these are some of the +/-'s of each approach:
(copy/pasted from an earlier response)

Current:

o Allows some messages to not have a prefix at all
o Prefixes can vary inside a specific compilation unit

Proposed:

o Consistent, smaller source code, with no typos
  for instance: acpi/apic typos were found/fixed
                kernel/power had messages without PM:
                mce used "MCE: " and "mce: " prefixes
o Compatible with KMSG_COMPONENT
o All logging messages should have a prefix so
  it could be easier to grep/categorize logs
o Future:
  - Doesn't require each compilation unit to #define pr_fmt
  - Smaller objects without duplicated prefixes
  - Extensible via some dynamic_debug like mechanism
    to hide or show modname/__func__/offset without
    significant overhead or any increase in object size
    (printk would emit the prefix via some insertion
     mechanism after "<level>")



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-10-05 17:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-05  1:18 [PATCH 00/21] pr_dbg, pr_fmt Joe Perches
2009-10-05  0:53 ` [PATCH 16/21] kernel/kexec.c: use pr_<level> and add pr_fmt(fmt) Joe Perches
2009-10-05 12:01   ` Eric W. Biederman
2009-10-05 17:57     ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox