summaryrefslogtreecommitdiff
path: root/tools/objtool
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2020-03-16 15:47:27 +0100
committerIngo Molnar <mingo@kernel.org>2020-04-22 10:53:50 +0200
commit87ecb582f0ac85886398dde8c3cdb2225cac7786 (patch)
treeab4033654e1b581111ea8fc297d3d09c2d6c2f2e /tools/objtool
parent34f7c96d96d5e11b03a612017fcc3a6e645bb481 (diff)
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) <peterz@infradead.org> Reviewed-by: Miroslav Benes <mbenes@suse.cz> Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lkml.kernel.org/r/20200416115119.227240432@infradead.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/objtool')
-rw-r--r--tools/objtool/check.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 87e528c2840c..923652ba5f9a 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -34,9 +34,10 @@ struct instruction *find_insn(struct objtool_file *file,
{
struct instruction *insn;
- hash_for_each_possible(file->insn_hash, insn, hash, offset)
+ hash_for_each_possible(file->insn_hash, insn, hash, sec_offset_hash(sec, offset)) {
if (insn->sec == sec && insn->offset == offset)
return insn;
+ }
return NULL;
}
@@ -282,7 +283,7 @@ static int decode_instructions(struct objtool_file *file)
if (ret)
goto err;
- hash_add(file->insn_hash, &insn->hash, insn->offset);
+ hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset));
list_add_tail(&insn->list, &file->insn_list);
nr_insns++;
}