All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: David Miller <davem@davemloft.net>, bigeasy@linutronix.de
Cc: stephen@networkplumber.org, netdev@vger.kernel.org,
	virtualization@lists.linux-foundation.org, tglx@linutronix.de,
	makita.toshiaki@lab.ntt.co.jp, mst@redhat.com
Subject: Re: [PATCH] virtio_net: add local_bh_disable() around u64_stats_update_begin
Date: Fri, 19 Oct 2018 10:19:56 +0800	[thread overview]
Message-ID: <0c7c4cb9-5814-e8b1-33e5-b57aa26f0cce@redhat.com> (raw)
In-Reply-To: <20181018.162308.2295937118791060714.davem@davemloft.net>


On 2018/10/19 上午7:23, David Miller wrote:
> From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Date: Thu, 18 Oct 2018 10:43:13 +0200
>
>> on 32bit, lockdep notices that virtnet_open() and refill_work() invoke
>> try_fill_recv() from process context while virtnet_receive() invokes the
>> same function from BH context. The problem that the seqcounter within
>> u64_stats_update_begin() may deadlock if it is interrupted by BH and
>> then acquired again.
>>
>> Introduce u64_stats_update_begin_bh() which disables BH on 32bit
>> architectures. Since the BH might interrupt the worker, this new
>> function should not limited to SMP like the others which are expected
>> to be used in softirq.
>>
>> With this change we might lose increments but this is okay. The
>> important part that the two 32bit parts of the 64bit counter are not
>> corrupted.
>>
>> Fixes: 461f03dc99cf6 ("virtio_net: Add kick stats").
>> Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Trying to get down to the bottom of this:
>
> 1) virtnet_receive() runs from softirq but only if NAPI is active and
>     enabled.  It is in this context that it invokes try_fill_recv().
>
> 2) refill_work() runs from process context, but disables NAPI (and
>     thus invocation of virtnet_receive()) before calling
>     try_fill_recv().
>
> 3) virtnet_open() invokes from process context as well, but before the
>     NAPI instances are enabled, it is same as case #2.
>
> 4) virtnet_restore_up() is the same situations as #3.
>
> Therefore I agree that this is a false positive, and simply lockdep
> cannot see the NAPI synchronization done by case #2.
>
> I think we shouldn't add unnecessary BH disabling here, and instead
> find some way to annotate this for lockdep's sake.
>
> Thank you.
>

+1

Thanks

  reply	other threads:[~2018-10-19 10:24 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-16 16:55 [RFC] virtio_net: add local_bh_disable() around u64_stats_update_begin Sebastian Andrzej Siewior
2018-10-16 17:59 ` Stephen Hemminger
2018-10-16 18:21   ` Sebastian Andrzej Siewior
2018-10-16 17:59 ` Stephen Hemminger
2018-10-16 18:01 ` Stephen Hemminger
2018-10-16 18:01 ` Stephen Hemminger
2018-10-16 18:42   ` Sebastian Andrzej Siewior
2018-10-16 18:44     ` Stephen Hemminger
2018-10-18  8:43       ` [PATCH] " Sebastian Andrzej Siewior
2018-10-18  8:43       ` Sebastian Andrzej Siewior
2018-10-18  9:06         ` Toshiaki Makita
2018-10-18  9:11           ` Sebastian Andrzej Siewior
2018-10-18  9:26             ` Toshiaki Makita
2018-10-18  9:11           ` Sebastian Andrzej Siewior
2018-10-18 23:23         ` David Miller
2018-10-19  2:19           ` Jason Wang [this message]
2018-10-19  2:19           ` Jason Wang
2018-10-16 18:44     ` [RFC] " Stephen Hemminger
2018-10-16 18:42   ` Sebastian Andrzej Siewior
2018-10-17  1:13 ` Toshiaki Makita
2018-10-17  1:13 ` Toshiaki Makita
2018-10-17  6:48   ` Jason Wang
2018-10-17  6:48   ` Jason Wang
2018-10-18  8:47     ` Sebastian Andrzej Siewior
2018-10-18  8:47     ` Sebastian Andrzej Siewior
2018-10-18  9:00       ` Toshiaki Makita
2018-10-18  9:08         ` Sebastian Andrzej Siewior
2018-10-18  9:19           ` Toshiaki Makita
2018-10-18  9:30             ` Sebastian Andrzej Siewior
2018-10-18  9:53               ` Toshiaki Makita
2018-10-18  9:30             ` Sebastian Andrzej Siewior
2018-10-18 13:21             ` Rafael David Tinoco
2018-10-18  9:08         ` Sebastian Andrzej Siewior
2018-10-19  2:17       ` Jason Wang
2018-10-19  2:17       ` Jason Wang

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=0c7c4cb9-5814-e8b1-33e5-b57aa26f0cce@redhat.com \
    --to=jasowang@redhat.com \
    --cc=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=makita.toshiaki@lab.ntt.co.jp \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.