Subject: Re: seqlock lockdep false positives?

From: "Erhard F." <[email-masked]>
Date: Mon, 8 Mar 2021 19:28:49 +0100

On Sun, 7 Mar 2021 10:20:08 +0100
"Ahmed S. Darwish" <[email-masked]> wrote:

> @Erhard, can you please try below patch? Just want to confirm if this
> theory has any validity to it:
> 
> diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c
> index 1e5a453dea14..c0dbb0418e9d 100644
> --- a/drivers/net/ethernet/realtek/8139too.c
> +++ b/drivers/net/ethernet/realtek/8139too.c
> @@ -715,6 +715,11 @@ static const unsigned int rtl8139_rx_config =
>  static const unsigned int rtl8139_tx_config =
>  	TxIFG96 | (TX_DMA_BURST << TxDMAShift) | (TX_RETRY << TxRetryShift);
> 
> +#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
> +static struct lock_class_key rx_stats_key;
> +static struct lock_class_key tx_stats_key;
> +#endif
> +
>  static void __rtl8139_cleanup_dev (struct net_device *dev)
>  {
>  	struct rtl8139_private *tp = netdev_priv(dev);
> @@ -794,8 +799,17 @@ static struct net_device *rtl8139_init_board(struct pci_dev *pdev)
> 
>  	pci_set_master (pdev);
> 
> -	u64_stats_init(&tp->rx_stats.syncp);
> -	u64_stats_init(&tp->tx_stats.syncp);
> +#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
> +	dev_warn(d, "Manually intializing tx/rx stats sequence counters\n");
> +
> +	tp->rx_stats.syncp.seq.sequence = 0;
> +	lockdep_set_class_and_name(&tp->rx_stats.syncp.seq,
> +				   &rx_stats_key, "RX stats");
> +
> +	tp->tx_stats.syncp.seq.sequence = 0;
> +	lockdep_set_class_and_name(&tp->tx_stats.syncp.seq,
> +				   &tx_stats_key, "TX stats");
> +#endif

Hi Ahmed!

With your patch on top of 5.12-rc2 the lockdep splat is gone in the kernel dmesg and I only get:

[...]
8139too: 8139too Fast Ethernet driver 0.9.28
8139too 0000:00:0f.0: Manually intializing tx/rx stats sequence counters
8139too 0000:00:0f.0 eth0: RealTek RTL8139 at 0x(ptrval), 00:30:1b:2f:2c:58, IRQ 18
[...]

Trying Peter's patch next.