Message ID | 20240409160720.154470-2-diogo.ivo@siemens.com (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] net: ethernet: Move eth_*_addr_base to global symbols | expand |
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..
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
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
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
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(-)