From: Jason Wang <jasowang@redhat.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev@vger.kernel.org, rusty@rustcorp.com.au,
linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org, mst@redhat.com,
Stephen Hemminger <shemminger@vyatta.com>
Subject: Re: [PATCH] virtio-net: fix a race on 32bit arches
Date: Wed, 06 Jun 2012 17:37:34 +0800 [thread overview]
Message-ID: <4FCF24DE.5090109@redhat.com> (raw)
In-Reply-To: <1338972341.2760.3944.camel@edumazet-glaptop>
On 06/06/2012 04:45 PM, Eric Dumazet wrote:
> On Wed, 2012-06-06 at 10:35 +0200, Eric Dumazet wrote:
>> From: Eric Dumazet<edumazet@google.com>
>>
>> commit 3fa2a1df909 (virtio-net: per cpu 64 bit stats (v2)) added a race
>> on 32bit arches.
>>
>> We must use separate syncp for rx and tx path as they can be run at the
>> same time on different cpus. Thus one sequence increment can be lost and
>> readers spin forever.
>>
>> Signed-off-by: Eric Dumazet<edumazet@google.com>
>> Cc: Stephen Hemminger<shemminger@vyatta.com>
>> Cc: Michael S. Tsirkin<mst@redhat.com>
>> Cc: Jason Wang<jasowang@redhat.com>
>> ---
> Just to make clear : even using percpu stats/syncp, we have no guarantee
> that write_seqcount_begin() is done with one instruction. [1]
>
> It is OK on x86 if "incl" instruction is generated by the compiler, but
> on a RISC cpu, the "load memory,%reg ; inc %reg ; store %reg,memory" can
> be interrupted.
>
> So if you are 100% sure all paths are safe against preemption/BH, then
> this patch is not needed, but a big comment in the code would avoid
> adding possible races in the future.
Thanks for explaing, current virtio-net is safe I think. But the patch
is still needed as my patch would update the statistics in irq.
>
> [1] If done with one instruction, we still have a race, since a reader
> might see an even sequence and conclude no writer is inside the critical
> section. So read values could be wrong.
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2012-06-06 9:36 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-06 8:35 [PATCH] virtio-net: fix a race on 32bit arches Eric Dumazet
2012-06-06 8:45 ` Eric Dumazet
2012-06-06 9:37 ` Jason Wang [this message]
2012-06-06 11:13 ` Michael S. Tsirkin
2012-06-06 13:10 ` Eric Dumazet
2012-06-06 14:49 ` Michael S. Tsirkin
2012-06-06 15:14 ` Stephen Hemminger
2012-06-06 18:51 ` Michael S. Tsirkin
2012-06-06 19:54 ` Eric Dumazet
2012-06-06 19:58 ` Michael S. Tsirkin
2012-06-06 20:08 ` Eric Dumazet
2012-06-06 20:16 ` Michael S. Tsirkin
2012-06-06 20:24 ` Eric Dumazet
2012-06-06 20:38 ` Eric Dumazet
2012-06-06 20:35 ` Ben Hutchings
2012-06-06 20:43 ` Michael S. Tsirkin
2012-06-06 20:19 ` Ben Hutchings
2012-06-06 20:25 ` Eric Dumazet
2012-06-06 15:19 ` Eric Dumazet
2012-06-06 16:17 ` Michael S. Tsirkin
2012-06-06 17:13 ` Eric Dumazet
2012-06-06 18:43 ` Michael S. Tsirkin
2012-06-06 20:06 ` Eric Dumazet
2012-06-06 20:19 ` Michael S. Tsirkin
2012-06-06 16:57 ` Michael S. Tsirkin
2012-06-06 20:00 ` Eric Dumazet
2012-06-10 6:36 ` Rusty Russell
2012-06-10 7:03 ` Michael S. Tsirkin
2012-06-10 10:21 ` Eric Dumazet
2012-06-10 10:22 ` Michael S. Tsirkin
2012-06-10 10:25 ` Michael S. Tsirkin
2012-06-11 3:23 ` David Miller
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=4FCF24DE.5090109@redhat.com \
--to=jasowang@redhat.com \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=shemminger@vyatta.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox