summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-08-21 13:11:06 +0100
committerMark Brown <broonie@kernel.org>2026-08-21 13:11:06 +0100
commit090658cad1132ea72e686310e8ac010fcc93f065 (patch)
tree7f56fe05817f990379510b2f86bda756d59273fa /kernel
parent22cc35c9d09084ea0ef2617991a26a43c934e006 (diff)
parent10f307e525a1783570a39eb9ac146d45f4f16b3e (diff)
downloadlinux-next-090658cad1132ea72e686310e8ac010fcc93f065.tar.gz
linux-next-090658cad1132ea72e686310e8ac010fcc93f065.zip
Merge branch 'linux-next' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6.git
Diffstat (limited to 'kernel')
-rw-r--r--kernel/workqueue.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index bfeef512f6dd..3c034cbc5bb3 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -6294,6 +6294,30 @@ bool current_is_workqueue_rescuer(void)
}
/**
+ * current_is_workqueue_mem_reclaim - is %current a %WQ_MEM_RECLAIM worker?
+ *
+ * Determine whether %current is a workqueue worker executing on a workqueue
+ * created with %WQ_MEM_RECLAIM. This mirrors the condition that
+ * check_flush_dependency() warns on: flushing (or otherwise waiting on) a
+ * !WQ_MEM_RECLAIM workqueue from such a context breaks the forward-progress
+ * guarantee and can deadlock. Callers that may recurse into such a flush --
+ * e.g. NFS LOCALIO submitting into a stacked filesystem that flushes its own
+ * !WQ_MEM_RECLAIM workqueue -- can use this to decide whether they must defer
+ * the work to a !WQ_MEM_RECLAIM workqueue rather than run it inline.
+ *
+ * Return: %true if %current is a %WQ_MEM_RECLAIM worker. %false otherwise.
+ */
+bool current_is_workqueue_mem_reclaim(void)
+{
+ struct worker *worker = current_wq_worker();
+
+ return worker &&
+ ((worker->current_pwq->wq->flags &
+ (WQ_MEM_RECLAIM | __WQ_LEGACY)) == WQ_MEM_RECLAIM);
+}
+EXPORT_SYMBOL_GPL(current_is_workqueue_mem_reclaim);
+
+/**
* workqueue_congested - test whether a workqueue is congested
* @cpu: CPU in question
* @wq: target workqueue