[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YMJ9MGyXHi9Xa0ne@DESKTOP-1V8MEUQ.localdomain>
Date: Thu, 10 Jun 2021 13:59:28 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Sami Tolvanen <samitolvanen@...gle.com>, X86 ML <x86@...nel.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Jason Baron <jbaron@...mai.com>,
Steven Rostedt <rostedt@...dmis.org>,
Ard Biesheuvel <ardb@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH 01/13] objtool: Rewrite hashtable sizing
On Thu, Jun 10, 2021 at 09:33:44PM +0200, Peter Zijlstra wrote:
> On Thu, Jun 10, 2021 at 11:50:36AM -0700, Sami Tolvanen wrote:
> > On Thu, Jun 10, 2021 at 11:14 AM Nathan Chancellor <nathan@...nel.org> wrote:
> > > Adding Sami because I am not sure why this patch would have much of an impact
> > > in relation to LTO. https://git.kernel.org/tip/25cf0d8aa2a3 is the patch in
> > > question.
> >
> > It's because LLVM enables -ffunction-sections with LTO, so using .text
> > section size to estimate the reloc hash table size isn't going to be
> > accurate, as confirmed by objtool output with --stats:
> >
> > OBJTOOL vmlinux.o
> > nr_sections: 141481
> > section_bits: 17
> > nr_symbols: 215262
> > symbol_bits: 17
> > max_reloc: 24850
> > tot_reloc: 590890
> > reloc_bits: 10
>
> Bah. Would something like the *completely* untested below help with that?
LGTM, thanks for the quick fix!
Benchmark #1: allmodconfig
Time (mean ± σ): 624.555 s ± 2.089 s [User: 35109.967 s, System: 2146.215 s]
Range (min … max): 623.078 s … 626.032 s 2 runs
Benchmark #2: allmodconfig with ThinLTO
Time (mean ± σ): 769.959 s ± 1.819 s [User: 39692.409 s, System: 2308.010 s]
Range (min … max): 768.673 s … 771.245 s 2 runs
Summary
'allmodconfig' ran
1.23 ± 0.01 times faster than 'allmodconfig with ThinLTO'
Tested-by: Nathan Chancellor <nathan@...nel.org>
> ---
> diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> index 25f6d293bc86..8676c7598728 100644
> --- a/tools/objtool/elf.c
> +++ b/tools/objtool/elf.c
> @@ -288,6 +288,9 @@ static int read_sections(struct elf *elf)
> }
> sec->len = sec->sh.sh_size;
>
> + if (sec->sh.sh_flags & SHF_EXECINSTR)
> + elf->text_size += sec->len;
> +
> list_add_tail(&sec->list, &elf->sections);
> elf_hash_add(section, &sec->hash, sec->idx);
> elf_hash_add(section_name, &sec->name_hash, str_hash(sec->name));
> @@ -581,13 +584,7 @@ static int read_relocs(struct elf *elf)
> unsigned int symndx;
> unsigned long nr_reloc, max_reloc = 0, tot_reloc = 0;
>
> - sec = find_section_by_name(elf, ".text");
> - if (!sec) {
> - WARN("no .text");
> - return -1;
> - }
> -
> - if (!elf_alloc_hash(reloc, sec->len / 16))
> + if (!elf_alloc_hash(reloc, elf->text_size / 16))
> return -1;
>
> list_for_each_entry(sec, &elf->sections, list) {
> diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
> index 90082751f851..e34395047530 100644
> --- a/tools/objtool/include/objtool/elf.h
> +++ b/tools/objtool/include/objtool/elf.h
> @@ -83,6 +83,7 @@ struct elf {
> int fd;
> bool changed;
> char *name;
> + unsigned int text_size;
> struct list_head sections;
>
> int symbol_bits;
Powered by blists - more mailing lists