Skip to content

A tool to verify the BPF memory model #5587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: bpf-next_base
Choose a base branch
from

Conversation

kernel-patches-daemon-bpf-rc[bot]
Copy link

Pull request for series with
subject: A tool to verify the BPF memory model
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=981178

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: ad97cb2
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=981178
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: d81526a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=981178
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: eeec23a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=981178
version: 1

As BPF doesn't include any barrier instructions, smp_mb() is implemented
by doing a dummy value returning atomic operation. Such an operation
acts a full barrier as enforced by LKMM and also by the work in progress
BPF memory model.

If the returned value is not used, clang[1] can optimize the value
returning atomic instruction in to a normal atomic instruction which
provides no ordering guarantees.

Mark the variable as volatile so the above optimization is never
performed and smp_mb() works as expected.

[1] https://godbolt.org/z/qzze7bG6z

Fixes: 88d706b ("selftests/bpf: Introduce arena spin lock")
Signed-off-by: Puranjay Mohan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant