From: Peter Zijlstra <peterz@infradead.org>
To: x86@kernel.org, jpoimboe@redhat.com, linux@weissschuh.net
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org
Subject: [PATCH 05/10] objtool: Remove instruction::reloc
Date: Wed, 08 Feb 2023 18:18:01 +0100 [thread overview]
Message-ID: <20230208172245.572145269@infradead.org> (raw)
In-Reply-To: 20230208171756.898991570@infradead.org
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, 23448736 mem
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
tools/objtool/check.c | 26 ++++++++++++--------------
tools/objtool/include/objtool/check.h | 6 +++---
2 files changed, 15 insertions(+), 17 deletions(-)
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1307,26 +1307,24 @@ __weak bool arch_is_rethunk(struct symbo
return false;
}
-#define NEGATIVE_RELOC ((void *)-1L)
-
static struct reloc *insn_reloc(struct objtool_file *file, struct instruction *insn)
{
- if (insn->reloc == NEGATIVE_RELOC)
+ struct reloc *reloc;
+
+ if (insn->no_reloc)
return NULL;
- if (!insn->reloc) {
- if (!file)
- return NULL;
-
- insn->reloc = find_reloc_by_dest_range(file->elf, insn->sec,
- insn->offset, insn->len);
- if (!insn->reloc) {
- insn->reloc = NEGATIVE_RELOC;
- return NULL;
- }
+ if (!file)
+ return NULL;
+
+ reloc = find_reloc_by_dest_range(file->elf, insn->sec,
+ insn->offset, insn->len);
+ if (!reloc) {
+ insn->no_reloc = 1;
+ return NULL;
}
- return insn->reloc;
+ return reloc;
}
static void remove_insn_ops(struct instruction *insn)
--- a/tools/objtool/include/objtool/check.h
+++ b/tools/objtool/include/objtool/check.h
@@ -55,8 +55,9 @@ struct instruction {
retpoline_safe : 1,
noendbr : 1,
entry : 1,
- visited : 4;
- /* 3 bit hole */
+ visited : 4,
+ no_reloc : 1;
+ /* 2 bit hole */
s8 instr;
@@ -65,7 +66,6 @@ struct instruction {
struct instruction *jump_dest;
struct instruction *first_jump_src;
struct reloc *jump_table;
- struct reloc *reloc;
struct alternative *alts;
struct symbol *sym;
struct stack_op *stack_ops;
next prev parent reply other threads:[~2023-02-08 17:24 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-08 17:17 [PATCH 00/10] objtool: Honey, I shrunk the instruction Peter Zijlstra
2023-02-08 17:17 ` [PATCH 01/10] objtool: Change arch_decode_instruction() signature Peter Zijlstra
2023-02-13 11:10 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2023-02-23 8:32 ` tip-bot2 for Peter Zijlstra
2023-02-08 17:17 ` [PATCH 02/10] objtool: Make instruction::stack_ops a single-linked list Peter Zijlstra
2023-02-13 11:10 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2023-02-23 8:32 ` tip-bot2 for Peter Zijlstra
2023-02-08 17:17 ` [PATCH 03/10] objtool: Make instruction::alts " Peter Zijlstra
2023-02-13 11:10 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2023-02-23 8:32 ` tip-bot2 for Peter Zijlstra
2023-02-08 17:18 ` [PATCH 04/10] objtool: Shrink instruction::{type,visited} Peter Zijlstra
2023-02-13 11:10 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2023-02-23 8:32 ` tip-bot2 for Peter Zijlstra
2023-02-08 17:18 ` Peter Zijlstra [this message]
2023-02-13 11:10 ` [tip: objtool/core] objtool: Remove instruction::reloc tip-bot2 for Peter Zijlstra
2023-02-23 8:32 ` tip-bot2 for Peter Zijlstra
2023-02-08 17:18 ` [PATCH 06/10] objtool: Union instruction::{call_dest,jump_table} Peter Zijlstra
2023-02-13 11:10 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2023-02-23 8:32 ` tip-bot2 for Peter Zijlstra
2023-02-08 17:18 ` [PATCH 07/10] objtool: Fix overlapping alternatives Peter Zijlstra
2023-02-13 11:10 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2023-02-23 8:32 ` tip-bot2 for Peter Zijlstra
2023-02-08 17:18 ` [PATCH 08/10] x86: Fix FILL_RETURN_BUFFER Peter Zijlstra
2023-02-13 11:10 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2023-02-23 8:32 ` tip-bot2 for Peter Zijlstra
2023-02-08 17:18 ` [PATCH 09/10] objtool: Remove instruction::list Peter Zijlstra
2023-02-13 11:10 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2023-02-23 8:32 ` tip-bot2 for Peter Zijlstra
2023-02-08 17:18 ` [PATCH 10/10][HACK] objtool: Shrink reloc Peter Zijlstra
2023-02-08 18:35 ` [PATCH 00/10] objtool: Honey, I shrunk the instruction Nathan Chancellor
2023-02-08 20:22 ` Damian Tometzki
2023-02-09 10:22 ` Peter Zijlstra
2023-02-09 10:56 ` Damian Tometzki
2023-02-09 19:57 ` Josh Poimboeuf
2023-02-10 8:59 ` Peter Zijlstra
2023-02-10 13:47 ` [PATCH 00/10] objtool: Honey, I shrunk the instruction^Wreloc Peter Zijlstra
2023-02-10 1:50 ` [PATCH 00/10] objtool: Honey, I shrunk the instruction Thomas Weißschuh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230208172245.572145269@infradead.org \
--to=peterz@infradead.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox