From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: "Toke Høiland-Jørgensen" <toke@toke.dk>
Cc: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: [WireGuard] Requeuing Race Condition [Was: Re: [Cake] WireGuard Queuing, Bufferbloat, Performance, Latency, and related issues]
Date: Thu, 3 Nov 2016 16:13:07 +0100 [thread overview]
Message-ID: <CAHmME9qQiho_9vsuCxyV32Oy3hvkf1FL+Lpqq+yMtHPpN=_sNQ@mail.gmail.com> (raw)
Hey Toke,
On Wed, Oct 5, 2016 at 3:59 PM, Toke H=C3=B8iland-J=C3=B8rgensen <toke@toke=
.dk> wrote:
>> On Sun, Oct 2, 2016 at 1:31 PM, Toke H=C3=B8iland-J=C3=B8rgensen <toke@t=
oke.dk> wrote:
>>> You don't need a timer. You already have a signal for when more queue
>>> space is available in the encryption step: When a packet finishes
>>> encryption. All you need to do is try to enqueue another one at this
>>> point.
>>
>> Oh, silly me. Yes of course. Voila:
>> https://git.zx2c4.com/WireGuard/commit/?id=3Da0ad61c1a0e25a376e145f07ca2=
7c605d3852bc4
>
> Yup, that seems like the way to go about it :)
There's a small problem with this approach:
Thread 1 | Thread 2
---------------------------------- | ------------------------------------
Queue it up? Nope, queue is full. |
| I just finished encrypting my last
| packet. My queue is now empty. Has
| thread 1 set need_resend_queue? Nope=
,
| so I'll go to sleep.
Set need_resend_queue =3D true and |
wait for thread 2 to requeue it. |
|
Nothing happens. |
| Nothing happens.
Nothing happens. |
| Nothing happens.
Nothing happens. |
| Nothing happens.
One way of fixing this would be to add a spin lock that synchronizes the
submission of jobs in thread 1 and the completion of jobs in thread 2. That
looks like this:
https://git.zx2c4.com/WireGuard/commit/?h=3Djd/ugly-sync
I have no intention of actually merging this approach, as it's really too
awful. But perhaps you have a better race-free and lock-free approach.
Jason
next reply other threads:[~2016-11-03 15:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-03 15:13 Jason A. Donenfeld [this message]
2016-11-04 11:53 ` Toke Høiland-Jørgensen
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='CAHmME9qQiho_9vsuCxyV32Oy3hvkf1FL+Lpqq+yMtHPpN=_sNQ@mail.gmail.com' \
--to=jason@zx2c4.com \
--cc=toke@toke.dk \
--cc=wireguard@lists.zx2c4.com \
/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).