Skip to content

Wait for concurrent reapers in homa_sock_destroy - #153

Open
breakertt wants to merge 1 commit into
PlatformLab:mainfrom
breakertt:fix/destroy-wait-for-reapers
Open

breakertt wants to merge 1 commit into
PlatformLab:mainfrom
breakertt:fix/destroy-wait-for-reapers

Conversation

@breakertt

Copy link
Copy Markdown
Contributor

homa_sock_destroy waits only until dead_rpcs is empty. But homa_timer or SoftIRQ can still free the last batch that it took off the list. That reaper returns the buffers to the pool and subtracts their frag_bytes from sk_wmem_alloc. Destroy then hits WARN_ON_ONCE(sk_wmem_alloc != 1) and frees the pool under that reaper.

This patch counts the reaps in progress in hsk->reapers. Destroy increments protect_count, so a new reap returns at once, and then waits until reapers is 0.

Test on two xl170 nodes: 16 threads each keep 150 8 KB RPCs in flight, then all close their sockets together. On upstream, destroy found sk_wmem_alloc != 1 in 318 of 128000 closes. In one run, homa_timer then oopsed in homa_pool_free_bufs (NULL buffer_pool) and 2 sockets leaked. With this patch: 0 of 144000. cp_node throughput does not change.

Reproduction, logs and the oops: https://github.com/breakertt/HomaModule/tree/fix-artifact/destroy-wait-for-reapers

* homa_rpc_reap takes RPCs off dead_rpcs under the socket lock and frees
  them after unlocking; since d00a93b that is also when it subtracts
  their frag_bytes from sk_wmem_alloc. homa_sock_destroy only waited for
  dead_rpcs to be empty (its comment wrongly said that all references
  were gone), so while homa_timer or softirq still freed the last batch
  it hit WARN_ON_ONCE(sk_wmem_alloc != 1) and freed the buffer pool under
  the reaper.
* Count the reaps in progress in hsk->reapers. homa_sock_destroy now
  increments protect_count so that no new reap starts, and waits for
  hsk->reapers to reach zero before it checks sk_wmem_alloc and frees
  the pool.
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