Skip to contentSkip to conversation

lib/debugobjects.c: convert printk to pr_foo()

PATCH Superseded Fabian Frederick 2 participants 6 messages May 24, 2014 – May 28, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 lib/debugobjects.c: convert printk to pr_foo()

Convert all except KERN_DEBUG

Cc Josh Triplett <[email protected]>
Cc Andrew Morton <[email protected]>
---
 lib/debugobjects.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
lib/debugobjects.c +5 -7
index e0731c3..ea4c737 100644
@@ -218,7 +218,7 @@ static void debug_objects_oom(void)
 	unsigned long flags;
 	int i;
 
-	printk(KERN_WARNING "ODEBUG: Out of memory. ODEBUG disabled\n");
+	pr_warn("ODEBUG: Out of memory. ODEBUG disabled\n");
 
 	for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {
 		raw_spin_lock_irqsave(&db->lock, flags);
@@ -292,11 +292,9 @@ static void debug_object_is_on_stack(void *addr, int onstack)
 
 	limit++;
 	if (is_on_stack)
-		printk(KERN_WARNING
-		       "ODEBUG: object is on stack, but not annotated\n");
+		pr_warn("ODEBUG: object is on stack, but not annotated\n");
 	else
-		printk(KERN_WARNING
-		       "ODEBUG: object is not on stack, but annotated\n");
+		pr_warn("ODEBUG: object is not on stack, but annotated\n");
 	WARN_ON(1);
 }
 
@@ -985,7 +983,7 @@ static void __init debug_objects_selftest(void)
 	if (check_results(&obj, ODEBUG_STATE_NONE, ++fixups, ++warnings))
 		goto out;
 #endif
-	printk(KERN_INFO "ODEBUG: selftest passed\n");
+	pr_info("ODEBUG: selftest passed\n");
 
 out:
 	debug_objects_fixups = oldfixups;
@@ -1090,7 +1088,7 @@ void __init debug_objects_mem_init(void)
 		debug_objects_enabled = 0;
 		if (obj_cache)
 			kmem_cache_destroy(obj_cache);
-		printk(KERN_WARNING "ODEBUG: out of memory.\n");
+		pr_warn("ODEBUG: out of memory.\n");
 	} else
 		debug_objects_selftest();
 }
Signature · 1 line
1.8.4.5
Reviewed-by on v1 1/4
#1 lore raw
Quoted 1 line · Fabian Frederick

Convert all except KERN_DEBUG

Why not KERN_DEBUG?

Quoted 3 lines
Cc Josh Triplett <[email protected]>
Cc Andrew Morton <[email protected]>
Quoted 51 lines
 lib/debugobjects.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
lib/debugobjects.c +5 -7
index e0731c3..ea4c737 100644
@@ -218,7 +218,7 @@ static void debug_objects_oom(void)
 	unsigned long flags;
 	int i;
 
-	printk(KERN_WARNING "ODEBUG: Out of memory. ODEBUG disabled\n");
+	pr_warn("ODEBUG: Out of memory. ODEBUG disabled\n");
 
 	for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {
 		raw_spin_lock_irqsave(&db->lock, flags);
@@ -292,11 +292,9 @@ static void debug_object_is_on_stack(void *addr, int onstack)
 
 	limit++;
 	if (is_on_stack)
-		printk(KERN_WARNING
-		       "ODEBUG: object is on stack, but not annotated\n");
+		pr_warn("ODEBUG: object is on stack, but not annotated\n");
 	else
-		printk(KERN_WARNING
-		       "ODEBUG: object is not on stack, but annotated\n");
+		pr_warn("ODEBUG: object is not on stack, but annotated\n");
 	WARN_ON(1);
 }
 
@@ -985,7 +983,7 @@ static void __init debug_objects_selftest(void)
 	if (check_results(&obj, ODEBUG_STATE_NONE, ++fixups, ++warnings))
 		goto out;
 #endif
-	printk(KERN_INFO "ODEBUG: selftest passed\n");
+	pr_info("ODEBUG: selftest passed\n");
 
 out:
 	debug_objects_fixups = oldfixups;
@@ -1090,7 +1088,7 @@ void __init debug_objects_mem_init(void)
 		debug_objects_enabled = 0;
 		if (obj_cache)
 			kmem_cache_destroy(obj_cache);
-		printk(KERN_WARNING "ODEBUG: out of memory.\n");
+		pr_warn("ODEBUG: out of memory.\n");
 	} else
 		debug_objects_selftest();
 }
Signature · 1 line
1.8.4.5
#2 lore raw
Quoted 4 lines · On Sat, 24 May 2014 14:53:22 -0700 Josh Triplett <[email protected]> wrote:
Quoted 1 line · Fabian Frederick

Convert all except KERN_DEBUG

Why not KERN_DEBUG?

printk(KERN_DEBUG can't be converted to pr_debug the same way as other printk.

#3 lore raw
Quoted 8 lines · Fabian Frederick
Quoted 4 lines · On Sat, 24 May 2014 14:53:22 -0700 Josh Triplett <[email protected]> wrote:
Quoted 1 line · Fabian Frederick

Convert all except KERN_DEBUG

Why not KERN_DEBUG?

printk(KERN_DEBUG can't be converted to pr_debug the same way as other printk.

True, but I don't see any obvious reason why that prevents you from converting them. More importantly, though, you should explain for the benefit of the changelog.

- Josh Triplett

#4 lore raw
Quoted 5 lines · On Sat, 24 May 2014 20:40:43 -0700 Josh Triplett <[email protected]> wrote:
Quoted 4 lines · Fabian Frederick
Quoted 1 line · On Sat, 24 May 2014 14:53:22 -0700 Josh Triplett <[email protected]> wrote:

On Sat, May 24, 2014 at 03:06:08PM +0200, Fabian Frederick wrote:

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Convert all except KERN_DEBUG

Why not KERN_DEBUG?

printk(KERN_DEBUG can't be converted to pr_debug the same way as other printk.

True, but I don't see any obvious reason why that prevents you from converting them. More importantly, though, you should explain for the benefit of the changelog.

There's no documentation yet in mainline for this but in linux-next:
commit 8ce2658fc31bb7

I can submit one more patch with pr_debug conversion using #define DEBUG
or compilation -DDEBUG

Fabian

Quoted 2 lines

- Josh Triplett

#5 lore raw
Quoted 17 lines · Fabian Frederick
Quoted 5 lines · On Sat, 24 May 2014 20:40:43 -0700 Josh Triplett <[email protected]> wrote:
Quoted 4 lines · Fabian Frederick
Quoted 1 line · On Sat, 24 May 2014 14:53:22 -0700 Josh Triplett <[email protected]> wrote:

On Sat, May 24, 2014 at 03:06:08PM +0200, Fabian Frederick wrote:

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Convert all except KERN_DEBUG

Why not KERN_DEBUG?

printk(KERN_DEBUG can't be converted to pr_debug the same way as other printk.

True, but I don't see any obvious reason why that prevents you from converting them. More importantly, though, you should explain for the benefit of the changelog.

Quoted 5 lines

There's no documentation yet in mainline for this but in linux-next:
commit 8ce2658fc31bb7

I can submit one more patch with pr_debug conversion using #define DEBUG
or compilation -DDEBUG

Definitely keep it as a separate patch, but I don't think you should define DEBUG by default; just let people turn it on if desired, and leave it out otherwise. There's only a single KERN_DEBUG printk in this driver, and it seems fine to just convert to pr_debug so it gets left out of normal builds.

- Josh Triplett