mirror of
https://passt.top/passt
synced 2025-06-13 11:05:34 +02:00
flow: Avoid moving flow entries to compact table
Currently we always keep the flow table maximally compact: that is all the active entries are contiguous at the start of the table. Doing this sometimes requires moving an entry when one is freed. That's kind of fiddly, and potentially expensive: it requires updating the hash table for the new location, and depending on flow type, it may require EPOLL_CTL_MOD, system calls to update epoll tags with the new location too. Implement a new way of managing the flow table that doesn't ever move entries. It attempts to maintain some compactness by always using the first free slot for a new connection, and mitigates the effect of non compactness by cheaply skipping over contiguous blocks of free entries. See the "theory of operation" comment in flow.c for details. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>b [sbrivio: additional ASSERT(flow_first_free <= FLOW_MAX - 2) to avoid Coverity Scan false positive] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
9c0881d4f6
commit
8981a720aa
7 changed files with 166 additions and 86 deletions
23
tcp.c
23
tcp.c
|
@ -1251,29 +1251,6 @@ static void tcp_hash_remove(const struct ctx *c,
|
|||
tc_hash[b] = FLOW_SIDX_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* tcp_tap_conn_update() - Update tcp_tap_conn when being moved in the table
|
||||
* @c: Execution context
|
||||
* @old: Old location of tcp_tap_conn
|
||||
* @new: New location of tcp_tap_conn
|
||||
*/
|
||||
void tcp_tap_conn_update(const struct ctx *c, struct tcp_tap_conn *old,
|
||||
struct tcp_tap_conn *new)
|
||||
|
||||
{
|
||||
unsigned b = tcp_hash_probe(c, old);
|
||||
|
||||
if (!flow_at_sidx(tc_hash[b]))
|
||||
return; /* Not in hash table, nothing to update */
|
||||
|
||||
tc_hash[b] = FLOW_SIDX(new, TAPSIDE);
|
||||
|
||||
debug("TCP: hash table update: old index %u, new index %u, sock %i, "
|
||||
"bucket: %u", FLOW_IDX(old), FLOW_IDX(new), new->sock, b);
|
||||
|
||||
tcp_epoll_ctl(c, new);
|
||||
}
|
||||
|
||||
/**
|
||||
* tcp_hash_lookup() - Look up connection given remote address and ports
|
||||
* @c: Execution context
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue