From patchwork Tue Dec 27 16:00:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 3343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1459879wrt; Tue, 27 Dec 2022 08:03:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXtGfR47cdb2IxFIuEayJ2BZqptEAujYsQ2sfwxT6+L/B4q+w0Vdt7Gi/sA1hKEckTCwAZCi X-Received: by 2002:a17:906:5956:b0:81b:f617:eb99 with SMTP id g22-20020a170906595600b0081bf617eb99mr18201767ejr.67.1672157035806; Tue, 27 Dec 2022 08:03:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672157035; cv=none; d=google.com; s=arc-20160816; b=cHNbIzG1U8DOgr7STISYItXd4pCRpmM4MQddEvXqc6d2rnCFJsp1H+yVIVuTo/ppLg YNO5lGt6J/we8pQMqjYFHv+ACW5WHuLd53IuHJFbHCHVJj1ML0FBRYFvdEI7T0sw2XJl BRECzPwxHOlvbCurGL92Qq0onxA76pc8XaBWYFKxdvrOrehKmBFK/BszEG/sAj/dlqZz MaApvh8W7kMXWBBI0Sli5p80lGpST/H3HVoOedkFY6vW4/hRYKLt7oHzxrZK1OW18Yke pFXTFCGjeEzvKM8cZBEOpiFTiFb/V2oiXXUwedCBCVdkLv5+aOzZCOrBZUmaNmSOeq60 4iAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:content-transfer-encoding:mime-version :message-id:date:subject:dkim-signature:from; bh=Kavl+nY6yKPPFY91UM6cTSEyyYQ6WnqMthKfomHD1V0=; b=bzNhSPTpTGICOcEKa3jOMva7O2WctxfxwUswlY1TPKwEq7RdI7/JMhOq5u7iTHc+iI mY7l3sSU+60KaLaI40fW23nuqbu5S2wY52ETt0rib+YMtfKpW0bXFtA43OMBaCw4XERg SnXQS1yAwTFYqL94r9l+4WSyytgG2RBKcjYpwmGr108KU4QWsIMvzTlupzwwEt9VMk1X GPUf5ggiFhY5JhilN1hQ5mR1LhieWjJbYakVGcZ+BwZtS07cy04H2ubUh8SC4HbqmqSt 4c6bACMmdaN6Iu57YVsNTyfCc2fG4BjuGMEUAV3meQoUAIF/19DNLM5YkhC4VLzG8ZCx 1u2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=pB7BvWCk; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh39-20020a1709076ea700b008361e2a67b2si11022733ejc.0.2022.12.27.08.03.30; Tue, 27 Dec 2022 08:03:55 -0800 (PST) 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=fail header.i=@weissschuh.net header.s=mail header.b=pB7BvWCk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231723AbiL0QC5 (ORCPT + 99 others); Tue, 27 Dec 2022 11:02:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231521AbiL0QCt (ORCPT ); Tue, 27 Dec 2022 11:02:49 -0500 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19D7CF20 for ; Tue, 27 Dec 2022 08:02:47 -0800 (PST) From: Thomas =?utf-8?q?Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1672156964; bh=xSg7Iuav8suoTduBbOb9CQOu+RLLR8Kat74NxAQM5+M=; h=From:Subject:Date:To:Cc:From; b=pB7BvWCkxtxYBTl3id+BJnTPVNSz4l85aPymbB6t7MN5MOaoHoOsd0iRKzheEd4+B PRKiYXMoI9B7+X0wUG1yu4PgurHiPqOCwdo6s7WlRFtsyPAf8lOaVjj/7AfLNNxYbm cInKJbhKUPP7hf2HM2HA5iq0pmi03XmpJZwu0zJk= Subject: [PATCH v2 0/8] reduce maximum memory usage Date: Tue, 27 Dec 2022 16:00:57 +0000 Message-Id: <20221216-objtool-memory-v2-0-17968f85a464@weissschuh.net> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIALkWq2MC/3WNTQqDQAyFryJZN8VEsKWr3qO4cJzYmaIzMFFLE e/e0H1Xj+/xfnZQKVEUbtUORbaoMScDPlUwhD49BaM3Bq6ZianF7F5LzhPOMufywbr1rnFXNxIR WMn1KuhKn4ZgtbROk5kh6mLh38lGJo+/exthje3I3jfiLw3x/S1RVYewhnOSBbrjOL4wC4cGtgA AAA== To: Josh Poimboeuf , Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Thomas =?utf-8?q?Wei=C3=9Fschuh?= X-Mailer: b4 0.11.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1672156865; l=1789; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=xSg7Iuav8suoTduBbOb9CQOu+RLLR8Kat74NxAQM5+M=; b=Pryh6ZlQfLoaMXdHAG1AJBDrwlIp9neEIvLGw8009KmFhCr53XZG0K5u0/QEq3qYZLhu21A1kdV7 sHXaM4aWDQdzJLSD1//NBoDs13d7JzlLy1/533Lm9BhDNzyEndhe X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_NONE,SPF_PASS autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753383735780215870?= X-GMAIL-MSGID: =?utf-8?q?1753383735780215870?= The processing of vmlinux.o with objtool is the most memory-intensive step of a kernel build. By reducing the maximum memory usage here we can reduce the maximum memory usage of the whole kernel build. Therefore memory pressure on memory starved machines is relieved during kernel builds and the build is faster as less swapping has to occur. To: Josh Poimboeuf To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org Signed-off-by: Thomas Weißschuh --- Changes in v2: - Warn on out of range values for reloc->type - Also reduce size of struct special_alt - Note: v1 did not make it to the lists, only to individual recipients --- Thomas Weißschuh (8): objtool: make struct entries[] static and const objtool: make struct check_options static objtool: allocate multiple structures with calloc() objtool: introduce function elf_reloc_set_type objtool: reduce memory usage of struct reloc objtool: optimize layout of struct symbol objtool: optimize layout of struct special_alt objtool: explicitly cleanup resources on success tools/objtool/builtin-check.c | 4 ++- tools/objtool/check.c | 6 ++-- tools/objtool/elf.c | 56 +++++++++++++++++++-------------- tools/objtool/include/objtool/builtin.h | 2 -- tools/objtool/include/objtool/elf.h | 13 +++++--- tools/objtool/include/objtool/special.h | 2 +- tools/objtool/special.c | 6 ++-- 7 files changed, 51 insertions(+), 38 deletions(-) --- base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2 change-id: 20221216-objtool-memory-06db3b8bf111 Best regards,