]> git.baikalelectronics.ru Git - kernel.git/commit
virtio_net: fix lockdep warning on 32 bit
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 7 May 2020 07:25:56 +0000 (03:25 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 7 May 2020 14:57:21 +0000 (07:57 -0700)
commitc4d9047b0e36866a8b407af9b847fbc4e31db320
treeda7ec58179ef905a04896c2413c452d7831a5198
parent71b4af9768e7d24f51774c6f7562a16f9d270dab
virtio_net: fix lockdep warning on 32 bit

When we fill up a receive VQ, try_fill_recv currently tries to count
kicks using a 64 bit stats counter. Turns out, on a 32 bit kernel that
uses a seqcount. sequence counts are "lock" constructs where you need to
make sure that writers are serialized.

In turn, this means that we mustn't run two try_fill_recv concurrently.
Which of course we don't. We do run try_fill_recv sometimes from a
softirq napi context, and sometimes from a fully preemptible context,
but the later always runs with napi disabled.

However, when it comes to the seqcount, lockdep is trying to enforce the
rule that the same lock isn't accessed from preemptible and softirq
context - it doesn't know about napi being enabled/disabled. This causes
a false-positive warning:

WARNING: inconsistent lock state
...
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.

As a work around, shut down the warning by switching
to u64_stats_update_begin_irqsave - that works by disabling
interrupts on 32 bit only, is a NOP on 64 bit.

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/virtio_net.c