Unverified Commit 923dfb22 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!14987 workqueue: Do not warn when cancelling WQ_MEM_RECLAIM work from !WQ_MEM_RECLAIM worker

parents 1e23c363 9aad6173
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -2940,23 +2940,27 @@ static int rescuer_thread(void *__rescuer)
 * check_flush_dependency - check for flush dependency sanity
 * @target_wq: workqueue being flushed
 * @target_work: work item being flushed (NULL for workqueue flushes)
 * @from_cancel: are we called from the work cancel path
 *
 * %current is trying to flush the whole @target_wq or @target_work on it.
 * If @target_wq doesn't have %WQ_MEM_RECLAIM, verify that %current is not
 * reclaiming memory or running on a workqueue which doesn't have
 * %WQ_MEM_RECLAIM as that can break forward-progress guarantee leading to
 * a deadlock.
 * If this is not the cancel path (which implies work being flushed is either
 * already running, or will not be at all), check if @target_wq doesn't have
 * %WQ_MEM_RECLAIM and verify that %current is not reclaiming memory or running
 * on a workqueue which doesn't have %WQ_MEM_RECLAIM as that can break forward-
 * progress guarantee leading to a deadlock.
 */
static void check_flush_dependency(struct workqueue_struct *target_wq,
				   struct work_struct *target_work)
				   struct work_struct *target_work,
				   bool from_cancel)
{
	work_func_t target_func = target_work ? target_work->func : NULL;
	work_func_t target_func;
	struct worker *worker;

	if (target_wq->flags & WQ_MEM_RECLAIM)
	if (from_cancel || target_wq->flags & WQ_MEM_RECLAIM)
		return;

	worker = current_wq_worker();
	target_func = target_work ? target_work->func : NULL;

	WARN_ONCE(current->flags & PF_MEMALLOC,
		  "workqueue: PF_MEMALLOC task %d(%s) is flushing !WQ_MEM_RECLAIM %s:%ps",
@@ -3189,7 +3193,7 @@ void __flush_workqueue(struct workqueue_struct *wq)
		list_add_tail(&this_flusher.list, &wq->flusher_overflow);
	}

	check_flush_dependency(wq, NULL);
	check_flush_dependency(wq, NULL, false);

	mutex_unlock(&wq->mutex);

@@ -3364,7 +3368,7 @@ static bool start_flush_work(struct work_struct *work, struct wq_barrier *barr,
		pwq = worker->current_pwq;
	}

	check_flush_dependency(pwq->wq, work);
	check_flush_dependency(pwq->wq, work, from_cancel);

	insert_wq_barrier(pwq, barr, work, worker);
	raw_spin_unlock_irq(&pool->lock);