Re: [PATCH] module: Add stubs.c for CONFIG_MODULES=n module_put_and_kthread_exit()
From: Petr Pavlu
Date: Fri Sep 25 2026 - 05:21:22 EST
On 9/22/26 4:16 PM, bot+bpf-ci@xxxxxxxxxx wrote:
>> diff --git a/kernel/module/stubs.c b/kernel/module/stubs.c
>> new file mode 100644
>> index 0000000000000..81e66c02260c8
>> --- /dev/null
>> +++ b/kernel/module/stubs.c
>> @@ -0,0 +1,11 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +
>> +#include <linux/kthread.h>
>> +#include <linux/module.h>
>> +#include "internal.h"
>
> This isn't a bug, but does stubs.c need "internal.h" here, or would
> <linux/kthread.h> plus <linux/module.h> be enough?
>
> kthread_exit() comes from <linux/kthread.h>, and struct module,
> __noreturn, and EXPORT_SYMBOL come from <linux/module.h>. The file
> doesn't appear to use anything that internal.h provides.
>
> This makes stubs.c the only consumer of that header outside
> CONFIG_MODULES=y, which future internal.h changes would have to keep
> working.
Ack.
>
>> +
>> +void __noreturn __module_put_and_kthread_exit(struct module *mod, long code)
>> +{
>> + kthread_exit(code);
>> +}
>> +EXPORT_SYMBOL(__module_put_and_kthread_exit);
>
> This isn't a bug, but since stubs.o only exists for CONFIG_MODULES=n, is
> the EXPORT_SYMBOL() reachable by any module, or can it be dropped?
>
> No loadable module can resolve this export when CONFIG_MODULES=n. The
> macro still expands (producing an .export_symbol entry that
> COMMON_DISCARDS drops at link, plus __ADDRESSABLE()), so it's harmless
> but has no consumer.
>
> kernel/time/posix-stubs.c, cited in the commit message as the model,
> exports nothing.
Ack.
I'll incorporate these two suggested cleanups in v2.
-- Petr