Re: [PATCH 3/9] kernel/api: add debugfs interface for kernel API specifications
From: Sasha Levin <sashal@kernel.org>
Date: 2026-03-13 16:27:34
Also in:
linux-doc, linux-fsdevel, linux-kbuild, linux-kselftest, lkml, tools, workflows
On Fri, Mar 13, 2026 at 04:32:23PM +0100, Greg Kroah-Hartman wrote:
On Fri, Mar 13, 2026 at 11:09:13AM -0400, Sasha Levin wrote:quoted
Add a debugfs interface to expose kernel API specifications at runtime. This allows tools and users to query the complete API specifications through the debugfs filesystem. The interface provides: - /sys/kernel/debug/kapi/list - lists all available API specifications - /sys/kernel/debug/kapi/specs/<name> - detailed info for each API Each specification file includes: - Function name, version, and descriptions - Execution context requirements and flags - Parameter details with types, flags, and constraints - Return value specifications and success conditions - Error codes with descriptions and conditions - Locking requirements and constraints - Signal handling specifications - Examples, notes, and deprecation status This enables runtime introspection of kernel APIs for documentation tools, static analyzers, and debugging purposes. Signed-off-by: Sasha Levin <sashal@kernel.org> --- Documentation/dev-tools/kernel-api-spec.rst | 88 ++--You are removing stuff from the file you created earlier in this patch series, is that ok?
Sorry, just a rebasing artifact from shuffling patches around. I'll fix it.
quoted
--- /dev/null +++ b/kernel/api/kapi_debugfs.c@@ -0,0 +1,503 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Kernel API specification debugfs interface + * + * This provides a debugfs interface to expose kernel API specifications + * at runtime, allowing tools and users to query the complete API specs. + */No copyright line? :)
I'll add one.
And this is, a totally and crazy interface with debugfs, I love it!
Thanks :)
Two minor minor nits:quoted
+static int __init kapi_debugfs_init(void) +{ + struct kernel_api_spec *spec; + struct dentry *spec_dir; + + /* Create main directory */ + kapi_debugfs_root = debugfs_create_dir("kapi", NULL); + + /* Create list file */ + debugfs_create_file("list", 0444, kapi_debugfs_root, NULL, &kapi_list_fops); + + /* Create specs subdirectory */ + spec_dir = debugfs_create_dir("specs", kapi_debugfs_root); + + /* Create a file for each API spec */ + for (spec = __start_kapi_specs; spec < __stop_kapi_specs; spec++) { + debugfs_create_file(spec->name, 0444, spec_dir, spec, &kapi_spec_fops); + }No need for { }
ack
quoted
+ + pr_info("Kernel API debugfs interface initialized\n");When code is working properly, it should be quiet, no need for this as initializing this can not fail.
ack -- Thanks, Sasha