diff mbox series

[rdma-next] RDMA/nldev: Fix section mismatch warning for nldev

Message ID 50e3139ef8cbbff5db858a4916be309e012313b1.1666940305.git.leon@kernel.org (mailing list archive)
State Superseded
Delegated to: Jason Gunthorpe
Headers show
Series [rdma-next] RDMA/nldev: Fix section mismatch warning for nldev | expand

Commit Message

Leon Romanovsky Oct. 28, 2022, 6:58 a.m. UTC
ppc64_defconfig) produced this warning:

WARNING: modpost: drivers/infiniband/core/ib_core.o: section mismatch in reference: .init_module (section: .init.text) -> .nldev_exit (section: .exit.text)

Fix it by removing __init/__exit markers as nldev is part of ib_core.ko
and as such doesn't require any special notations for entry/exit functions.

Fixes: 6c80b41abe22 ("RDMA/netlink: Add nldev initialization flows")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
---
 drivers/infiniband/core/nldev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Leon Romanovsky Oct. 28, 2022, 7:12 a.m. UTC | #1
On Fri, Oct 28, 2022 at 09:58:56AM +0300, Leon Romanovsky wrote:
> ppc64_defconfig) produced this warning:
> 
> WARNING: modpost: drivers/infiniband/core/ib_core.o: section mismatch in reference: .init_module (section: .init.text) -> .nldev_exit (section: .exit.text)
> 
> Fix it by removing __init/__exit markers as nldev is part of ib_core.ko
> and as such doesn't require any special notations for entry/exit functions.
> 
> Fixes: 6c80b41abe22 ("RDMA/netlink: Add nldev initialization flows")
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Signed-off-by: Leon Romanovsky <leon@kernel.org>
> ---
>  drivers/infiniband/core/nldev.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

BTW, this was reported for rdma-rc and should go there.

Thanks
Jason Gunthorpe Oct. 28, 2022, 4 p.m. UTC | #2
On Fri, Oct 28, 2022 at 09:58:56AM +0300, Leon Romanovsky wrote:
> ppc64_defconfig) produced this warning:
> 
> WARNING: modpost: drivers/infiniband/core/ib_core.o: section mismatch in reference: .init_module (section: .init.text) -> .nldev_exit (section: .exit.text)
> 
> Fix it by removing __init/__exit markers as nldev is part of ib_core.ko
> and as such doesn't require any special notations for entry/exit functions.

This isn't what the problem is, the patch Stephen reported:

commit ad9394a3da33995dff828dbfd4540421e535bec9 (ko-rdma/for-rc)
Author: Chen Zhongjin <chenzhongjin@huawei.com>
Date:   Tue Oct 25 10:41:46 2022 +0800

    RDMA/core: Fix null-ptr-deref in ib_core_cleanup()

Adds a call to an __exit function from an __init function:

@@ -2815,10 +2815,18 @@ static int __init ib_core_init(void)

+err_parent:
+       rdma_nl_unregister(RDMA_NL_LS);
+       nldev_exit();
+       unregister_pernet_device(&rdma_dev_net_ops);

Which is not allowed

All that is required is to drop the __exit from nldev_exit, I'm going
to squash it in since I had to rebase it anyhow.

Jason
Leon Romanovsky Oct. 28, 2022, 4:14 p.m. UTC | #3
On Fri, Oct 28, 2022 at 01:00:27PM -0300, Jason Gunthorpe wrote:
> On Fri, Oct 28, 2022 at 09:58:56AM +0300, Leon Romanovsky wrote:
> > ppc64_defconfig) produced this warning:
> > 
> > WARNING: modpost: drivers/infiniband/core/ib_core.o: section mismatch in reference: .init_module (section: .init.text) -> .nldev_exit (section: .exit.text)
> > 
> > Fix it by removing __init/__exit markers as nldev is part of ib_core.ko
> > and as such doesn't require any special notations for entry/exit functions.
> 
> This isn't what the problem is, the patch Stephen reported:
> 
> commit ad9394a3da33995dff828dbfd4540421e535bec9 (ko-rdma/for-rc)
> Author: Chen Zhongjin <chenzhongjin@huawei.com>
> Date:   Tue Oct 25 10:41:46 2022 +0800
> 
>     RDMA/core: Fix null-ptr-deref in ib_core_cleanup()
> 
> Adds a call to an __exit function from an __init function:
> 
> @@ -2815,10 +2815,18 @@ static int __init ib_core_init(void)
> 
> +err_parent:
> +       rdma_nl_unregister(RDMA_NL_LS);
> +       nldev_exit();
> +       unregister_pernet_device(&rdma_dev_net_ops);
> 
> Which is not allowed
> 
> All that is required is to drop the __exit from nldev_exit, 

