Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4835621rwd; Tue, 30 May 2023 10:32:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4y2WcAhwxvRhvIBE9z0KIZkO+iBI1h+pIwu2kxWAaZSx7gLz2qMDRc8Iq1NrZhjKYoB9ie X-Received: by 2002:a17:903:1c1:b0:1af:faf2:edce with SMTP id e1-20020a17090301c100b001affaf2edcemr3615444plh.30.1685467930492; Tue, 30 May 2023 10:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685467930; cv=none; d=google.com; s=arc-20160816; b=oWxcCgxB1p+MTtmnBq4wmgPE6sSKdt+HhyqoikrHQ3jsZca/spBRtKa+FhAq8nWmRp +TrQ2/cogTdK/33ZhXUPxjJny26XkXl5AtjXgr3TeE+CYaMlH8lR3QSBwjKc4Og+rWky qbGLWzUJur/AnCDsDH0SBVITTTTARIQDxkg6rKQY26A9/KUPloIvdlBM9fEYiQll1ePP HX+cYaFyum3fin5C24jsO8unhaVYF+MvMd0EWPYo4QJmo4b0G25HNpex6WkWPBh/LANn azYDPjb1r6iwAq5yhfV4gk4jk8tj4w7Koc1P84QBvDpNGxkDVcR+J744h+ZYkaKCmbY0 0Llw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=jOUn1S4gTbtQeg5uTpqXlPU8H6iJdkSTuol0/iJZW9Y=; b=iVT97q3Wq0KI4Lc6WqXwEIqHknPtv5/Q/OFQqzIBqnHuMWl3krQu0E8Cf1T1QeGkqR MjGMG+PaSr7gnZHIz4tIdR733rxqCnzEBRfh9lajpmyMVcDVoUESzNh1owNS/buxFQiO 1H7+m7pnGMQ3S2GnhcC0QdGCE5ChQ6x6JO2l97pFiX8u7usdpPgUydPbvJdS+woCbIwI p3hcrdkqCi6okFh6/nBPTG/6R3crAo03QNFYphAfRQd6RmJTlCO+TFNSJ/c5Cqn/7pSS 16YLlAHLffpMgcnSSDFKQzlJzp1oAGVyJqXHDpwLYTrYbzKc9DpW2oMm1lLpmqHSwJTY eVrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ld4IKAPw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a1709028c8900b001ae5fb1436asi11032780plo.184.2023.05.30.10.31.56; Tue, 30 May 2023 10:32:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ld4IKAPw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231944AbjE3RVg (ORCPT + 99 others); Tue, 30 May 2023 13:21:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230479AbjE3RVe (ORCPT ); Tue, 30 May 2023 13:21:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F195DA3 for ; Tue, 30 May 2023 10:21:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8E66F630DB for ; Tue, 30 May 2023 17:21:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDB40C433D2; Tue, 30 May 2023 17:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685467291; bh=c+O+LLgqN5oTgo0HoROZJSsAcr4bfSI/Bxgq9ilr0CY=; h=From:To:Cc:Subject:Date:From; b=ld4IKAPwxj/ynldPT0K7p0sFQXmymcalYygVqgTSLvetQxplpPXJW+4DXYx7vjFDj MncBS9L83qTMabZBXoFHiPXz8gxtIT3UInNn35S0lKnQzGyinOpyj4R4QIBTrVG46U 2vYTw05WfSSho7UCN6mSURos7PXsWsVcW1hgB/xiQ2pdqJyevzaG6nQ9SQPeDwBDmN NMUeXLKfN/AB9dbZE8wWxqMLGRSSk1CYbwtqCP/ZOwkMUNNQ7CELF3OljX9STkSzDv r//Oy8STI51wF5KiT7ESk5hcB3n/FwAtXbeXEzI4fcBYO8MZbQwrvM//XdTXNDqBDZ QGPOnjK7+SDPw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes Subject: [PATCH 00/22] objtool: Reduce memory usage with CONFIG_DEBUG_INFO Date: Tue, 30 May 2023 10:20:52 -0700 Message-Id: X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org DWARF uses a LOT of relocations, causing objtool to need a LOT of memory for processing vmlinux.o. In the worst case of an allyesconfig+CONFIG_DEBUG_INFO kernel, DWARF creates almost 200 million relocations, ballooning objtool's peak heap usage to 53GB. These patches reduce that to 25GB. On a distro-type kernel with kernel IBT enabled, they reduce objtool's peak heap usage from 4.2GB to 2.8GB. They also improve the runtime significantly (from 2m50s to 1m54s on my system with allyesconfig+CONFIG_DEBUG_INFO), though most of that comes from fixing the size calculation for reloc_hash. Josh Poimboeuf (22): objtool: Tidy elf.h objtool: Remove flags argument from elf_create_section() objtool: Improve reloc naming objtool: Consolidate rel/rela handling objtool: Fix reloc_hash size objtool: Add mark_sec_changed() objtool: Add elf_create_section_pair() objtool: Keep GElf_Rel[a] structs synced objtool: Don't free memory in elf_close() objtool: Add for_each_reloc() objtool: Allocate relocs in advance for new rela sections objtool: Get rid of reloc->list objtool: Get rid of reloc->idx objtool: Get rid of reloc->offset objtool: Get rid of reloc->type objtool: Get rid of reloc->addend objtool: Get rid of reloc->jump_table_start objtool: Shrink reloc->sym_reloc_entry objtool: Shrink elf hash nodes objtool: Get rid of reloc->rel[a] objtool: Free insns when done objtool: Skip reading DWARF section data tools/objtool/arch/powerpc/include/arch/elf.h | 11 +- tools/objtool/arch/x86/decode.c | 6 +- tools/objtool/arch/x86/include/arch/elf.h | 11 +- tools/objtool/arch/x86/special.c | 6 +- tools/objtool/check.c | 429 +++++++------- tools/objtool/elf.c | 537 +++++++----------- tools/objtool/include/objtool/elf.h | 326 ++++++++--- tools/objtool/orc_gen.c | 8 +- tools/objtool/special.c | 4 +- 9 files changed, 698 insertions(+), 640 deletions(-) -- 2.40.1