Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rxe: fix completion queue consumer index overrun
Fix a bug in the CQ polling sequence where the consumer index can incorrectly advance beyond available completions. Consider this polling sequence: ``` ibv_start_poll(); ibv_next_poll(); ibv_end_poll(); ibv_start_poll(); ``` With one completion in the queue, the indices would be: 1. After `ibv_start_poll()` (reading first CQE): P ┌──┬─┴┬──┬──┬──┐ └─┬┴──┴──┴──┴──┘ C 2. After `ibv_next_poll()` (returns `ENOENT`): P ┌──┬─┴┬──┬──┬──┐ └──┴─┬┴──┴──┴──┘ C 3. After `ibv_end_poll()`: P ┌──┬─┴┬──┬──┬──┐ └──┴──┴─┬┴──┴──┘ C The issue occurs because `ibv_end_poll()` advances the consumer index even after `ibv_next_poll()` returns `ENOENT`. This causes the consumer index to move beyond the producer index, leading to: - False indication of available completions - Reading of uninitialized completion entries Fix this by checking for available completions before advancing the consumer index in `ibv_next_poll()`. Note: According to the man page, `ibv_end_poll()` must be called even when `ibv_next_poll()` returns `ENOENT`, but consumer index should only be advanced once in this case. Signed-off-by: Luke Yue <lukedyue@gmail.com>
- Loading branch information