This is why I dropped both __exit and __init. I see no value in keeping
__init, without __exit.

Thanks
Jason Gunthorpe Oct. 28, 2022, 4:15 p.m. UTC | #4
On Fri, Oct 28, 2022 at 07:14:16PM +0300, Leon Romanovsky wrote:
> On Fri, Oct 28, 2022 at 01:00:27PM -0300, Jason Gunthorpe wrote:
> > On Fri, Oct 28, 2022 at 09:58:56AM +0300, Leon Romanovsky wrote:
> > > ppc64_defconfig) produced this warning:
> > > 
> > > WARNING: modpost: drivers/infiniband/core/ib_core.o: section mismatch in reference: .init_module (section: .init.text) -> .nldev_exit (section: .exit.text)
> > > 
> > > Fix it by removing __init/__exit markers as nldev is part of ib_core.ko
> > > and as such doesn't require any special notations for entry/exit functions.
> > 
> > This isn't what the problem is, the patch Stephen reported:
> > 
> > commit ad9394a3da33995dff828dbfd4540421e535bec9 (ko-rdma/for-rc)
> > Author: Chen Zhongjin <chenzhongjin@huawei.com>
> > Date:   Tue Oct 25 10:41:46 2022 +0800
> > 
> >     RDMA/core: Fix null-ptr-deref in ib_core_cleanup()
> > 
> > Adds a call to an __exit function from an __init function:
> > 
> > @@ -2815,10 +2815,18 @@ static int __init ib_core_init(void)
> > 
> > +err_parent:
> > +       rdma_nl_unregister(RDMA_NL_LS);
> > +       nldev_exit();
> > +       unregister_pernet_device(&rdma_dev_net_ops);
> > 
> > Which is not allowed
> > 
> > All that is required is to drop the __exit from nldev_exit, 
> 
> This is why I dropped both __exit and __init. I see no value in keeping
> __init, without __exit.

__init works just fine, it will cause the code to be unload after the
module registration is compelted

__exit allows the code to be removed if the module is compiled in and
the __exit is never called

Jason
Leon Romanovsky Oct. 28, 2022, 4:19 p.m. UTC | #5
On Fri, Oct 28, 2022 at 01:15:16PM -0300, Jason Gunthorpe wrote:
> On Fri, Oct 28, 2022 at 07:14:16PM +0300, Leon Romanovsky wrote:
> > On Fri, Oct 28, 2022 at 01:00:27PM -0300, Jason Gunthorpe wrote:
> > > On Fri, Oct 28, 2022 at 09:58:56AM +0300, Leon Romanovsky wrote:
> > > > ppc64_defconfig) produced this warning:
> > > > 
> > > > WARNING: modpost: drivers/infiniband/core/ib_core.o: section mismatch in reference: .init_module (section: .init.text) -> .nldev_exit (section: .exit.text)
> > > > 
> > > > Fix it by removing __init/__exit markers as nldev is part of ib_core.ko
> > > > and as such doesn't require any special notations for entry/exit functions.
> > > 
> > > This isn't what the problem is, the patch Stephen reported:
> > > 
> > > commit ad9394a3da33995dff828dbfd4540421e535bec9 (ko-rdma/for-rc)
> > > Author: Chen Zhongjin <chenzhongjin@huawei.com>
> > > Date:   Tue Oct 25 10:41:46 2022 +0800
> > > 
> > >     RDMA/core: Fix null-ptr-deref in ib_core_cleanup()
> > > 
> > > Adds a call to an __exit function from an __init function:
> > > 
> > > @@ -2815,10 +2815,18 @@ static int __init ib_core_init(void)
> > > 
> > > +err_parent:
> > > +       rdma_nl_unregister(RDMA_NL_LS);
> > > +       nldev_exit();
> > > +       unregister_pernet_device(&rdma_dev_net_ops);
> > > 
> > > Which is not allowed
> > > 
> > > All that is required is to drop the __exit from nldev_exit, 
> > 
> > This is why I dropped both __exit and __init. I see no value in keeping
> > __init, without __exit.
> 
> __init works just fine, it will cause the code to be unload after the
> module registration is compelted

