riscv: Kconfig: Add select ARM_AMBA to SOC_STARFIVE
[platform/kernel/linux-starfive.git] / io_uring / sqpoll.c
index 76d4d70..7b6facf 100644 (file)
@@ -235,8 +235,6 @@ static int io_sq_thread(void *data)
                set_cpus_allowed_ptr(current, cpu_online_mask);
        current->flags |= PF_NO_SETAFFINITY;
 
-       audit_alloc_kernel(current);
-
        mutex_lock(&sqd->lock);
        while (1) {
                bool cap_entries, sqt_spin = false;
@@ -258,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;
                }
 
@@ -310,8 +312,6 @@ static int io_sq_thread(void *data)
        io_run_task_work();
        mutex_unlock(&sqd->lock);
 
-       audit_free(current);
-
        complete(&sqd->exited);
        do_exit(0);
 }
@@ -423,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;
+}