[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW5OH9paDZpG-KfYK3EkwpaQWPOcD6c0kyLQ7+ePs9Xd8g@mail.gmail.com>
Date: Tue, 2 Jun 2020 09:18:16 -0700
From: Song Liu <song@...nel.org>
To: Andrii Nakryiko <andriin@...com>
Cc: bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii.nakryiko@...il.com>,
Kernel Team <kernel-team@...com>
Subject: Re: [PATCH bpf-next] selftests/bpf: fix sample_cnt shared between two threads
On Mon, Jun 1, 2020 at 10:04 PM Andrii Nakryiko <andriin@...com> wrote:
>
> Make sample_cnt volatile to fix possible selftests failure due to compiler
> optimization preventing latest sample_cnt value to be visible to main thread.
> sample_cnt is incremented in background thread, which is then joined into main
> thread. So in terms of visibility sample_cnt update is ok. But because it's
> not volatile, compiler might make optimizations that would prevent main thread
> to see latest updated value. Fix this by marking global variable volatile.
>
> Fixes: cb1c9ddd5525 ("selftests/bpf: Add BPF ringbuf selftests")
> Signed-off-by: Andrii Nakryiko <andriin@...com>
Acked-by: Song Liu <songliubraving@...com>
Powered by blists - more mailing lists