The code will be unloaded as part of ib_core unload. It is not different
from any other function call in ib_core_init() which is marked as __init.

Thanks
Jason Gunthorpe Oct. 28, 2022, 4:34 p.m. UTC | #6
On Fri, Oct 28, 2022 at 07:19:36PM +0300, Leon Romanovsky wrote:
> On Fri, Oct 28, 2022 at 01:15:16PM -0300, Jason Gunthorpe wrote:
> > On Fri, Oct 28, 2022 at 07:14:16PM +0300, Leon Romanovsky wrote:
> > > On Fri, Oct 28, 2022 at 01:00:27PM -0300, Jason Gunthorpe wrote:
> > > > On Fri, Oct 28, 2022 at 09:58:56AM +0300, Leon Romanovsky wrote:
> > > > > ppc64_defconfig) produced this warning:
> > > > > 
> > > > > WARNING: modpost: drivers/infiniband/core/ib_core.o: section mismatch in reference: .init_module (section: .init.text) -> .nldev_exit (section: .exit.text)
> > > > > 
> > > > > Fix it by removing __init/__exit markers as nldev is part of ib_core.ko
> > > > > and as such doesn't require any special notations for entry/exit functions.
> > > > 
> > > > This isn't what the problem is, the patch Stephen reported:
> > > > 
> > > > commit ad9394a3da33995dff828dbfd4540421e535bec9 (ko-rdma/for-rc)
> > > > Author: Chen Zhongjin <chenzhongjin@huawei.com>
> > > > Date:   Tue Oct 25 10:41:46 2022 +0800
> > > > 
> > > >     RDMA/core: Fix null-ptr-deref in ib_core_cleanup()
> > > > 
> > > > Adds a call to an __exit function from an __init function:
> > > > 
> > > > @@ -2815,10 +2815,18 @@ static int __init ib_core_init(void)
> > > > 
> > > > +err_parent:
> > > > +       rdma_nl_unregister(RDMA_NL_LS);
> > > > +       nldev_exit();
> > > > +       unregister_pernet_device(&rdma_dev_net_ops);
> > > > 
> > > > Which is not allowed
> > > > 
> > > > All that is required is to drop the __exit from nldev_exit, 
> > > 
> > > This is why I dropped both __exit and __init. I see no value in keeping
> > > __init, without __exit.
> > 
> > __init works just fine, it will cause the code to be unload after the
> > module registration is compelted
> 
> The code will be unloaded as part of ib_core unload. It is not different
> from any other function call in ib_core_init() which is marked as __init.

Huh?

Only things marked __init are discarded after module load

Jason
Leon Romanovsky Oct. 28, 2022, 4:47 p.m. UTC | #7
On Fri, Oct 28, 2022 at 01:34:57PM -0300, Jason Gunthorpe wrote:
> On Fri, Oct 28, 2022 at 07:19:36PM +0300, Leon Romanovsky wrote:
> > On Fri, Oct 28, 2022 at 01:15:16PM -0300, Jason Gunthorpe wrote:
> > > On Fri, Oct 28, 2022 at 07:14:16PM +0300, Leon Romanovsky wrote:
> > > > On Fri, Oct 28, 2022 at 01:00:27PM -0300, Jason Gunthorpe wrote:
> > > > > On Fri, Oct 28, 2022 at 09:58:56AM +0300, Leon Romanovsky wrote:
> > > > > > ppc64_defconfig) produced this warning:
> > > > > > 
> > > > > > WARNING: modpost: drivers/infiniband/core/ib_core.o: section mismatch in reference: .init_module (section: .init.text) -> .nldev_exit (section: .exit.text)
> > > > > > 
> > > > > > Fix it by removing __init/__exit markers as nldev is part of ib_core.ko
> > > > > > and as such doesn't require any special notations for entry/exit functions.
> > > > > 
> > > > > This isn't what the problem is, the patch Stephen reported:
> > > > > 
> > > > > commit ad9394a3da33995dff828dbfd4540421e535bec9 (ko-rdma/for-rc)
> > > > > Author: Chen Zhongjin <chenzhongjin@huawei.com>
> > > > > Date:   Tue Oct 25 10:41:46 2022 +0800
> > > > > 
> > > > >     RDMA/core: Fix null-ptr-deref in ib_core_cleanup()
> > > > > 
> > > > > Adds a call to an __exit function from an __init function:
> > > > > 
> > > > > @@ -2815,10 +2815,18 @@ static int __init ib_core_init(void)
> > > > > 
> > > > > +err_parent:
> > > > > +       rdma_nl_unregister(RDMA_NL_LS);
> > > > > +       nldev_exit();
> > > > > +       unregister_pernet_device(&rdma_dev_net_ops);
> > > > > 
> > > > > Which is not allowed
> > > > > 
> > > > > All that is required is to drop the __exit from nldev_exit, 
> > > > 
> > > > This is why I dropped both __exit and __init. I see no value in keeping
> > > > __init, without __exit.
> > > 
> > > __init works just fine, it will cause the code to be unload after the
> > > module registration is compelted
> > 
> > The code will be unloaded as part of ib_core unload. It is not different
> > from any other function call in ib_core_init() which is marked as __init.
> 
> Huh?
> 
> Only things marked __init are discarded after module load

