Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ int mx_complete_handler(void *arg)
while (!kthread_should_stop()) {
bool zombie_only = (atomic_read(&q->wait_count) > 0 &&
atomic_read(&q->zombie_wait_count) == atomic_read(&q->wait_count));
bool popped_any = false;

__swait_event_interruptible_timeout(q->cq_wait,
atomic_read(&q->wait_count) - atomic_read(&q->zombie_wait_count) > 0,
zombie_only ? ZOMBIE_POLL_INTERVAL_MSEC : POLLING_INTERVAL_MSEC);

while (ops->is_popable(q)) {
popped_any = true;
ops->pop_completion(q, &info);

transfer = find_transfer_by_id(info.id);
Expand Down Expand Up @@ -217,6 +219,15 @@ int mx_complete_handler(void *arg)

if (ops->post_complete)
ops->post_complete(q);

/*
* If completions were expected but none arrived, sleep to
* avoid busy-looping (the swait above does not sleep when
* its condition is already true).
*/
if (!popped_any)
schedule_timeout_interruptible(
msecs_to_jiffies(POLLING_INTERVAL_MSEC));
}

return 0;
Expand Down