Skip to content

Commit 0932dbe

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
objtool: Remove instruction::reloc
Instead of caching the reloc for each instruction, only keep a negative cache of not having a reloc (by far the most common case). struct instruction { struct list_head list; /* 0 16 */ struct hlist_node hash; /* 16 16 */ struct list_head call_node; /* 32 16 */ struct section * sec; /* 48 8 */ long unsigned int offset; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ long unsigned int immediate; /* 64 8 */ unsigned int len; /* 72 4 */ u8 type; /* 76 1 */ /* Bitfield combined with previous fields */ u16 dead_end:1; /* 76: 8 2 */ u16 ignore:1; /* 76: 9 2 */ u16 ignore_alts:1; /* 76:10 2 */ u16 hint:1; /* 76:11 2 */ u16 save:1; /* 76:12 2 */ u16 restore:1; /* 76:13 2 */ u16 retpoline_safe:1; /* 76:14 2 */ u16 noendbr:1; /* 76:15 2 */ u16 entry:1; /* 78: 0 2 */ u16 visited:4; /* 78: 1 2 */ + u16 no_reloc:1; /* 78: 5 2 */ - /* XXX 3 bits hole, try to pack */ + /* XXX 2 bits hole, try to pack */ /* Bitfield combined with next fields */ s8 instr; /* 79 1 */ struct alt_group * alt_group; /* 80 8 */ struct symbol * call_dest; /* 88 8 */ struct instruction * jump_dest; /* 96 8 */ struct instruction * first_jump_src; /* 104 8 */ struct reloc * jump_table; /* 112 8 */ - struct reloc * reloc; /* 120 8 */ + struct alternative * alts; /* 120 8 */ /* --- cacheline 2 boundary (128 bytes) --- */ - struct alternative * alts; /* 128 8 */ - struct symbol * sym; /* 136 8 */ - struct stack_op * stack_ops; /* 144 8 */ - struct cfi_state * cfi; /* 152 8 */ + struct symbol * sym; /* 128 8 */ + struct stack_op * stack_ops; /* 136 8 */ + struct cfi_state * cfi; /* 144 8 */ - /* size: 160, cachelines: 3, members: 29 */ - /* sum members: 158 */ - /* sum bitfield members: 13 bits, bit holes: 1, sum bit holes: 3 bits */ - /* last cacheline: 32 bytes */ + /* size: 152, cachelines: 3, members: 29 */ + /* sum members: 150 */ + /* sum bitfield members: 14 bits, bit holes: 1, sum bit holes: 2 bits */ + /* last cacheline: 24 bytes */ }; pre: 5:48.89 real, 220.96 user, 127.55 sys, 24834672 mem post: 5:39.35 real, 215.58 user, 123.69 sys, 2344873 mem Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Tested-by: Nathan Chancellor <[email protected]> # build only Tested-by: Thomas Weißschuh <[email protected]> # compile and run Link: https://lore.kernel.org/r/[email protected]
1 parent 8b2de41 commit 0932dbe

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

tools/objtool/check.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,26 +1305,24 @@ __weak bool arch_is_rethunk(struct symbol *sym)
13051305
return false;
13061306
}
13071307

1308-
#define NEGATIVE_RELOC ((void *)-1L)
1309-
13101308
static struct reloc *insn_reloc(struct objtool_file *file, struct instruction *insn)
13111309
{
1312-
if (insn->reloc == NEGATIVE_RELOC)
1310+
struct reloc *reloc;
1311+
1312+
if (insn->no_reloc)
13131313
return NULL;
13141314

1315-
if (!insn->reloc) {
1316-
if (!file)
1317-
return NULL;
1315+
if (!file)
1316+
return NULL;
13181317

1319-
insn->reloc = find_reloc_by_dest_range(file->elf, insn->sec,
1320-
insn->offset, insn->len);
1321-
if (!insn->reloc) {
1322-
insn->reloc = NEGATIVE_RELOC;
1323-
return NULL;
1324-
}
1318+
reloc = find_reloc_by_dest_range(file->elf, insn->sec,
1319+
insn->offset, insn->len);
1320+
if (!reloc) {
1321+
insn->no_reloc = 1;
1322+
return NULL;
13251323
}
13261324

1327-
return insn->reloc;
1325+
return reloc;
13281326
}
13291327

13301328
static void remove_insn_ops(struct instruction *insn)

tools/objtool/include/objtool/check.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ struct instruction {
5555
retpoline_safe : 1,
5656
noendbr : 1,
5757
entry : 1,
58-
visited : 4;
59-
/* 3 bit hole */
58+
visited : 4,
59+
no_reloc : 1;
60+
/* 2 bit hole */
6061

6162
s8 instr;
6263

@@ -65,7 +66,6 @@ struct instruction {
6566
struct instruction *jump_dest;
6667
struct instruction *first_jump_src;
6768
struct reloc *jump_table;
68-
struct reloc *reloc;
6969
struct alternative *alts;
7070
struct symbol *sym;
7171
struct stack_op *stack_ops;

0 commit comments

Comments
 (0)