nldev_init() has single call to rdma_nl_register(), which part of ib_core_init() too.
There is nothing to discard.

Thanks

> 
> Jason
Jason Gunthorpe Oct. 28, 2022, 4:48 p.m. UTC | #8
On Fri, Oct 28, 2022 at 07:47:53PM +0300, Leon Romanovsky wrote:
> On Fri, Oct 28, 2022 at 01:34:57PM -0300, Jason Gunthorpe wrote:
> > On Fri, Oct 28, 2022 at 07:19:36PM +0300, Leon Romanovsky wrote:
> > > On Fri, Oct 28, 2022 at 01:15:16PM -0300, Jason Gunthorpe wrote:
> > > > On Fri, Oct 28, 2022 at 07:14:16PM +0300, Leon Romanovsky wrote:
> > > > > On Fri, Oct 28, 2022 at 01:00:27PM -0300, Jason Gunthorpe wrote:
> > > > > > On Fri, Oct 28, 2022 at 09:58:56AM +0300, Leon Romanovsky wrote:
> > > > > > > ppc64_defconfig) produced this warning:
> > > > > > > 
> > > > > > > WARNING: modpost: drivers/infiniband/core/ib_core.o: section mismatch in reference: .init_module (section: .init.text) -> .nldev_exit (section: .exit.text)
> > > > > > > 
> > > > > > > Fix it by removing __init/__exit markers as nldev is part of ib_core.ko
> > > > > > > and as such doesn't require any special notations for entry/exit functions.
> > > > > > 
> > > > > > This isn't what the problem is, the patch Stephen reported:
> > > > > > 
> > > > > > commit ad9394a3da33995dff828dbfd4540421e535bec9 (ko-rdma/for-rc)
> > > > > > Author: Chen Zhongjin <chenzhongjin@huawei.com>
> > > > > > Date:   Tue Oct 25 10:41:46 2022 +0800
> > > > > > 
> > > > > >     RDMA/core: Fix null-ptr-deref in ib_core_cleanup()
> > > > > > 
> > > > > > Adds a call to an __exit function from an __init function:
> > > > > > 
> > > > > > @@ -2815,10 +2815,18 @@ static int __init ib_core_init(void)
> > > > > > 
> > > > > > +err_parent:
> > > > > > +       rdma_nl_unregister(RDMA_NL_LS);
> > > > > > +       nldev_exit();
> > > > > > +       unregister_pernet_device(&rdma_dev_net_ops);
> > > > > > 
> > > > > > Which is not allowed
> > > > > > 
> > > > > > All that is required is to drop the __exit from nldev_exit, 
> > > > > 
> > > > > This is why I dropped both __exit and __init. I see no value in keeping
> > > > > __init, without __exit.
> > > > 
> > > > __init works just fine, it will cause the code to be unload after the
> > > > module registration is compelted
> > > 
> > > The code will be unloaded as part of ib_core unload. It is not different
> > > from any other function call in ib_core_init() which is marked as __init.
> > 
> > Huh?
> > 
> > Only things marked __init are discarded after module load
> 
> nldev_init() has single call to rdma_nl_register(), which part of ib_core_init() too.
> There is nothing to discard.

It discards the one statement function since it cannot be inlined.

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index b92358f606d0..4b6815dcd261 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -2532,12 +2532,12 @@  static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
 	},
 };
 
-void __init nldev_init(void)
+void nldev_init(void)
 {
 	rdma_nl_register(RDMA_NL_NLDEV, nldev_cb_table);
 }
 
-void __exit nldev_exit(void)
+void nldev_exit(void)
 {
 	rdma_nl_unregister(RDMA_NL_NLDEV);
 }