summaryrefslogtreecommitdiffstats
path: root/tools/objtool/elf.h
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2020-03-12 11:30:50 +0100
committerPeter Zijlstra <peterz@infradead.org>2020-03-25 18:28:31 +0100
commit74b873e49d92f90deb41d1a2a8fbb70328aebd67 (patch)
tree202750758a1796652a86b895de1a7fc79ff17673 /tools/objtool/elf.h
parent8887a86eddd93ca396ca35f7b41fb14ed412f85d (diff)
downloadlinux-74b873e49d92f90deb41d1a2a8fbb70328aebd67.tar.bz2
objtool: Optimize find_rela_by_dest_range()
Perf shows there is significant time in find_rela_by_dest(); this is because we have to iterate the address space per byte, looking for relocation entries. Optimize this by reducing the address space granularity. This reduces objtool on vmlinux.o runtime from 4.8 to 4.4 seconds. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Miroslav Benes <mbenes@suse.cz> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lkml.kernel.org/r/20200324160924.861321325@infradead.org
Diffstat (limited to 'tools/objtool/elf.h')
-rw-r--r--tools/objtool/elf.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
index dfd2431ef693..ebbb10c61e24 100644
--- a/tools/objtool/elf.h
+++ b/tools/objtool/elf.h
@@ -83,9 +83,23 @@ struct elf {
DECLARE_HASHTABLE(rela_hash, 20);
};
+#define OFFSET_STRIDE_BITS 4
+#define OFFSET_STRIDE (1UL << OFFSET_STRIDE_BITS)
+#define OFFSET_STRIDE_MASK (~(OFFSET_STRIDE - 1))
+
+#define for_offset_range(_offset, _start, _end) \
+ for (_offset = ((_start) & OFFSET_STRIDE_MASK); \
+ _offset <= ((_end) & OFFSET_STRIDE_MASK); \
+ _offset += OFFSET_STRIDE)
+
static inline u32 sec_offset_hash(struct section *sec, unsigned long offset)
{
- u32 ol = offset, oh = offset >> 32, idx = sec->idx;
+ u32 ol, oh, idx = sec->idx;
+
+ offset &= OFFSET_STRIDE_MASK;
+
+ ol = offset;
+ oh = offset >> 32;
__jhash_mix(ol, oh, idx);