From patchwork Thu Nov 17 17:16:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 21852 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp522046wrr; Thu, 17 Nov 2022 09:20:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf7AXKStlKA3555+atEe8q3vaGHyJo/clHBRGFZBqEUqrInjffFOgO7IBWfLYSWO7s809+eY X-Received: by 2002:a17:906:2b56:b0:78d:b6ea:174e with SMTP id b22-20020a1709062b5600b0078db6ea174emr2903530ejg.95.1668705615700; Thu, 17 Nov 2022 09:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668705615; cv=none; d=google.com; s=arc-20160816; b=s8lVKmqyYjkZfORK8jG+/zdv44kSg5sjy/KWB1qMV47Xo90xtASauY3LXPovuVXZUd SHPILTQGqZj8e9H8aQq5DIcUC6Kp9bUDA7TuyliO+XZHD5wXT1AkCxBx5ksT6wZQWlzL DluJ+VIRhDn2ytaovIyKxi2sY47ipbifVwgd3GPQX+RHEZmuvPBtTy5kH4AcokXMQTwO NMu+SqQ6ST2h6rxHBcZ/kxkKt3fkhd5r5EPzgab3/zlBGUZOCODVe6NxfNiKEJNfYH/t uo7A1f7hV/pDR9P41+3jpnHQNiujdCN+A62yD2SkgFzgmo/02IpaRf6164sX0A2yjtSm lh/g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Wlb4nC9DiXpO42QAvf6JoYYqoUdGTO9JI9f6xMWbJYA=; b=FbPEXFpfl3kEmchGfq1BPsgFoLWQJ+NKP6W4Ea6VpyKFOtF+SNrI1h3j4nCiAnCgXX JgIEvoKrcle6O+all3lHj/6vopRBic26YkJ8pccFszoJhs+lzDUSEzq5sTQ1LWuiEKvT NIt5UjWpMqlh9EM7B97KJ9qofrAT64RPBE+MimzF0I0ikE/jSXylJh8yM+07xxpy1WNs /s88H0cHuftm6H/6VZJbTzrpE9eoytMM9Lu1FvsuZzZJ0+qoLs+JHzhY9PL0fpponJrA CEQb5JpQRrrkr063w6fW3fh+LxQNjbedF9GwL9KGsy5GLK2jFCsOHveij8khhyVlLQWD xRLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=awTeIDv6; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020a1709065d0c00b007824b85978asi1022656ejt.81.2022.11.17.09.19.49; Thu, 17 Nov 2022 09:20:15 -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=pass header.i=@gmail.com header.s=20210112 header.b=awTeIDv6; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240590AbiKQRQy (ORCPT + 99 others); Thu, 17 Nov 2022 12:16:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240235AbiKQRQp (ORCPT ); Thu, 17 Nov 2022 12:16:45 -0500 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06C1C786D9 for ; Thu, 17 Nov 2022 09:16:44 -0800 (PST) Received: by mail-io1-xd34.google.com with SMTP id h206so1843088iof.10 for ; Thu, 17 Nov 2022 09:16:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wlb4nC9DiXpO42QAvf6JoYYqoUdGTO9JI9f6xMWbJYA=; b=awTeIDv6fg3KHIIIrRiWuAGtdhW00GmDoj4Wnpn0OOhaVTbA4ZxNVZWHvmD/RSWWwn QSZ8dJZis0G7sL/0xt9hR1po6coA0mHVOwgRrPQUuXW04PyrVlhk5CU24yyKGQuMRidI kU+s0/UCbgNdoDlAXyjcfqYFJS4tt8UuHd8w5hspXqKLg2+DkKf7lLq+07ETeGsDCrOr LQNwiJ6WcZFaBD/LTZXRvjwPPiQuM1Y+D6YVEJNv2urkcJRVRGJ0+x4jYqCdVDDfc5yo 7kp5ZB04aWLleSC476bymda6lNDdPQ0IymleoKlXkXQNXN04lofzu1FXEudfPCCfNEZD K0Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wlb4nC9DiXpO42QAvf6JoYYqoUdGTO9JI9f6xMWbJYA=; b=felK7abin8ZmY6fPNFu62gJ+fLTvgdh5ERpcijzJQ55AXV206U+z/QUew7SlHqVBB2 8S5UHoKtFjKqqvVir49CJK5oZnxR99Ar22teof0DvtnsImlLrk6NbvjDIL0wXqyy18Uz wwH+MTSZmeOSKP/JveuUQDltexXyfaM33Qx/Kriwbe8DhpVmoqrweeI5wjIq/rzA1I75 2IPf4qctSLCegR9Rb698lK9qR52W0UXzG/Ek5s7S9sIF+qi9ROKJ2tgm7+GrKzS5cpQX sRFkD0rTeqUCoat0TCFYLEuHZ+At4E980x2toeoFNL/ltBSmlrizrFkF350d4H0mV0zR bMkA== X-Gm-Message-State: ANoB5plEbiGkfquyGdb5xS2mn5CQTzk01XgRyuAHVJctCG7d2TmXAIL3 WLiDFtOY6I144JLxLF0FtaI= X-Received: by 2002:a05:6638:4308:b0:376:246:e637 with SMTP id bt8-20020a056638430800b003760246e637mr1517322jab.260.1668705403314; Thu, 17 Nov 2022 09:16:43 -0800 (PST) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id o1-20020a92d381000000b002faf6559e90sm495322ilo.51.2022.11.17.09.16.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 09:16:42 -0800 (PST) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: Jim Cromie Subject: [PATCH 2/2] vmlinux.lds.h: add HEADERED_SECTION_* macros Date: Thu, 17 Nov 2022 10:16:33 -0700 Message-Id: <20221117171633.923628-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117171633.923628-1-jim.cromie@gmail.com> References: <20221117171633.923628-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749764659337508986?= X-GMAIL-MSGID: =?utf-8?q?1749764659337508986?= These macros elaborate on BOUNDED_SECTION_(PRE|POST)_LABEL macros, prepending an optional KEEP(.gnu.linkonce##_sec_) reservation, and a linker-symbol to address it. This allows a developer to define a header struct (which must fit with the section's base struct-type), and could contain: 1- fields whose value is common to the entire set of data-records. This allows the header & data structs to specialize, complement each other, and shrink. 2- an uplink pointer to an organizing struct which refs other related/sub data-tables header record is addressable via the extern'd header linker-symbol Once the linker-symbols created by the macro are ref'd extern in code, that code can compute a record's index (ptr - start) in the "primary" table, then use it to index into the related/sub tables. Adding a primary.map_* field foreach sub-table would then allow deduplication and remapping of that sub-table. This is aimed at dyndbg's struct _ddebug __dyndbg[] section, whose 3 columns: function, file, module are 50%, 90%, 100% redundant. The module column is fully recoverable after dynamic_debug_init() saves it to each ddebug_table.module as the builtin __dyndbg[] table is parsed. Given that those 3 columns use 24/56 of a _ddebug record, a dyndbg=y kernel with ~5k callsites could reduce kernel memory substantially. Returning that memory to the kernel buddy-allocator? is then possible. Signed-off-by: Jim Cromie --- --- include/asm-generic/vmlinux.lds.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index c17f94785253..c9a475a30803 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -208,6 +208,21 @@ #define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) +#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \ + _HDR_##_label_ = .; \ + KEEP(*(.gnu.linkonce.##_sec_)) \ + BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) + +#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \ + _label_##_HDR_ = .; \ + KEEP(*(.gnu.linkonce.##_sec_)) \ + BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) + +#define HEADERED_SECTION_BY(_sec_, _label_) \ + HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) + +#define HEADERED_SECTION(_sec) HEADERED_SECTION_BY(_sec, _sec) + #ifdef CONFIG_TRACE_BRANCH_PROFILING #define LIKELY_PROFILE() \ BOUNDED_SECTION_BY(_ftrace_annotated_branch, _annotated_branch_profile)