lib: lock-free hash table - #23247
Open
eqvinox wants to merge 5 commits into
Open
Conversation
The lock-free hash table test code cycles through memory rapidly and tries to hit race conditions while doing so. To make that work, it eschews regular RCU memory management and does its own accounting on what may or may not still be in use. To do that correctly, it needs the RCU tail position, i.e. what's guaranteed to be no longer in use. (`rcu_stats->seq_head - seq_delta` is close, but that whole struct and function are only intended for display purposes, with no consistency guarantee. The test needs the guarantee, otherwise you get random failures and can't be sure if it was just a glitch.) Signed-off-by: David 'equinox' Lamparter <equinox@opensourcerouting.org>
This comment was marked as low quality.
This comment was marked as low quality.
Comment on lines
+1072
to
+1078
| #if 0 | ||
| /* pop() cannot easily be tested :( */ | ||
| static bool test_pop(unsigned int r) | ||
| { | ||
| return false; | ||
| } | ||
| #endif |
This comment was marked as low quality.
This comment was marked as low quality.
Sorry, something went wrong.
This provides, well, a lock-free hash table. (To be used with RCU.) Unlike a lot of other implementations, this one can shrink its hash "buckets" without a lock. To my knowledge, it is at this point the only lock-free single-CAS hash table to have that capability. Tests & documentation are in followup commits. Signed-off-by: David 'equinox' Lamparter <equinox@opensourcerouting.org>
Does what the function name says, permutes the items in an array into a random order. Signed-off-by: David 'equinox' Lamparter <equinox@opensourcerouting.org>
eqvinox
force-pushed
the
atomhash
branch
2 times, most recently
from
September 3, 2026 17:03
488ef17 to
dcc3346
Compare
Since this test is probabilistic in nature AND must preferentially be run on machines with weak memory models, it is not part of the regular test suite. It's intended to be run manually, in loops, on systems specifically picked out for the purpose. The longer it runs, the more reliable the result becomes. It also has a rather large number of tunables, which in all honesty must be understood by reading the code and tuned in a few ways to test specific things. Signed-off-by: David 'equinox' Lamparter <equinox@opensourcerouting.org>
Docs for `DECLARE_ATOMHASH`, 'nuff said. Signed-off-by: David 'equinox' Lamparter <equinox@opensourcerouting.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Maybe I should write 52 more lines of comments for
atomhash.c, just so I can claim it's more comments than code 😆 … it does have aHIC SUNT DRACONES🐉.In seriousness though, the documentation is in the last commit.
In a galaxy far, far in the future, at the final frontier, this will be the backing for deduplicating ("interning") the various crap we have in BGP (communities, aspaths, attrs, etc.), and in the same vein allows implementing lock-free structure refcounts.
Anyway, it completed 50000 test cycles (20M ops ea) on ARM and 60000 test cycles (10M ops ea) on ppc64. (And another few times that during a bughunt for a rather nasty bug — but on the plus side the test did find that.)