From: Eric Dumazet <eric.dumazet@gmail.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>, eric.dumazet@gmail.com
Cc: cai@lca.pw, netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Marco Elver <elver@google.com>
Subject: Re: [PATCH v3] skbuff: fix a data race in skb_queue_len()
Date: Thu, 6 Feb 2020 09:10:34 -0800 [thread overview]
Message-ID: <453212cf-8987-9f05-ceae-42a4fc3b0876@gmail.com> (raw)
In-Reply-To: <20200206163844.GA432041@zx2c4.com>
On 2/6/20 8:38 AM, Jason A. Donenfeld wrote:
> Hi Eric,
>
> On Tue, Feb 04, 2020 at 01:40:29PM -0500, Qian Cai wrote:
>> - list->qlen--;
>> + WRITE_ONCE(list->qlen, list->qlen - 1);
>
> Sorry I'm a bit late to the party here, but this immediately jumped out.
> This generates worse code with a bigger race in some sense:
>
> list->qlen-- is:
>
> 0: 83 6f 10 01 subl $0x1,0x10(%rdi)
>
> whereas WRITE_ONCE(list->qlen, list->qlen - 1) is:
>
> 0: 8b 47 10 mov 0x10(%rdi),%eax
> 3: 83 e8 01 sub $0x1,%eax
> 6: 89 47 10 mov %eax,0x10(%rdi)
>
> Are you sure that's what we want?
>
> Jason
>
Unfortunately we do not have ADD_ONCE() or something like that.
Sure, on x86 we could get much better code generation.
If we agree a READ_ONCE() was needed at the read side,
then a WRITE_ONCE() is needed as well on write sides.
If we believe load-tearing and/or write-tearing must not ever happen,
then we must document this.
next prev parent reply other threads:[~2020-02-06 17:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-04 18:40 [PATCH v3] skbuff: fix a data race in skb_queue_len() Qian Cai
2020-02-06 12:59 ` David Miller
2020-02-06 16:38 ` Jason A. Donenfeld
2020-02-06 17:10 ` Eric Dumazet [this message]
2020-02-06 18:12 ` Jason A. Donenfeld
2020-02-06 18:22 ` Eric Dumazet
2020-02-06 18:43 ` Jason A. Donenfeld
2020-02-06 19:29 ` Marco Elver
2020-02-06 21:55 ` Jason A. Donenfeld
2020-02-07 10:35 ` Marco Elver
2020-02-17 3:24 ` Herbert Xu
2020-02-17 7:39 ` Jason A. Donenfeld
2020-02-17 10:20 ` Herbert Xu
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=453212cf-8987-9f05-ceae-42a4fc3b0876@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=Jason@zx2c4.com \
--cc=cai@lca.pw \
--cc=elver@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).