diff options
author | Christian Borntraeger <borntraeger@de.ibm.com> | 2014-12-01 03:16:45 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2014-12-08 03:42:29 -0500 |
commit | 832a771034bf62444796ab8868264c3ea9e50866 (patch) | |
tree | 40f2a4daa8cb86927e77c07eaae2c06b8e885b73 | |
parent | ed7d56e174b11b76e2954f28605c5c16f8814fab (diff) |
s390/debug: avoid function call for debug_sprintf_*
debug_sprintf_event/exception are called even for debug events
with a disabling debug level. All other functions already do
the check in a wrapper function. Lets do the same here.
Due to the var_args the compiler rejects to make this function
inline. So let's wrap this via a macro.
This patch saves around 80 ns on my z196 for a KVM round trip (we
have two debug statements for entry and exit) when KVM is build as
a module.
The savings for built-in drivers is smaller as we then avoid the
PLT overhead for a function call.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r-- | arch/s390/include/asm/debug.h | 29 | ||||
-rw-r--r-- | arch/s390/kernel/debug.c | 12 |
2 files changed, 31 insertions, 10 deletions
diff --git a/arch/s390/include/asm/debug.h b/arch/s390/include/asm/debug.h index 530c15eb01e9..0206c8052328 100644 --- a/arch/s390/include/asm/debug.h +++ b/arch/s390/include/asm/debug.h | |||
@@ -151,9 +151,21 @@ debug_text_event(debug_info_t* id, int level, const char* txt) | |||
151 | * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details! | 151 | * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details! |
152 | */ | 152 | */ |
153 | extern debug_entry_t * | 153 | extern debug_entry_t * |
154 | debug_sprintf_event(debug_info_t* id,int level,char *string,...) | 154 | __debug_sprintf_event(debug_info_t *id, int level, char *string, ...) |
155 | __attribute__ ((format(printf, 3, 4))); | 155 | __attribute__ ((format(printf, 3, 4))); |
156 | 156 | ||
157 | #define debug_sprintf_event(_id, _level, _fmt, ...) \ | ||
158 | ({ \ | ||
159 | debug_entry_t *__ret; \ | ||
160 | debug_info_t *__id = _id; \ | ||
161 | int __level = _level; \ | ||
162 | if ((!__id) || (__level > __id->level)) \ | ||
163 | __ret = NULL; \ | ||
164 | else \ | ||
165 | __ret = __debug_sprintf_event(__id, __level, \ | ||
166 | _fmt, ## __VA_ARGS__); \ | ||
167 | __ret; \ | ||
168 | }) | ||
157 | 169 | ||
158 | static inline debug_entry_t* | 170 | static inline debug_entry_t* |
159 | debug_exception(debug_info_t* id, int level, void* data, int length) | 171 | debug_exception(debug_info_t* id, int level, void* data, int length) |
@@ -194,9 +206,22 @@ debug_text_exception(debug_info_t* id, int level, const char* txt) | |||
194 | * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details! | 206 | * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details! |
195 | */ | 207 | */ |
196 | extern debug_entry_t * | 208 | extern debug_entry_t * |
197 | debug_sprintf_exception(debug_info_t* id,int level,char *string,...) | 209 | __debug_sprintf_exception(debug_info_t *id, int level, char *string, ...) |
198 | __attribute__ ((format(printf, 3, 4))); | 210 | __attribute__ ((format(printf, 3, 4))); |
199 | 211 | ||
212 | #define debug_sprintf_exception(_id, _level, _fmt, ...) \ | ||
213 | ({ \ | ||
214 | debug_entry_t *__ret; \ | ||
215 | debug_info_t *__id = _id; \ | ||
216 | int __level = _level; \ | ||
217 | if ((!__id) || (__level > __id->level)) \ | ||
218 | __ret = NULL; \ | ||
219 | else \ | ||
220 | __ret = __debug_sprintf_exception(__id, __level, \ | ||
221 | _fmt, ## __VA_ARGS__);\ | ||
222 | __ret; \ | ||
223 | }) | ||
224 | |||
200 | int debug_register_view(debug_info_t* id, struct debug_view* view); | 225 | int debug_register_view(debug_info_t* id, struct debug_view* view); |
201 | int debug_unregister_view(debug_info_t* id, struct debug_view* view); | 226 | int debug_unregister_view(debug_info_t* id, struct debug_view* view); |
202 | 227 | ||
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c index ee8390da6ea7..c1f21aca76e7 100644 --- a/arch/s390/kernel/debug.c +++ b/arch/s390/kernel/debug.c | |||
@@ -1019,7 +1019,7 @@ debug_count_numargs(char *string) | |||
1019 | */ | 1019 | */ |
1020 | 1020 | ||
1021 | debug_entry_t* | 1021 | debug_entry_t* |
1022 | debug_sprintf_event(debug_info_t* id, int level,char *string,...) | 1022 | __debug_sprintf_event(debug_info_t *id, int level, char *string, ...) |
1023 | { | 1023 | { |
1024 | va_list ap; | 1024 | va_list ap; |
1025 | int numargs,idx; | 1025 | int numargs,idx; |
@@ -1027,8 +1027,6 @@ debug_sprintf_event(debug_info_t* id, int level,char *string,...) | |||
1027 | debug_sprintf_entry_t *curr_event; | 1027 | debug_sprintf_entry_t *curr_event; |
1028 | debug_entry_t *active; | 1028 | debug_entry_t *active; |
1029 | 1029 | ||
1030 | if((!id) || (level > id->level)) | ||
1031 | return NULL; | ||
1032 | if (!debug_active || !id->areas) | 1030 | if (!debug_active || !id->areas) |
1033 | return NULL; | 1031 | return NULL; |
1034 | numargs=debug_count_numargs(string); | 1032 | numargs=debug_count_numargs(string); |
@@ -1050,14 +1048,14 @@ debug_sprintf_event(debug_info_t* id, int level,char *string,...) | |||
1050 | 1048 | ||
1051 | return active; | 1049 | return active; |
1052 | } | 1050 | } |
1053 | EXPORT_SYMBOL(debug_sprintf_event); | 1051 | EXPORT_SYMBOL(__debug_sprintf_event); |
1054 | 1052 | ||
1055 | /* | 1053 | /* |
1056 | * debug_sprintf_exception: | 1054 | * debug_sprintf_exception: |
1057 | */ | 1055 | */ |
1058 | 1056 | ||
1059 | debug_entry_t* | 1057 | debug_entry_t* |
1060 | debug_sprintf_exception(debug_info_t* id, int level,char *string,...) | 1058 | __debug_sprintf_exception(debug_info_t *id, int level, char *string, ...) |
1061 | { | 1059 | { |
1062 | va_list ap; | 1060 | va_list ap; |
1063 | int numargs,idx; | 1061 | int numargs,idx; |
@@ -1065,8 +1063,6 @@ debug_sprintf_exception(debug_info_t* id, int level,char *string,...) | |||
1065 | debug_sprintf_entry_t *curr_event; | 1063 | debug_sprintf_entry_t *curr_event; |
1066 | debug_entry_t *active; | 1064 | debug_entry_t *active; |
1067 | 1065 | ||
1068 | if((!id) || (level > id->level)) | ||
1069 | return NULL; | ||
1070 | if (!debug_active || !id->areas) | 1066 | if (!debug_active || !id->areas) |
1071 | return NULL; | 1067 | return NULL; |
1072 | 1068 | ||
@@ -1089,7 +1085,7 @@ debug_sprintf_exception(debug_info_t* id, int level,char *string,...) | |||
1089 | 1085 | ||
1090 | return active; | 1086 | return active; |
1091 | } | 1087 | } |
1092 | EXPORT_SYMBOL(debug_sprintf_exception); | 1088 | EXPORT_SYMBOL(__debug_sprintf_exception); |
1093 | 1089 | ||
1094 | /* | 1090 | /* |
1095 | * debug_register_view: | 1091 | * debug_register_view: |