Re: [PATCH v2 1/2] vsprintf: Only export no_hash_pointers to test module

From: Thomas Weißschuh

Date: Mon May 18 2026 - 06:10:44 EST


On Thu, May 14, 2026 at 01:58:06PM +0200, Petr Mladek wrote:
> On Mon 2026-05-04 13:53:47, Thomas Weißschuh wrote:
> > On Mon, May 04, 2026 at 01:57:31PM +0300, Andy Shevchenko wrote:
> > > On Mon, May 04, 2026 at 12:43:40PM +0200, Thomas Weißschuh wrote:
> > > > Aside from the printf test module, no module should ever use this symbol.
> > >
> > > ...
> > >
> > > > -EXPORT_SYMBOL_GPL(no_hash_pointers);
> > >
> > > > +#if IS_MODULE(CONFIG_PRINTF_KUNIT_TEST)
> > > > +EXPORT_SYMBOL_FOR_MODULES(no_hash_pointers, "printf_kunit");
> > > > +#endif
> > >
> > > But do we need that ugly ifdeffery? the infrastructure should handle that.
> >
> > Where does the generic infrastructure take the kconfig option into account?
>
> My understanding is that it does not harm when the symbol is exported
> even when the related module is built-in or not built at all.

I think it wastes a bit of space in the kernel image, not that it would matter.

> The important thing is that it is exported only for this particular module (name).

Theoretically an out-of-tree module could assume this name to get access
to the symbol, which I was trying to prevent. But that is a theoretical edge
case and I am absolutely fine with not caring about it.

My OCD insists that we should have a variant of EXPORT_SYMBOL_FOR_MODULES()
which does handle the corresponding kconfig settings, maybe even automatically.
Something for the wishlist.

> BTW: I have just tried to remove the ifdeffery and use a built-in
> printf_kunit and it works fine.
>
> > > (Also, if I build a module separately after the kernel, it won't work.)
> >
> > Only if it was not enabled when the kernel was built.
> >
> > But if people are unhappy with the ifdeffery, I'm fine with dropping it.
> > It is not a hard requirement at all.
>
> Yeah, I would prefer to remove the ifdeffery. It does not look worth
> it.
>
> Without the ifdeffery:
>
> Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
> Tested-by: Petr Mladek <pmladek@xxxxxxxx>
>
> Best Regards,
> Petr
>
> PS: No need to send v3, I could remove the ifdeffery when pushing the patch.

Works for me, thanks!


Thomas