* [PATCH net-next] net: ethernet: Move eth_*_addr_base to global symbols
@ 2024-04-09 16:07 Diogo Ivo
2024-04-09 21:58 ` Jakub Kicinski
0 siblings, 1 reply; 4+ messages in thread
From: Diogo Ivo @ 2024-04-09 16:07 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, aleksander.lobakin, netdev
Cc: Diogo Ivo, jan.kiszka
Promote IPv4/6 and Ethernet reserved base addresses to global symbols
to avoid local copies being created when these addresses are referenced.
Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>
---
include/linux/etherdevice.h | 10 +++-------
net/ethernet/eth.c | 15 +++++++++++++++
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 8d6daf828427..6002dabca0f8 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -67,15 +67,11 @@ struct sk_buff *eth_gro_receive(struct list_head *head, struct sk_buff *skb);
int eth_gro_complete(struct sk_buff *skb, int nhoff);
/* Reserved Ethernet Addresses per IEEE 802.1Q */
-static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) =
-{ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
+extern const u8 eth_reserved_addr_base[ETH_ALEN];
#define eth_stp_addr eth_reserved_addr_base
-static const u8 eth_ipv4_mcast_addr_base[ETH_ALEN] __aligned(2) =
-{ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 };
-
-static const u8 eth_ipv6_mcast_addr_base[ETH_ALEN] __aligned(2) =
-{ 0x33, 0x33, 0x00, 0x00, 0x00, 0x00 };
+extern const u8 eth_ipv4_mcast_addr_base[ETH_ALEN];
+extern const u8 eth_ipv6_mcast_addr_base[ETH_ALEN];
/**
* is_link_local_ether_addr - Determine if given Ethernet address is link-local
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 2edc8b796a4e..8141e5c7e4f3 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -63,6 +63,21 @@
#include <linux/uaccess.h>
#include <net/pkt_sched.h>
+const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) = {
+ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00
+};
+EXPORT_SYMBOL(eth_reserved_addr_base);
+
+const u8 eth_ipv4_mcast_addr_base[ETH_ALEN] __aligned(2) = {
+ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00
+};
+EXPORT_SYMBOL(eth_ipv4_mcast_addr_base);
+
+const u8 eth_ipv6_mcast_addr_base[ETH_ALEN] __aligned(2) = {
+ 0x33, 0x33, 0x00, 0x00, 0x00, 0x00
+};
+EXPORT_SYMBOL(eth_ipv6_mcast_addr_base);
+
/**
* eth_header - create the Ethernet header
* @skb: buffer to alter
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: ethernet: Move eth_*_addr_base to global symbols
2024-04-09 16:07 [PATCH net-next] net: ethernet: Move eth_*_addr_base to global symbols Diogo Ivo
@ 2024-04-09 21:58 ` Jakub Kicinski
2024-04-10 11:48 ` Alexander Lobakin
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2024-04-09 21:58 UTC (permalink / raw)
To: Diogo Ivo, aleksander.lobakin; +Cc: davem, edumazet, pabeni, netdev, jan.kiszka
On Tue, 9 Apr 2024 17:07:18 +0100 Diogo Ivo wrote:
> Promote IPv4/6 and Ethernet reserved base addresses to global symbols
> to avoid local copies being created when these addresses are referenced.
Did someone bloat-o-meter this?
I agree it's odd but the values are tiny and I'd expect compiler
to eliminate the dead instances.
I mean, the instances are literally smaller than a pointer we'll
need to refer to them, if they can be inlined..
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: ethernet: Move eth_*_addr_base to global symbols
2024-04-09 21:58 ` Jakub Kicinski
@ 2024-04-10 11:48 ` Alexander Lobakin
2024-04-10 12:49 ` Alexander Lobakin
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Lobakin @ 2024-04-10 11:48 UTC (permalink / raw)
To: Jakub Kicinski, Diogo Ivo; +Cc: davem, edumazet, pabeni, netdev, jan.kiszka
From: Jakub Kicinski <kuba@kernel.org>
Date: Tue, 9 Apr 2024 14:58:35 -0700
> On Tue, 9 Apr 2024 17:07:18 +0100 Diogo Ivo wrote:
>> Promote IPv4/6 and Ethernet reserved base addresses to global symbols
>> to avoid local copies being created when these addresses are referenced.
>
> Did someone bloat-o-meter this?
bloat-o-meter would be good, right.
> I agree it's odd but the values are tiny and I'd expect compiler
> to eliminate the dead instances.
The compiler won't copy the arrays to each file which includes
ethernet.h obviously.
> I mean, the instances are literally smaller than a pointer we'll
> need to refer to them, if they can be inlined..
The compilers are sometimes even able to inline extern consts. So,
without bloat-o-meter, I wouldn't assume anything at all :)
Thanks,
Olek
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: ethernet: Move eth_*_addr_base to global symbols
2024-04-10 11:48 ` Alexander Lobakin
@ 2024-04-10 12:49 ` Alexander Lobakin
0 siblings, 0 replies; 4+ messages in thread
From: Alexander Lobakin @ 2024-04-10 12:49 UTC (permalink / raw)
To: Jakub Kicinski, Diogo Ivo; +Cc: davem, edumazet, pabeni, netdev, jan.kiszka
From: Alexander Lobakin <aleksander.lobakin@intel.com>
Date: Wed, 10 Apr 2024 13:48:54 +0200
> From: Jakub Kicinski <kuba@kernel.org>
> Date: Tue, 9 Apr 2024 14:58:35 -0700
>
>> On Tue, 9 Apr 2024 17:07:18 +0100 Diogo Ivo wrote:
>>> Promote IPv4/6 and Ethernet reserved base addresses to global symbols
>>> to avoid local copies being created when these addresses are referenced.
>>
>> Did someone bloat-o-meter this?
>
> bloat-o-meter would be good, right.
>
>> I agree it's odd but the values are tiny and I'd expect compiler
>> to eliminate the dead instances.
>
> The compiler won't copy the arrays to each file which includes
> ethernet.h obviously.
>
>> I mean, the instances are literally smaller than a pointer we'll
>> need to refer to them, if they can be inlined..
>
> The compilers are sometimes even able to inline extern consts. So,
> without bloat-o-meter, I wouldn't assume anything at all :)
Kuba is right, converting them to globals only hurts.
vmlinux before/after the patch:
text: add/remove: 0/0 grow/shrink: 2/0 up/down: 16/0 (16)
text: add/remove: 3/0 grow/shrink: 0/0 up/down: 18/0 (18)
Simple module which uses static inlines referencing these arrays:
text: add/remove: 0/0 grow/shrink: 4/0 up/down: 75/0 (75)
I'm sorry that I suggested this anti-improvement :z
Please reject this patch.
Thanks,
Olek
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-10 12:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-09 16:07 [PATCH net-next] net: ethernet: Move eth_*_addr_base to global symbols Diogo Ivo
2024-04-09 21:58 ` Jakub Kicinski
2024-04-10 11:48 ` Alexander Lobakin
2024-04-10 12:49 ` Alexander Lobakin
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).