Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christian Borntraeger and committed by
Martin Schwidefsky
832a7710 ed7d56e1

+31 -10
+27 -2
arch/s390/include/asm/debug.h
··· 151 151 * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details! 152 152 */ 153 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 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 170 static inline debug_entry_t* 159 171 debug_exception(debug_info_t* id, int level, void* data, int length) ··· 206 194 * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details! 207 195 */ 208 196 extern debug_entry_t * 209 - debug_sprintf_exception(debug_info_t* id,int level,char *string,...) 197 + __debug_sprintf_exception(debug_info_t *id, int level, char *string, ...) 210 198 __attribute__ ((format(printf, 3, 4))); 199 + 200 + #define debug_sprintf_exception(_id, _level, _fmt, ...) \ 201 + ({ \ 202 + debug_entry_t *__ret; \ 203 + debug_info_t *__id = _id; \ 204 + int __level = _level; \ 205 + if ((!__id) || (__level > __id->level)) \ 206 + __ret = NULL; \ 207 + else \ 208 + __ret = __debug_sprintf_exception(__id, __level, \ 209 + _fmt, ## __VA_ARGS__);\ 210 + __ret; \ 211 + }) 211 212 212 213 int debug_register_view(debug_info_t* id, struct debug_view* view); 213 214 int debug_unregister_view(debug_info_t* id, struct debug_view* view);
+4 -8
arch/s390/kernel/debug.c
··· 1019 1019 */ 1020 1020 1021 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 1024 va_list ap; 1025 1025 int numargs,idx; ··· 1027 1027 debug_sprintf_entry_t *curr_event; 1028 1028 debug_entry_t *active; 1029 1029 1030 - if((!id) || (level > id->level)) 1031 - return NULL; 1032 1030 if (!debug_active || !id->areas) 1033 1031 return NULL; 1034 1032 numargs=debug_count_numargs(string); ··· 1048 1050 1049 1051 return active; 1050 1052 } 1051 - EXPORT_SYMBOL(debug_sprintf_event); 1053 + EXPORT_SYMBOL(__debug_sprintf_event); 1052 1054 1053 1055 /* 1054 1056 * debug_sprintf_exception: 1055 1057 */ 1056 1058 1057 1059 debug_entry_t* 1058 - debug_sprintf_exception(debug_info_t* id, int level,char *string,...) 1060 + __debug_sprintf_exception(debug_info_t *id, int level, char *string, ...) 1059 1061 { 1060 1062 va_list ap; 1061 1063 int numargs,idx; ··· 1063 1065 debug_sprintf_entry_t *curr_event; 1064 1066 debug_entry_t *active; 1065 1067 1066 - if((!id) || (level > id->level)) 1067 - return NULL; 1068 1068 if (!debug_active || !id->areas) 1069 1069 return NULL; 1070 1070 ··· 1085 1089 1086 1090 return active; 1087 1091 } 1088 - EXPORT_SYMBOL(debug_sprintf_exception); 1092 + EXPORT_SYMBOL(__debug_sprintf_exception); 1089 1093 1090 1094 /* 1091 1095 * debug_register_view: