Skip to content
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

bpf: Overwrite the htab element atomically #4946

Open
wants to merge 3 commits 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: bpf: Overwrite the htab element atomically
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=930344

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

Upstream branch: 03f3aa4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=930344
version: 1

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

Upstream branch: 03f3aa4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=930344
version: 1

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

Upstream branch: 03f3aa4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=930344
version: 1

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

Upstream branch: 12befeb
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=930344
version: 1

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

Upstream branch: 0abff46
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=930344
version: 1

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

Upstream branch: 003be25
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=930344
version: 1

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

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

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

Upstream branch: 9b6cdaf
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=930344
version: 1

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

Upstream branch: 733c3fa
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=930344
version: 1

Add hlist_nulls_replace_rcu() to replace an existing element in the hash
list. For the concurrent list traversal, the replace is atomic, it will
find either the old element or the new element.

Signed-off-by: Hou Tao <[email protected]>
Currently, the update of existing element in hash map involves two
steps:
1) insert the new element at the head of the hash list
2) remove the old element

It is possible that the concurrent lookup operation may fail to find
either the old element or the new element if the lookup operation starts
before the addition and continues after the removal.

Therefore, replacing the two-step update with an atomic update. After
the change, the update will be atomic in the perspective of the lookup
operation: it will either find the old element or the new element.

Signed-off-by: Hou Tao <[email protected]>
Add a test case to verify the atomic update of existing element in hash
map. The test proceeds in three steps:
1) fill the map with keys in the range [0, 63]
2) create 8 threads to lookup these keys concurrently
3) create 2 threads to overwrite these keys concurrently

Without atomic update support, the lookup operation may return -ENOENT
error and the test will fail. After the atomic-update change, the lookup
operation will always return 0 and the test will succeed.

Signed-off-by: Hou Tao <[email protected]>
@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 4107a1a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=930344
version: 1

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