Skip to content

Commit 52aa853

Browse files
JoePerchestorvalds
authored andcommittedSep 10, 2015
kernel/cred.c: remove unnecessary kdebug atomic reads
Commit e0e8173 ("CRED: Add some configurable debugging [try #6]") added the kdebug mechanism to this file back in 2009. The kdebug macro calls no_printk which always evaluates arguments. Most of the kdebug uses have an unnecessary call of atomic_read(&cred->usage) Make the kdebug macro do nothing by defining it with do { if (0) no_printk(...); } while (0) when not enabled. $ size kernel/cred.o* (defconfig x86-64) text data bss dec hex filename 2748 336 8 3092 c14 kernel/cred.o.new 2788 336 8 3132 c3c kernel/cred.o.old Miscellanea: o Neaten the #define kdebug macros while there Signed-off-by: Joe Perches <[email protected]> Cc: David Howells <[email protected]> Cc: James Morris <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2307e1a commit 52aa853

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
 

‎kernel/cred.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@
2020
#include <linux/cn_proc.h>
2121

2222
#if 0
23-
#define kdebug(FMT, ...) \
24-
printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__)
23+
#define kdebug(FMT, ...) \
24+
printk("[%-5.5s%5u] " FMT "\n", \
25+
current->comm, current->pid, ##__VA_ARGS__)
2526
#else
26-
#define kdebug(FMT, ...) \
27-
no_printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__)
27+
#define kdebug(FMT, ...) \
28+
do { \
29+
if (0) \
30+
no_printk("[%-5.5s%5u] " FMT "\n", \
31+
current->comm, current->pid, ##__VA_ARGS__); \
32+
} while (0)
2833
#endif
2934

3035
static struct kmem_cache *cred_jar;

0 commit comments

Comments
 (0)
Please sign in to comment.