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

Test PR To Trigger CI #8667

Closed

Conversation

jrife
Copy link
Contributor

@jrife jrife commented Mar 12, 2025

WIP

@jrife jrife force-pushed the jrife/socket-iterators-tcp-udp branch 2 times, most recently from fff693a to ecf16c9 Compare March 12, 2025 21:16
@jrife jrife closed this Mar 12, 2025
@jrife jrife reopened this Mar 12, 2025
@jrife jrife force-pushed the jrife/socket-iterators-tcp-udp branch from ecf16c9 to 10828f2 Compare March 12, 2025 21:35
@jrife jrife closed this Mar 12, 2025
@jrife jrife reopened this Mar 12, 2025
Replace the offset-based approach for tracking progress through a bucket
in the UDP table with one based on unique, monotonically increasing
index numbers associated with each socket in a bucket.

* Assign index numbers on sockets in the bucket's linked list such that
  they are monotonically increasing as you read from the head to tail:

  * Every time a socket is added to a bucket, increment the hash table's
    version number, ver.
  * If the socket is being added to the head of the bucket's linked
    list, set sk->idx to -1*ver.
  * If the socket is being added to the tail of the bucket's linked
    list, set sk->idx to ver.

  Ex: append_head(C), append_head(B), append_tail(D), append_head(A),
      append_tail(E) results in the following state.

      A -> B -> C -> D -> E
     -4   -2   -1    3    5
* As we iterate through a bucket keep track of the last index number
  we've seen for that bucket (iter->prev_idx).
* Use iter->prev_idx on subsequent iterations to pick up where we left
  off.

Since we always iterate from head to tail and indexes are always
increasing in that direction we can be sure that any socket whose index
is greater than iter->prev_idx has not yet been seen. Any socket whose
index is less than iter->prev_idx has either been seen before or was
added after we began iterating over that bucket. In either case, it's
safe to skip them.
@jrife jrife force-pushed the jrife/socket-iterators-tcp-udp branch from 10828f2 to 7e21cfb Compare March 12, 2025 22:31
@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the bpf-next_base branch 2 times, most recently from 44c3a1d to 720c696 Compare March 12, 2025 23:33
Replace the offset-based approach for tracking progress through a bucket
in the TCP table with one based on unique, monotonically increasing
index numbers associated with each socket in a bucket.

* Assign index numbers on sockets in the bucket's linked list such that
  they are monotonically increasing as you read from the head to tail:

  * Every time a socket is added to a bucket, increment the hash table's
    version number, ver.
  * If the socket is being added to the head of the bucket's linked
    list, set sk->idx to -1*ver.
  * If the socket is being added to the tail of the bucket's linked
    list, set sk->idx to ver.

  Ex: append_head(C), append_head(B), append_tail(D), append_head(A),
      append_tail(E) results in the following state.

      A -> B -> C -> D -> E
     -4   -2   -1    3    5
* As we iterate through a bucket keep track of the last index number
  we've seen for that bucket (iter->prev_idx).
* Use iter->prev_idx on subsequent iterations to pick up where we left
  off.

Since we always iterate from head to tail and indexes are always
increasing in that direction we can be sure that any socket whose index
is greater than iter->prev_idx has not yet been seen. Any socket whose
index is less than iter->prev_idx has either been seen before or was
added after we began iterating over that bucket. In either case, it's
safe to skip them.
@jrife jrife force-pushed the jrife/socket-iterators-tcp-udp branch from 7e21cfb to a8a5ff6 Compare March 13, 2025 01:48
jrife and others added 2 commits March 13, 2025 02:14
Add do_skip_test() and do_repeat_test() subtests to the sock_iter_batch
prog_test to check for socket skips and repeats, respectively. Extend
the sock_iter_batch BPF program to output the socket cookie as well, so
that we can check for uniqueness. The skip test works by partially
iterating through a bucket, then closing one of the sockets that have
already been seen to remove it from the bucket. Before, this would have
resulted in skipping the fourth socket. Now, the fourth socket is seen.
The repeat test works by partially iterating through a bucket, then
adding four more sockets to the head of the bucket. Before, this would
have resulted in repeating several of the sockets from the first batch,
but now we see sockets exactly once.
@jrife jrife force-pushed the jrife/socket-iterators-tcp-udp branch from a8a5ff6 to 0dbe2cd Compare March 13, 2025 02:14
@jrife jrife closed this Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant