Message ID | 20221216-objtool-memory-v2-0-17968f85a464@weissschuh.net |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;eddaouddi.ayoub@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; Tue, 27 Dec 2022 08:02:47 -0800 (PST) From: Thomas =?utf-8?q?Wei=C3=9Fschuh?= <linux@weissschuh.net> 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-B4-Tracking: v=1; b=H4sIALkWq2MC/3WNTQqDQAyFryJZN8VEsKWr3qO4cJzYmaIzMFFLE e/e0H1Xj+/xfnZQKVEUbtUORbaoMScDPlUwhD49BaM3Bq6ZianF7F5LzhPOMufywbr1rnFXNxIR WMn1KuhKn4ZgtbROk5kh6mLh38lGJo+/exthje3I3jfiLw3x/S1RVYewhnOSBbrjOL4wC4cGtgA AAA== To: Josh Poimboeuf <jpoimboe@kernel.org>, Peter Zijlstra <peterz@infradead.org> Cc: linux-kernel@vger.kernel.org, Thomas =?utf-8?q?Wei=C3=9Fschuh?= <linux@weissschuh.net> 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: <linux-kernel.vger.kernel.org> 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?= |
Series |
reduce maximum memory usage
|
|
Message
Thomas Weißschuh
Dec. 27, 2022, 4 p.m. UTC
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 <jpoimboe@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
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,
Comments
On Tue, Dec 27, 2022 at 04:00:57PM +0000, Thomas Weißschuh wrote: > 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. Friendly ping. These patches can also applied one by one, the only dependency is from patch 5 to patch 4. Thanks, Thomas > To: Josh Poimboeuf <jpoimboe@kernel.org> > To: Peter Zijlstra <peterz@infradead.org> > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > --- > 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, > -- > Thomas Weißschuh <linux@weissschuh.net>
On Sun, Jan 29, 2023 at 09:43:39PM +0000, Thomas Weißschuh wrote: > On Tue, Dec 27, 2022 at 04:00:57PM +0000, Thomas Weißschuh wrote: > > 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. > > Friendly ping. > > These patches can also applied one by one, the only dependency is from > patch 5 to patch 4. Thanks, I'll go ahead and take five of them now.
On Mon, Jan 30, 2023 at 04:03:56PM -0800, Josh Poimboeuf wrote: > On Sun, Jan 29, 2023 at 09:43:39PM +0000, Thomas Weißschuh wrote: > > On Tue, Dec 27, 2022 at 04:00:57PM +0000, Thomas Weißschuh wrote: > > > 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. > > > > Friendly ping. > > > > These patches can also applied one by one, the only dependency is from > > patch 5 to patch 4. > > Thanks, I'll go ahead and take five of them now. Thanks. I have another half-finished series that replaces the doubly-linked list_heads used by elf.h with a custom singly-linked list. This would save a few pointers per struct. Do you think this is worth it? Thomas
On Tue, Jan 31, 2023 at 03:54:42AM +0000, Thomas Weißschuh wrote: > On Mon, Jan 30, 2023 at 04:03:56PM -0800, Josh Poimboeuf wrote: > > On Sun, Jan 29, 2023 at 09:43:39PM +0000, Thomas Weißschuh wrote: > > > On Tue, Dec 27, 2022 at 04:00:57PM +0000, Thomas Weißschuh wrote: > > > > 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. > > > > > > Friendly ping. > > > > > > These patches can also applied one by one, the only dependency is from > > > patch 5 to patch 4. > > > > Thanks, I'll go ahead and take five of them now. > > Thanks. > > I have another half-finished series that replaces the doubly-linked > list_heads used by elf.h with a custom singly-linked list. > This would save a few pointers per struct. > > Do you think this is worth it? Maybe, depending on the memory savings.
From: Thomas Weißschuh. > Sent: 31 January 2023 03:55 ... > I have another half-finished series that replaces the doubly-linked > list_heads used by elf.h with a custom singly-linked list. > This would save a few pointers per struct. > > Do you think this is worth it? If you allocate the structures in blocks of (say) 256 you can use an array of pointers to the blocks and then a 32bit index instead of a 64bit pointer. For real space-saving you might decide that the index can never exceed 2^^24 and use a bitfield! David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Tue, Jan 31, 2023 at 09:27:15AM -0800, Josh Poimboeuf wrote: > On Tue, Jan 31, 2023 at 03:54:42AM +0000, Thomas Weißschuh wrote: > > On Mon, Jan 30, 2023 at 04:03:56PM -0800, Josh Poimboeuf wrote: > > > On Sun, Jan 29, 2023 at 09:43:39PM +0000, Thomas Weißschuh wrote: > > > > On Tue, Dec 27, 2022 at 04:00:57PM +0000, Thomas Weißschuh wrote: > > > > > 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. > > > > > > > > Friendly ping. > > > > > > > > These patches can also applied one by one, the only dependency is from > > > > patch 5 to patch 4. > > > > > > Thanks, I'll go ahead and take five of them now. > > > > Thanks. > > > > I have another half-finished series that replaces the doubly-linked > > list_heads used by elf.h with a custom singly-linked list. > > This would save a few pointers per struct. > > > > Do you think this is worth it? > > Maybe, depending on the memory savings. FYI, there were more memory usage complaints, so Peter worked up a nice series to do this and more: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/log/?h=objtool/core