riscv: Kconfig: Add select ARM_AMBA to SOC_STARFIVE
[platform/kernel/linux-starfive.git] / io_uring / sqpoll.c
index 5596523..7b6facf 100644 (file)
@@ -256,9 +256,13 @@ static int io_sq_thread(void *data)
                        sqt_spin = true;
 
                if (sqt_spin || !time_after(jiffies, timeout)) {
-                       cond_resched();
                        if (sqt_spin)
                                timeout = jiffies + sqd->sq_thread_idle;
+                       if (unlikely(need_resched())) {
+                               mutex_unlock(&sqd->lock);
+                               cond_resched();
+                               mutex_lock(&sqd->lock);
+                       }
                        continue;
                }
 
@@ -419,3 +423,20 @@ err:
        io_sq_thread_finish(ctx);
        return ret;
 }
+
+__cold int io_sqpoll_wq_cpu_affinity(struct io_ring_ctx *ctx,
+                                    cpumask_var_t mask)
+{
+       struct io_sq_data *sqd = ctx->sq_data;
+       int ret = -EINVAL;
+
+       if (sqd) {
+               io_sq_thread_park(sqd);
+               /* Don't set affinity for a dying thread */
+               if (sqd->thread)
+                       ret = io_wq_cpu_affinity(sqd->thread->io_uring, mask);
+               io_sq_thread_unpark(sqd);
+       }
+
+       return ret;
+}