Skip to content

Commit 87ecb58

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
objtool: Use sec_offset_hash() for insn_hash
In preparation for find_insn_containing(), change insn_hash to use sec_offset_hash(). This actually reduces runtime; probably because mixing in the section index reduces the collisions due to text sections all starting their instructions at offset 0. Runtime on vmlinux.o from 3.1 to 2.5 seconds. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Miroslav Benes <[email protected]> Reviewed-by: Alexandre Chartre <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 34f7c96 commit 87ecb58

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/objtool/check.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ struct instruction *find_insn(struct objtool_file *file,
3434
{
3535
struct instruction *insn;
3636

37-
hash_for_each_possible(file->insn_hash, insn, hash, offset)
37+
hash_for_each_possible(file->insn_hash, insn, hash, sec_offset_hash(sec, offset)) {
3838
if (insn->sec == sec && insn->offset == offset)
3939
return insn;
40+
}
4041

4142
return NULL;
4243
}
@@ -282,7 +283,7 @@ static int decode_instructions(struct objtool_file *file)
282283
if (ret)
283284
goto err;
284285

285-
hash_add(file->insn_hash, &insn->hash, insn->offset);
286+
hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset));
286287
list_add_tail(&insn->list, &file->insn_list);
287288
nr_insns++;
288289
}

0 commit comments

Comments
 (0)