Skip to content

Commit d540665

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
objtool: Make instruction::alts a single-linked list
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) --- */ unsigned int len; /* 64 4 */ enum insn_type type; /* 68 4 */ long unsigned int immediate; /* 72 8 */ u16 dead_end:1; /* 80: 0 2 */ u16 ignore:1; /* 80: 1 2 */ u16 ignore_alts:1; /* 80: 2 2 */ u16 hint:1; /* 80: 3 2 */ u16 save:1; /* 80: 4 2 */ u16 restore:1; /* 80: 5 2 */ u16 retpoline_safe:1; /* 80: 6 2 */ u16 noendbr:1; /* 80: 7 2 */ u16 entry:1; /* 80: 8 2 */ /* XXX 7 bits hole, try to pack */ s8 instr; /* 82 1 */ u8 visited; /* 83 1 */ /* XXX 4 bytes hole, try to pack */ struct alt_group * alt_group; /* 88 8 */ struct symbol * call_dest; /* 96 8 */ struct instruction * jump_dest; /* 104 8 */ struct instruction * first_jump_src; /* 112 8 */ struct reloc * jump_table; /* 120 8 */ /* --- cacheline 2 boundary (128 bytes) --- */ struct reloc * reloc; /* 128 8 */ - struct list_head alts; /* 136 16 */ - struct symbol * sym; /* 152 8 */ - struct stack_op * stack_ops; /* 160 8 */ - struct cfi_state * cfi; /* 168 8 */ + struct alternative * alts; /* 136 8 */ + struct symbol * sym; /* 144 8 */ + struct stack_op * stack_ops; /* 152 8 */ + struct cfi_state * cfi; /* 160 8 */ - /* size: 176, cachelines: 3, members: 29 */ - /* sum members: 170, holes: 1, sum holes: 4 */ + /* size: 168, cachelines: 3, members: 29 */ + /* sum members: 162, holes: 1, sum holes: 4 */ /* sum bitfield members: 9 bits, bit holes: 1, sum bit holes: 7 bits */ - /* last cacheline: 48 bytes */ + /* last cacheline: 40 bytes */ }; pre: 5:58.50 real, 229.64 user, 128.65 sys, 26221520 mem post: 5:48.86 real, 220.30 user, 128.34 sys, 24834672 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 3ee88df commit d540665

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

tools/objtool/check.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <linux/static_call_types.h>
2424

2525
struct alternative {
26-
struct list_head list;
26+
struct alternative *next;
2727
struct instruction *insn;
2828
bool skip_orig;
2929
};
@@ -397,7 +397,6 @@ static int decode_instructions(struct objtool_file *file)
397397
return -1;
398398
}
399399
memset(insn, 0, sizeof(*insn));
400-
INIT_LIST_HEAD(&insn->alts);
401400
INIT_LIST_HEAD(&insn->call_node);
402401

403402
insn->sec = sec;
@@ -1780,7 +1779,6 @@ static int handle_group_alt(struct objtool_file *file,
17801779
return -1;
17811780
}
17821781
memset(nop, 0, sizeof(*nop));
1783-
INIT_LIST_HEAD(&nop->alts);
17841782

17851783
nop->sec = special_alt->new_sec;
17861784
nop->offset = special_alt->new_off + special_alt->new_len;
@@ -1978,7 +1976,8 @@ static int add_special_section_alts(struct objtool_file *file)
19781976
alt->insn = new_insn;
19791977
alt->skip_orig = special_alt->skip_orig;
19801978
orig_insn->ignore_alts |= special_alt->skip_alt;
1981-
list_add_tail(&alt->list, &orig_insn->alts);
1979+
alt->next = orig_insn->alts;
1980+
orig_insn->alts = alt;
19821981

19831982
list_del(&special_alt->list);
19841983
free(special_alt);
@@ -2037,7 +2036,8 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
20372036
}
20382037

20392038
alt->insn = dest_insn;
2040-
list_add_tail(&alt->list, &insn->alts);
2039+
alt->next = insn->alts;
2040+
insn->alts = alt;
20412041
prev_offset = reloc->offset;
20422042
}
20432043

@@ -3594,10 +3594,10 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
35943594
if (propagate_alt_cfi(file, insn))
35953595
return 1;
35963596

3597-
if (!insn->ignore_alts && !list_empty(&insn->alts)) {
3597+
if (!insn->ignore_alts && insn->alts) {
35983598
bool skip_orig = false;
35993599

3600-
list_for_each_entry(alt, &insn->alts, list) {
3600+
for (alt = insn->alts; alt; alt = alt->next) {
36013601
if (alt->skip_orig)
36023602
skip_orig = true;
36033603

@@ -3796,11 +3796,11 @@ static int validate_entry(struct objtool_file *file, struct instruction *insn)
37963796

37973797
insn->visited |= VISITED_ENTRY;
37983798

3799-
if (!insn->ignore_alts && !list_empty(&insn->alts)) {
3799+
if (!insn->ignore_alts && insn->alts) {
38003800
struct alternative *alt;
38013801
bool skip_orig = false;
38023802

3803-
list_for_each_entry(alt, &insn->alts, list) {
3803+
for (alt = insn->alts; alt; alt = alt->next) {
38043804
if (alt->skip_orig)
38053805
skip_orig = true;
38063806

tools/objtool/include/objtool/check.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct instruction {
6666
struct instruction *first_jump_src;
6767
struct reloc *jump_table;
6868
struct reloc *reloc;
69-
struct list_head alts;
69+
struct alternative *alts;
7070
struct symbol *sym;
7171
struct stack_op *stack_ops;
7272
struct cfi_state *cfi;

0 commit comments

Comments
 (0)