netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: dqs: Do not use extern for unused dql_group
@ 2024-09-02 10:17 Breno Leitao
  2024-09-02 19:02 ` Simon Horman
  2024-09-03 20:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Breno Leitao @ 2024-09-02 10:17 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: leit, kernel test robot, Johannes Berg, Jamie Bainbridge,
	open list:NETWORKING [GENERAL], open list

When CONFIG_DQL is not enabled, dql_group should be treated as a dead
declaration. However, its current extern declaration assumes the linker
will ignore it, which is generally true across most compiler and
architecture combinations.

But in certain cases, the linker still attempts to resolve the extern
struct, even when the associated code is dead, resulting in a linking
error. For instance the following error in loongarch64:

>> loongarch64-linux-ld: net-sysfs.c:(.text+0x589c): undefined reference to `dql_group'

Modify the declaration of the dead object to be an empty declaration
instead of an extern. This change will prevent the linker from
attempting to resolve an undefined reference.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202409012047.eCaOdfQJ-lkp@intel.com/
Fixes: 74293ea1c4db ("net: sysfs: Do not create sysfs for non BQL device")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
 net/core/net-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 444f23e74f8e..291fdf4a328b 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1524,7 +1524,7 @@ static const struct attribute_group dql_group = {
 };
 #else
 /* Fake declaration, all the code using it should be dead */
-extern const struct attribute_group dql_group;
+static const struct attribute_group dql_group = {};
 #endif /* CONFIG_BQL */
 
 #ifdef CONFIG_XPS
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: dqs: Do not use extern for unused dql_group
  2024-09-02 10:17 [PATCH net] net: dqs: Do not use extern for unused dql_group Breno Leitao
@ 2024-09-02 19:02 ` Simon Horman
  2024-09-03 20:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-09-02 19:02 UTC (permalink / raw)
  To: Breno Leitao
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, leit,
	kernel test robot, Johannes Berg, Jamie Bainbridge,
	open list:NETWORKING [GENERAL], open list

On Mon, Sep 02, 2024 at 03:17:30AM -0700, Breno Leitao wrote:
> When CONFIG_DQL is not enabled, dql_group should be treated as a dead
> declaration. However, its current extern declaration assumes the linker
> will ignore it, which is generally true across most compiler and
> architecture combinations.
> 
> But in certain cases, the linker still attempts to resolve the extern
> struct, even when the associated code is dead, resulting in a linking
> error. For instance the following error in loongarch64:
> 
> >> loongarch64-linux-ld: net-sysfs.c:(.text+0x589c): undefined reference to `dql_group'
> 
> Modify the declaration of the dead object to be an empty declaration
> instead of an extern. This change will prevent the linker from
> attempting to resolve an undefined reference.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202409012047.eCaOdfQJ-lkp@intel.com/
> Fixes: 74293ea1c4db ("net: sysfs: Do not create sysfs for non BQL device")
> Signed-off-by: Breno Leitao <leitao@debian.org>

Thanks,

I see this with gcc-13.2.0 but, curiously, not 14.2.0.

Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Simon Horman <horms@kernel.org> # build-tested

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: dqs: Do not use extern for unused dql_group
  2024-09-02 10:17 [PATCH net] net: dqs: Do not use extern for unused dql_group Breno Leitao
  2024-09-02 19:02 ` Simon Horman
@ 2024-09-03 20:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-03 20:10 UTC (permalink / raw)
  To: Breno Leitao
  Cc: davem, edumazet, kuba, pabeni, leit, lkp, johannes.berg,
	jamie.bainbridge, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon,  2 Sep 2024 03:17:30 -0700 you wrote:
> When CONFIG_DQL is not enabled, dql_group should be treated as a dead
> declaration. However, its current extern declaration assumes the linker
> will ignore it, which is generally true across most compiler and
> architecture combinations.
> 
> But in certain cases, the linker still attempts to resolve the extern
> struct, even when the associated code is dead, resulting in a linking
> error. For instance the following error in loongarch64:
> 
> [...]

Here is the summary with links:
  - [net] net: dqs: Do not use extern for unused dql_group
    https://git.kernel.org/netdev/net/c/77461c108191

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-03 20:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-02 10:17 [PATCH net] net: dqs: Do not use extern for unused dql_group Breno Leitao
2024-09-02 19:02 ` Simon Horman
2024-09-03 20:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).