Skip to content

Commit 3ee88df

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
objtool: Make instruction::stack_ops 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 list_head stack_ops; /* 160 16 */ - struct cfi_state * cfi; /* 176 8 */ + struct stack_op * stack_ops; /* 160 8 */ + struct cfi_state * cfi; /* 168 8 */ - /* size: 184, cachelines: 3, members: 29 */ - /* sum members: 178, holes: 1, sum holes: 4 */ + /* size: 176, cachelines: 3, members: 29 */ + /* sum members: 170, holes: 1, sum holes: 4 */ /* sum bitfield members: 9 bits, bit holes: 1, sum bit holes: 7 bits */ - /* last cacheline: 56 bytes */ + /* last cacheline: 48 bytes */ }; pre: 5:58.22 real, 226.69 user, 131.22 sys, 26221520 mem post: 5:58.50 real, 229.64 user, 128.65 sys, 26221520 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 20a5546 commit 3ee88df

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

tools/objtool/arch/x86/decode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ bool arch_pc_relative_reloc(struct reloc *reloc)
105105
#define ADD_OP(op) \
106106
if (!(op = calloc(1, sizeof(*op)))) \
107107
return -1; \
108-
else for (list_add_tail(&op->list, ops_list); op; op = NULL)
108+
else for (*ops_list = op, ops_list = &op->next; op; op = NULL)
109109

110110
/*
111111
* Helpers to decode ModRM/SIB:
@@ -148,7 +148,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
148148
unsigned long offset, unsigned int maxlen,
149149
struct instruction *insn)
150150
{
151-
struct list_head *ops_list = &insn->stack_ops;
151+
struct stack_op **ops_list = &insn->stack_ops;
152152
const struct elf *elf = file->elf;
153153
struct insn ins;
154154
int x86_64, ret;

tools/objtool/check.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ static int decode_instructions(struct objtool_file *file)
398398
}
399399
memset(insn, 0, sizeof(*insn));
400400
INIT_LIST_HEAD(&insn->alts);
401-
INIT_LIST_HEAD(&insn->stack_ops);
402401
INIT_LIST_HEAD(&insn->call_node);
403402

404403
insn->sec = sec;
@@ -1331,12 +1330,13 @@ static struct reloc *insn_reloc(struct objtool_file *file, struct instruction *i
13311330

13321331
static void remove_insn_ops(struct instruction *insn)
13331332
{
1334-
struct stack_op *op, *tmp;
1333+
struct stack_op *op, *next;
13351334

1336-
list_for_each_entry_safe(op, tmp, &insn->stack_ops, list) {
1337-
list_del(&op->list);
1335+
for (op = insn->stack_ops; op; op = next) {
1336+
next = op->next;
13381337
free(op);
13391338
}
1339+
insn->stack_ops = NULL;
13401340
}
13411341

13421342
static void annotate_call_site(struct objtool_file *file,
@@ -1781,7 +1781,6 @@ static int handle_group_alt(struct objtool_file *file,
17811781
}
17821782
memset(nop, 0, sizeof(*nop));
17831783
INIT_LIST_HEAD(&nop->alts);
1784-
INIT_LIST_HEAD(&nop->stack_ops);
17851784

17861785
nop->sec = special_alt->new_sec;
17871786
nop->offset = special_alt->new_off + special_alt->new_len;
@@ -3226,7 +3225,7 @@ static int handle_insn_ops(struct instruction *insn,
32263225
{
32273226
struct stack_op *op;
32283227

3229-
list_for_each_entry(op, &insn->stack_ops, list) {
3228+
for (op = insn->stack_ops; op; op = op->next) {
32303229

32313230
if (update_cfi_state(insn, next_insn, &state->cfi, op))
32323231
return 1;

tools/objtool/include/objtool/arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ struct op_src {
6262
};
6363

6464
struct stack_op {
65+
struct stack_op *next;
6566
struct op_dest dest;
6667
struct op_src src;
67-
struct list_head list;
6868
};
6969

7070
struct instruction;

tools/objtool/include/objtool/check.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct instruction {
6868
struct reloc *reloc;
6969
struct list_head alts;
7070
struct symbol *sym;
71-
struct list_head stack_ops;
71+
struct stack_op *stack_ops;
7272
struct cfi_state *cfi;
7373
};
7474

0 commit comments

Comments
 (0)