]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - kernel/workqueue.c
rxe: Fix a sleep-in-atomic bug in post_one_send
[karo-tx-linux.git] / kernel / workqueue.c
index bbf46da28e9ac0e7d9ae8d2024b39089a34d51d5..c74bf39ef7643fdc4ecc219aa25b58feabcd91f3 100644 (file)
@@ -4734,6 +4734,29 @@ long work_on_cpu(int cpu, long (*fn)(void *), void *arg)
        return wfc.ret;
 }
 EXPORT_SYMBOL_GPL(work_on_cpu);
+
+/**
+ * work_on_cpu_safe - run a function in thread context on a particular cpu
+ * @cpu: the cpu to run on
+ * @fn:  the function to run
+ * @arg: the function argument
+ *
+ * Disables CPU hotplug and calls work_on_cpu(). The caller must not hold
+ * any locks which would prevent @fn from completing.
+ *
+ * Return: The value @fn returns.
+ */
+long work_on_cpu_safe(int cpu, long (*fn)(void *), void *arg)
+{
+       long ret = -ENODEV;
+
+       get_online_cpus();
+       if (cpu_online(cpu))
+               ret = work_on_cpu(cpu, fn, arg);
+       put_online_cpus();
+       return ret;
+}
+EXPORT_SYMBOL_GPL(work_on_cpu_safe);
 #endif /* CONFIG_SMP */
 
 #ifdef CONFIG_FREEZER