[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <168629684647.404.12216177036864165921.tip-bot2@tip-bot2>
Date: Fri, 09 Jun 2023 07:47:26 -0000
From: "tip-bot2 for Josh Poimboeuf" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Josh Poimboeuf <jpoimboe@...nel.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: objtool/core] objtool: Free insns when done
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: d93b5935fd47007597aed5105a902a10204bc30e
Gitweb: https://git.kernel.org/tip/d93b5935fd47007597aed5105a902a10204bc30e
Author: Josh Poimboeuf <jpoimboe@...nel.org>
AuthorDate: Tue, 30 May 2023 10:21:13 -07:00
Committer: Josh Poimboeuf <jpoimboe@...nel.org>
CommitterDate: Wed, 07 Jun 2023 10:03:27 -07:00
objtool: Free insns when done
Free the decoded instructions as they're no longer needed after this
point. This frees up a big chunk of heap, which will come handy when
skipping the reading of DWARF section data.
Link: https://lore.kernel.org/r/4d4bca1a0f869de020dac80d91f9acbf6df77eab.1685464332.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>
---
tools/objtool/check.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 47ff130..8936a05 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4596,6 +4596,34 @@ static int disas_warned_funcs(struct objtool_file *file)
return 0;
}
+struct insn_chunk {
+ void *addr;
+ struct insn_chunk *next;
+};
+
+/*
+ * Reduce peak RSS usage by freeing insns memory before writing the ELF file,
+ * which can trigger more allocations for .debug_* sections whose data hasn't
+ * been read yet.
+ */
+static void free_insns(struct objtool_file *file)
+{
+ struct instruction *insn;
+ struct insn_chunk *chunks = NULL, *chunk;
+
+ for_each_insn(file, insn) {
+ if (!insn->idx) {
+ chunk = malloc(sizeof(*chunk));
+ chunk->addr = insn;
+ chunk->next = chunks;
+ chunks = chunk;
+ }
+ }
+
+ for (chunk = chunks; chunk; chunk = chunk->next)
+ free(chunk->addr);
+}
+
int check(struct objtool_file *file)
{
int ret, warnings = 0;
@@ -4742,6 +4770,8 @@ int check(struct objtool_file *file)
warnings += ret;
}
+ free_insns(file);
+
if (opts.verbose)
disas_warned_funcs(file);
Powered by blists - more mailing lists