From: "Petr Tesařík" <petr@tesarici.cz>
To: Simon Horman <horms@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
open list <netdev@vger.kernel.org>,
Linux regressions mailing list <regressions@lists.linux.dev>,
open list <linux-kernel@vger.kernel.org>,
"Linux regression tracking (Thorsten Leemhuis)"
<regressions@leemhuis.info>
Subject: Re: [PATCH net] u64_stats: fix u64_stats_init() for lockdep when used repeatedly in one file
Date: Sat, 6 Apr 2024 10:12:04 +0200 [thread overview]
Message-ID: <20240406101204.1f7827ae@meshulam.tesarici.cz> (raw)
In-Reply-To: <20240405195117.GV26556@kernel.org>
On Fri, 5 Apr 2024 20:51:17 +0100
Simon Horman <horms@kernel.org> wrote:
> On Thu, Apr 04, 2024 at 09:57:40AM +0200, Petr Tesarik wrote:
> > Fix bogus lockdep warnings if multiple u64_stats_sync variables are
> > initialized in the same file.
> >
> > With CONFIG_LOCKDEP, seqcount_init() is a macro which declares:
> >
> > static struct lock_class_key __key;
> >
> > Since u64_stats_init() is a function (albeit an inline one), all calls
> > within the same file end up using the same instance, effectively treating
> > them all as a single lock-class.
> >
> > Fixes: 9464ca650008 ("net: make u64_stats_init() a function")
> > Closes: https://lore.kernel.org/netdev/ea1567d9-ce66-45e6-8168-ac40a47d1821@roeck-us.net/
> > Signed-off-by: Petr Tesarik <petr@tesarici.cz>
>
> Reviewed-by: Simon Horman <horms@kernel.org>
>
> Interesting bug. I'm wondering if you also looked over other users of
> u64_stats_init() to see if any of them can result in unexpected aliasing of
> lock keys too.
I didn't.
I have now run `git grep u64_stats_init | sed -e 's/:.*//' | uniq -d`
and there indeed appears to be some aliasing in other files.
block/blk-cgroup.c:
- struct blkg_iostat_set.sync
- struct blkg_iostat_set.sync
drivers/net/ethernet/amazon/ena/ena_netdev.c:
- struct ena_ring.syncp
struct ena_adapter.syncp
drivers/net/ethernet/aquantia/atlantic/aq_ring.c:
- struct aq_ring_stats_tx_s.syncp
- struct aq_ring_stats_rx_s.syncp
drivers/net/ethernet/emulex/benet/be_main.c:
- struct be_tx_stats.sync
+ aliasing between this struct in
- struct be_tx_obj
- struct be_rx_obj
- struct be_tx_stats.sync_compl
drivers/net/ethernet/google/gve/gve_main.c:
- struct gve_priv.rx[].statss
- struct gve_priv.tx[].statss
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c:
- tx_ring->syncp
- rx_ring->syncp
drivers/net/ethernet/intel/i40e/i40e_txrx.c:
- tx_ring->syncp
- rx_ring->syncp
drivers/net/ethernet/intel/igb/igb_main.c:
- struct igb_ring.tx_syncp
- struct igb_ring.tx_syncp2
- struct igb_ring.rx_syncp
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:
- struct ixgbe_adapter.rx_ring[]->syncp
- struct ixgbe_adapter.tx_ring[]->syncp
- struct ixgbe_adapter.xdp_ring[]->syncp
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:
- tx_ring->syncp
- rx_ring->syncp
drivers/net/ethernet/marvell/sky2.c:
- struct sky2_port.tx_stats.syncp
- struct sky2_port.rx_stats.syncp
drivers/net/ethernet/microsoft/mana/mana_en.c:
- struct mana_txq.stats.syncp
- struct mana_rxq.stats.syncp
drivers/net/ethernet/netronome/nfp/nfp_net_dp.c:
- struct nfp_net_tx_ring.r_vec->tx_sync
- struct nfp_net_rx_ring.r_vec->rx_sync
drivers/net/ethernet/nvidia/forcedeth.c:
- struct fe_priv.swstats_tx_syncp
- struct fe_priv.swstats_rx_syncp
drivers/net/ethernet/realtek/8139too.c:
- struct rtl8139_private.tx_stats.syncp
- struct rtl8139_private.rx_stats.syncp
drivers/net/ethernet/socionext/sni_ave.c:
- struct ave_private.stats_tx.syncp
- struct ave_private.stats_rx.syncp
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:
- this was the trigger ;-)
drivers/net/ethernet/ti/netcp_core.c:
- struct netcp_stats.syncp_tx
- struct netcp_stats.syncp_rx
drivers/net/ethernet/via/via-rhine.c:
- struct rhine_private.tx_stats.syncp
- struct rhine_private.rx_stats.syncp
drivers/net/ethernet/xilinx/xilinx_axienet_main.c:
- struct axienet_local.tx_stat_sync
- struct axienet_local.rx_stat_sync
drivers/net/hyperv/netvsc.c:
- struct netvsc_channel.tx_stats.syncp
- struct netvsc_channel.rx_stats.syncp
drivers/net/ifb.c:
- struct ifb_q_private.tx_stats.sync
- struct ifb_q_private.rx_stats.sync
drivers/net/mhi_net.c:
- struct mhi_net_stats.tx_syncp
- struct mhi_net_stats.rx_syncp
drivers/net/virtio_net.c:
- struct virtnet_info.rq[].stats.syncp
- struct virtnet_info.sq[].stats.syncp
drivers/net/wwan/mhi_wwan_mbim.c:
- struct mhi_mbim_link.tx_syncp
- struct mhi_mbim_link.rx_syncp
drivers/vdpa/vdpa_sim/vdpa_sim_net.c:
- struct vdpasim_net.tx_stats.syncp
- struct vdpasim_net.rx_stats.syncp
- struct vdpasim_net.cq_stats.syncp
HTH
Petr T
next prev parent reply other threads:[~2024-04-06 8:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 7:57 [PATCH net] u64_stats: fix u64_stats_init() for lockdep when used repeatedly in one file Petr Tesarik
2024-04-05 19:51 ` Simon Horman
2024-04-06 8:12 ` Petr Tesařík [this message]
2024-04-05 21:08 ` Eric Dumazet
2024-04-06 7:44 ` Petr Tesařík
2024-04-06 6:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240406101204.1f7827ae@meshulam.tesarici.cz \
--to=petr@tesarici.cz \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=regressions@leemhuis.info \
--cc=regressions@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).