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

objtool: Provide stats for jump_labels

Add objtool --stats to count the jump_label sites it encounters.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210506194158.153101906@infradead.org

authored by

Peter Zijlstra and committed by
Ingo Molnar
e2d9494b 6d37b83c

+23 -2
+20 -2
tools/objtool/check.c
··· 1225 1225 struct instruction *orig_insn, 1226 1226 struct instruction **new_insn) 1227 1227 { 1228 - if (orig_insn->type == INSN_NOP) 1228 + if (orig_insn->type == INSN_NOP) { 1229 + do_nop: 1230 + if (orig_insn->len == 2) 1231 + file->jl_nop_short++; 1232 + else 1233 + file->jl_nop_long++; 1234 + 1229 1235 return 0; 1236 + } 1230 1237 1231 1238 if (orig_insn->type != INSN_JUMP_UNCONDITIONAL) { 1232 1239 WARN_FUNC("unsupported instruction at jump label", ··· 1252 1245 orig_insn->offset, orig_insn->len, 1253 1246 arch_nop_insn(orig_insn->len)); 1254 1247 orig_insn->type = INSN_NOP; 1255 - return 0; 1248 + goto do_nop; 1256 1249 } 1250 + 1251 + if (orig_insn->len == 2) 1252 + file->jl_short++; 1253 + else 1254 + file->jl_long++; 1257 1255 1258 1256 *new_insn = list_next_entry(orig_insn, list); 1259 1257 return 0; ··· 1338 1326 1339 1327 list_del(&special_alt->list); 1340 1328 free(special_alt); 1329 + } 1330 + 1331 + if (stats) { 1332 + printf("jl\\\tNOP\tJMP\n"); 1333 + printf("short:\t%ld\t%ld\n", file->jl_nop_short, file->jl_short); 1334 + printf("long:\t%ld\t%ld\n", file->jl_nop_long, file->jl_long); 1341 1335 } 1342 1336 1343 1337 out:
+3
tools/objtool/include/objtool/objtool.h
··· 22 22 struct list_head static_call_list; 23 23 struct list_head mcount_loc_list; 24 24 bool ignore_unreachables, c_file, hints, rodata; 25 + 26 + unsigned long jl_short, jl_long; 27 + unsigned long jl_nop_short, jl_nop_long; 25 28 }; 26 29 27 30 struct objtool_file *objtool_open_read(const char *_objname);