From: Siddharth Nayyar <sidnayyar@google.com>
To: Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Aaron Tomlin <atomlin@atomlin.com>,
Arnd Bergmann <arnd@arndb.de>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org,
linux-doc@vger.kernel.org,
Siddharth Nayyar <sidnayyar@google.com>,
maennich@google.com, gprocida@google.com
Subject: [PATCH v4 0/8] scalable symbol flags with __kflagstab
Date: Thu, 05 Mar 2026 16:55:16 +0000 [thread overview]
Message-ID: <20260305-kflagstab-v4-0-6a76bf8b83c7@google.com> (raw)
This patch series implements a mechanism for scalable exported symbol
flags using a separate section called __kflagstab. The series introduces
__kflagstab support, removes *_gpl sections in favor of a GPL flag,
simplifies symbol resolution during module loading.
The __kflagstab contains an 8-bit bitset which can represent up to 8
boolean flags per symbol exported in the __ksymtab. The patch series
also uses this bitset to store GPL-only flag values for kernel symbols,
thereby eliminating the need for *_gpl sections for representing GPL
only symbols.
Petr Pavlu ran a small test to get a better understanding of the
different section sizes resulting from this patch series. He used
v6.17-rc6 together with the openSUSE x86_64 config [1], which is fairly
large. The resulting vmlinux.bin (no debuginfo) had an on-disk size of
58 MiB, and included 5937 + 6589 (GPL-only) exported symbols.
The following table summarizes his measurements and calculations
regarding the sizes of all sections related to exported symbols:
| HAVE_ARCH_PREL32_RELOCATIONS | !HAVE_ARCH_PREL32_RELOCATIONS
Section | Base [B] | Ext. [B] | Sep. [B] | Base [B] | Ext. [B] | Sep. [B]
----------------------------------------------------------------------------------------
__ksymtab | 71244 | 200416 | 150312 | 142488 | 400832 | 300624
__ksymtab_gpl | 79068 | NA | NA | 158136 | NA | NA
__kcrctab | 23748 | 50104 | 50104 | 23748 | 50104 | 50104
__kcrctab_gpl | 26356 | NA | NA | 26356 | NA | NA
__ksymtab_strings | 253628 | 253628 | 253628 | 253628 | 253628 | 253628
__kflagstab | NA | NA | 12526 | NA | NA | 12526
----------------------------------------------------------------------------------------
Total | 454044 | 504148 | 466570 | 604356 | 704564 | 616882
Increase to base [%] | NA | 11.0 | 2.8 | NA | 16.6 | 2.1
The column "HAVE_ARCH_PREL32_RELOCATIONS -> Base" contains themeasured
numbers. The rest of the values are calculated. The "Ext." column
represents an alternative approach of extending __ksymtab to include a
bitset of symbol flags, and the "Sep." column represents the approach of
having a separate __kflagstab. With HAVE_ARCH_PREL32_RELOCATIONS, each
kernel_symbol is 12 B in size and is extended to 16 B. With
!HAVE_ARCH_PREL32_RELOCATIONS, it is 24 B, extended to 32 B. Note that
this does not include the metadata needed to relocate __ksymtab*, which
is freed after the initial processing.
The base export data in this case totals 0.43 MiB. About 50% is used for
storing the names of exported symbols.
Adding __kflagstab as a separate section has a negligible impact, as
expected. When extending __ksymtab (kernel_symbol) instead, the worst
case with !HAVE_ARCH_PREL32_RELOCATIONS increases the export data size
by 16.6%. Note that the larger increase in size for the latter approach
is due to 4-byte alignment of kernel_symbol data structure, instead of
1-byte alignment for the flags bitset in __kflagstab in the former
approach.
Based on the above, it was concluded that introducing __kflagstab makes
senses, as the added complexity is minimal over extending kernel_symbol,
and there is overall simplification of symbol finding logic in the
module loader.
Thank you Petr Pavlu for doing a section size analysis as well as Sami
Tolvanen, Petr Pavlu and Jonathan Corbet for their valuable feedback.
---
Changes from v3:
- made commit messages more descriptive
v3:
https://lore.kernel.org/20251103161954.1351784-1-sidnayyar@google.com/
Changes from v2:
- dropped symbol import protection to spin off into its own series
v2:
https://lore.kernel.org/20251013153918.2206045-1-sidnayyar@google.com/
Changes from v1:
- added a check to ensure __kflagstab is present
- added warnings for the obsolete *_gpl sections
- moved protected symbol check before ref_module() call
- moved protected symbol check failure warning to issue detection point
v1:
https://lore.kernel.org/20250829105418.3053274-1-sidnayyar@google.com/
[1] https://github.com/openSUSE/kernel-source/blob/307f149d9100a0e229eb94cbb997ae61187995c3/config/x86_64/default
Signed-off-by: Siddharth Nayyar <sidnayyar@google.com>
---
Siddharth Nayyar (8):
define ksym_flags enumeration to represent kernel symbol flags
linker: add kflagstab section to vmlinux and modules
modpost: populate kflagstab
module loader: use kflagstab instead of *_gpl sections
modpost: remove fragmentation of ksymtab and kcrctab sections
module loader: deprecate usage of *_gpl sections
linker: remove *_gpl sections from vmlinux and modules
documentation: remove references to *_gpl sections
Documentation/kbuild/modules.rst | 11 +++--
include/asm-generic/vmlinux.lds.h | 21 +++-----
include/linux/export-internal.h | 28 +++++++----
include/linux/module.h | 4 +-
include/linux/module_symbol.h | 5 ++
kernel/module/internal.h | 4 +-
kernel/module/main.c | 101 ++++++++++++++++++--------------------
scripts/mod/modpost.c | 16 ++++--
scripts/module.lds.S | 3 +-
9 files changed, 98 insertions(+), 95 deletions(-)
---
base-commit: c107785c7e8dbabd1c18301a1c362544b5786282
change-id: 20260305-kflagstab-51a08efed244
Best regards,
--
Siddharth Nayyar <sidnayyar@google.com>
next reply other threads:[~2026-03-05 16:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 16:55 Siddharth Nayyar [this message]
2026-03-05 16:55 ` [PATCH v4 1/8] define ksym_flags enumeration to represent kernel symbol flags Siddharth Nayyar
2026-03-05 16:55 ` [PATCH v4 2/8] linker: add kflagstab section to vmlinux and modules Siddharth Nayyar
2026-03-05 16:55 ` [PATCH v4 3/8] modpost: populate kflagstab Siddharth Nayyar
2026-03-05 16:55 ` [PATCH v4 4/8] module loader: use kflagstab instead of *_gpl sections Siddharth Nayyar
2026-03-05 16:55 ` [PATCH v4 5/8] modpost: remove fragmentation of ksymtab and kcrctab sections Siddharth Nayyar
2026-03-05 16:55 ` [PATCH v4 6/8] module loader: deprecate usage of *_gpl sections Siddharth Nayyar
2026-03-05 16:55 ` [PATCH v4 7/8] linker: remove *_gpl sections from vmlinux and modules Siddharth Nayyar
2026-03-05 16:55 ` [PATCH v4 8/8] documentation: remove references to *_gpl sections Siddharth Nayyar
2026-03-25 12:49 ` [PATCH v4 0/8] scalable symbol flags with __kflagstab Petr Pavlu
2026-03-26 21:31 ` Sid Nayyar
-- strict thread matches above, loose matches on Subject: below --
2026-03-05 16:54 Siddharth Nayyar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260305-kflagstab-v4-0-6a76bf8b83c7@google.com \
--to=sidnayyar@google.com \
--cc=arnd@arndb.de \
--cc=atomlin@atomlin.com \
--cc=corbet@lwn.net \
--cc=da.gomez@kernel.org \
--cc=gprocida@google.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=maennich@google.com \
--cc=mcgrof@kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox