diff options
author | Joe Perches <joe@perches.com> | 2015-06-24 19:54:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-24 20:49:39 -0400 |
commit | 7c2bd2f930aefbc93b90140fa37fa2547728c84c (patch) | |
tree | 64fa81a5a6e7803231fc2be91e3f08d2c5d9b676 | |
parent | 5286d20c4eb7b0c29217f8756652609df74f5489 (diff) |
ocfs2: reduce object size of mlog uses
Using a function for __mlog_printk instead of a macro reduces the object
size of built-in.o by about 190KB, or ~18% overall (x86-64 defconfig
with all ocfs2 options)
$ size fs/ocfs2/built-in.o*
text data bss dec hex filename
870954 118471 134408 1123833 1125f9 fs/ocfs2/built-in.o,new
1064081 118071 134408 1316560 1416d0 fs/ocfs2/built-in.o.old
Miscellanea:
- Move the used-once __mlog_cpu_guess statement expression macro to the
masklog.c file above the use in __mlog_printk function
- Simplify the mlog macro moving the and/or logic and level code into
__mlog_printk
[akpm@linux-foundation.org: export __mlog_printk() to other ocfs2 modules]
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/ocfs2/cluster/masklog.c | 47 | ||||
-rw-r--r-- | fs/ocfs2/cluster/masklog.h | 42 |
2 files changed, 59 insertions, 30 deletions
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c index af7598bff1b5..c2182ba1013c 100644 --- a/fs/ocfs2/cluster/masklog.c +++ b/fs/ocfs2/cluster/masklog.c | |||
@@ -64,6 +64,53 @@ static ssize_t mlog_mask_store(u64 mask, const char *buf, size_t count) | |||
64 | return count; | 64 | return count; |
65 | } | 65 | } |
66 | 66 | ||
67 | /* | ||
68 | * smp_processor_id() "helpfully" screams when called outside preemptible | ||
69 | * regions in current kernels. sles doesn't have the variants that don't | ||
70 | * scream. just do this instead of trying to guess which we're building | ||
71 | * against.. *sigh*. | ||
72 | */ | ||
73 | #define __mlog_cpu_guess \ | ||
74 | ({ \ | ||
75 | unsigned long _cpu = get_cpu(); \ | ||
76 | put_cpu(); \ | ||
77 | _cpu; \ | ||
78 | }) | ||
79 | |||
80 | void __mlog_printk(const u64 *mask, const char *func, int line, | ||
81 | const char *fmt, ...) | ||
82 | { | ||
83 | struct va_format vaf; | ||
84 | va_list args; | ||
85 | const char *level; | ||
86 | const char *prefix = ""; | ||
87 | |||
88 | if (!__mlog_test_u64(*mask, mlog_and_bits) || | ||
89 | __mlog_test_u64(*mask, mlog_not_bits)) | ||
90 | return; | ||
91 | |||
92 | if (*mask & ML_ERROR) { | ||
93 | level = KERN_ERR; | ||
94 | prefix = "ERROR: "; | ||
95 | } else if (*mask & ML_NOTICE) { | ||
96 | level = KERN_NOTICE; | ||
97 | } else { | ||
98 | level = KERN_INFO; | ||
99 | } | ||
100 | |||
101 | va_start(args, fmt); | ||
102 | |||
103 | vaf.fmt = fmt; | ||
104 | vaf.va = &args; | ||
105 | |||
106 | printk("%s(%s,%u,%lu):%s:%d %s%pV", | ||
107 | level, current->comm, task_pid_nr(current), __mlog_cpu_guess, | ||
108 | func, line, prefix, &vaf); | ||
109 | |||
110 | va_end(args); | ||
111 | } | ||
112 | EXPORT_SYMBOL_GPL(__mlog_printk); | ||
113 | |||
67 | struct mlog_attribute { | 114 | struct mlog_attribute { |
68 | struct attribute attr; | 115 | struct attribute attr; |
69 | u64 mask; | 116 | u64 mask; |
diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h index 7fdc25a4d8c0..308ea0eb35fd 100644 --- a/fs/ocfs2/cluster/masklog.h +++ b/fs/ocfs2/cluster/masklog.h | |||
@@ -162,38 +162,20 @@ extern struct mlog_bits mlog_and_bits, mlog_not_bits; | |||
162 | 162 | ||
163 | #endif | 163 | #endif |
164 | 164 | ||
165 | /* | 165 | __printf(4, 5) |
166 | * smp_processor_id() "helpfully" screams when called outside preemptible | 166 | void __mlog_printk(const u64 *m, const char *func, int line, |
167 | * regions in current kernels. sles doesn't have the variants that don't | 167 | const char *fmt, ...); |
168 | * scream. just do this instead of trying to guess which we're building | ||
169 | * against.. *sigh*. | ||
170 | */ | ||
171 | #define __mlog_cpu_guess ({ \ | ||
172 | unsigned long _cpu = get_cpu(); \ | ||
173 | put_cpu(); \ | ||
174 | _cpu; \ | ||
175 | }) | ||
176 | 168 | ||
177 | /* In the following two macros, the whitespace after the ',' just | 169 | /* |
178 | * before ##args is intentional. Otherwise, gcc 2.95 will eat the | 170 | * Testing before the __mlog_printk call lets the compiler eliminate the |
179 | * previous token if args expands to nothing. | 171 | * call completely when (m & ML_ALLOWED_BITS) is 0. |
180 | */ | 172 | */ |
181 | #define __mlog_printk(level, fmt, args...) \ | 173 | #define mlog(mask, fmt, ...) \ |
182 | printk(level "(%s,%u,%lu):%s:%d " fmt, current->comm, \ | 174 | do { \ |
183 | task_pid_nr(current), __mlog_cpu_guess, \ | 175 | u64 _m = MLOG_MASK_PREFIX | (mask); \ |
184 | __PRETTY_FUNCTION__, __LINE__ , ##args) | 176 | if (_m & ML_ALLOWED_BITS) \ |
185 | 177 | __mlog_printk(&_m, __func__, __LINE__, fmt, \ | |
186 | #define mlog(mask, fmt, args...) do { \ | 178 | ##__VA_ARGS__); \ |
187 | u64 __m = MLOG_MASK_PREFIX | (mask); \ | ||
188 | if ((__m & ML_ALLOWED_BITS) && \ | ||
189 | __mlog_test_u64(__m, mlog_and_bits) && \ | ||
190 | !__mlog_test_u64(__m, mlog_not_bits)) { \ | ||
191 | if (__m & ML_ERROR) \ | ||
192 | __mlog_printk(KERN_ERR, "ERROR: "fmt , ##args); \ | ||
193 | else if (__m & ML_NOTICE) \ | ||
194 | __mlog_printk(KERN_NOTICE, fmt , ##args); \ | ||
195 | else __mlog_printk(KERN_INFO, fmt , ##args); \ | ||
196 | } \ | ||
197 | } while (0) | 179 | } while (0) |
198 | 180 | ||
199 | #define mlog_errno(st) ({ \ | 181 | #define mlog_errno(st) ({ \ |