• X
    io_uring: use cond_resched() in io_ring_ctx_wait_and_kill() · 8e086891
    Xiaoguang Wang 提交于
    to #28170604
    
    commit 3fd44c86711f71156b586c22b0495c58f69358bb upstream
    
    While working on to make io_uring sqpoll mode support syscalls that need
    struct files_struct, I got cpu soft lockup in io_ring_ctx_wait_and_kill(),
    
        while (ctx->sqo_thread && !wq_has_sleeper(&ctx->sqo_wait))
            cpu_relax();
    
    above loop never has an chance to exit, it's because preempt isn't enabled
    in the kernel, and the context calling io_ring_ctx_wait_and_kill() and
    io_sq_thread() run in the same cpu, if io_sq_thread calls a cond_resched()
    yield cpu and another context enters above loop, then io_sq_thread() will
    always in runqueue and never exit.
    
    Use cond_resched() can fix this issue.
    
     Reported-by: syzbot+66243bb7126c410cefe6@syzkaller.appspotmail.com
    Signed-off-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
    Signed-off-by: NJens Axboe <axboe@kernel.dk>
    Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
    8e086891
io_uring.c 191.3 KB