Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2749299pxj; Mon, 14 Jun 2021 06:23:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxje4Ri2BVjMtKpxnIFidVHkViso8iZooRhI/qnCmlCJtlTpb6y1ykf1gUzivmfRk6Vtoit X-Received: by 2002:a05:6402:28a:: with SMTP id l10mr16485810edv.365.1623676994367; Mon, 14 Jun 2021 06:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623676994; cv=none; d=google.com; s=arc-20160816; b=R6iFJc5B3d8utMOswnGp5IaeFlao56uGtW/EuwoOsm/HHHsdQm+03b/CtY2CYB/kTh ujGXNcRTjZB3O55Zj3oTI7l+e3AuiFh5UaberEZVeD2GhpzIdqHoiNG3EiXGkR0eT/Ny hiz5z/ZFn4SsbVVKMKLgHMAziJHwQzgA0XPn+wYIijzJRGjuFLUIOaPSaC9WBS1Q8+9i cmDd8FvPfSEN6qbAkdIDasYTzVheeLhE1RjSoBiJQRe5+axxUlteHvc0SvSIDOe8ATjM rIsnXvmL/6Kkvnwn/bonlrTm/HAudHuKiIgLjlZulZqe1zliMcw3rssQSyUfKY/hZc2C 6xhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=5q9+MaoHfV/mDKcaDuJodpqNRdwr+f/ZC3PEstNU0p8=; b=MNkwWyI4qm8SvPY4cO+NwYjx5TLOmHm2PdL0axvjL89m77Eeri2Nad4MM8leNxrYxG Lty6539chcq5jH6GQXl59Bi7z3A/9c01/e8DW527vYdDsqEoPm8V51TOTB/N2ktZT7mw irJDAWid1u9vmBshSstB54tVm8bnfdPXlGaoH8IbDtOEgo9z31/VUg53Xxnnb2JeZu9k 6jYpEKm026wqNO6CpuY+5wN1YJ0ioIZrYJlULrQ+Lns+0RrwE4I9t5EMEE4DFRPO9k2P 1FDjZQuChW2eTICn54nJ2me0b2NCVcrKZDugAk2F2ymPsAg7bREoTpWwq0752K2iAIVi izCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1xkAbuHA; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=WjTGenGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si11084518ejl.222.2021.06.14.06.22.51; Mon, 14 Jun 2021 06:23:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1xkAbuHA; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=WjTGenGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233226AbhFNNVd (ORCPT + 99 others); Mon, 14 Jun 2021 09:21:33 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:54744 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232825AbhFNNVc (ORCPT ); Mon, 14 Jun 2021 09:21:32 -0400 Date: Mon, 14 Jun 2021 13:19:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1623676768; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5q9+MaoHfV/mDKcaDuJodpqNRdwr+f/ZC3PEstNU0p8=; b=1xkAbuHASmPAdqUvn4g0Eh6r3Nl1PpG5SGl8DPSscie1CSriIbf6C3SwXKpt8oVoc2RyKm KZRn9VKfAUKGTz+f9sTKj31/aXbEG8HTGxXFoE8fIpPfL6DtXYH3rHk+TalRddj6KScVhn 6e9n0dhAZ1OZ2VxvFpFd2hlOecxqlrfuLYngntW62CINu695tpOuHcWsE7jrzAz7Ybg78f wdSgASCSwp5ofUYMxxwMFVyXHdpy6zPhuh/SliEc0Cs6P5Rngy6WLN/Sfwz0C3QyuFcYdx u3e93dOTEYJlcLf5gT3/pXKvO9dED4U9cm3dumIkTSUYYwbgg3ByTKaZ66p0mg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1623676768; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5q9+MaoHfV/mDKcaDuJodpqNRdwr+f/ZC3PEstNU0p8=; b=WjTGenGbzUt7vZ0BaclYK7dg6cVjAYkRUKTSyu/M2b7oEWZKvwPctjA5PKB1Nf7sre9qbj Q9609hNk6hK5mUBw== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] objtool: Improve reloc hash size guestimate Cc: Nathan Chancellor , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: MIME-Version: 1.0 Message-ID: <162367676767.19906.18401009799732706895.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the objtool/core branch of tip: Commit-ID: d33b9035e14a35f6f2a5f067f0b156a93581811d Gitweb: https://git.kernel.org/tip/d33b9035e14a35f6f2a5f067f0b156a93581811d Author: Peter Zijlstra AuthorDate: Fri, 11 Jun 2021 08:33:36 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 14 Jun 2021 14:05:36 +02:00 objtool: Improve reloc hash size guestimate Nathan reported that LLVM ThinLTO builds have a performance regression with commit 25cf0d8aa2a3 ("objtool: Rewrite hashtable sizing"). Sami was quick to note that this is due to their use of -ffunction-sections. As a result the .text section is small and basing the number of relocs off of that no longer works. Instead have read_sections() compute the sum of all SHF_EXECINSTR sections and use that. Fixes: 25cf0d8aa2a3 ("objtool: Rewrite hashtable sizing") Reported-by: Nathan Chancellor Debugged-by: Sami Tolvanen Signed-off-by: Peter Zijlstra (Intel) Tested-by: Nathan Chancellor Link: https://lkml.kernel.org/r/YMJpGLuGNsGtA5JJ@hirez.programming.kicks-ass.net --- tools/objtool/elf.c | 11 ++++------- tools/objtool/include/objtool/elf.h | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index a8a0ee2..2371ccc 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 9008275..e343950 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;