All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: linux-mm <linux-mm@kvack.org>, Hillf Danton <hdanton@sina.com>
Subject: [RFC 1/4] workqueue: fix selecting cpu for queuing work
Date: Wed, 11 Dec 2019 18:59:19 +0800	[thread overview]
Message-ID: <20191211105919.10652-1-hdanton@sina.com> (raw)
In-Reply-To: <20191211104601.16468-1-hdanton@sina.com>


Round robin is needed only for unbound workqueue and wq_unbound_cpumask
has nothing to do with standard workqueues, so we have to select cpu in
case of WORK_CPU_UNBOUND also with workqueue type taken into account.

Fixes: ef557180447f ("workqueue: schedule WORK_CPU_UNBOUND work on wq_unbound_cpumask CPUs")
Signed-off-by: Hillf Danton <hdanton@sina.com>
---

--- a/kernel/workqueue.c
+++ c/kernel/workqueue.c
@@ -1409,16 +1409,19 @@ static void __queue_work(int cpu, struct
 	if (unlikely(wq->flags & __WQ_DRAINING) &&
 	    WARN_ON_ONCE(!is_chained_work(wq)))
 		return;
+
 	rcu_read_lock();
 retry:
-	if (req_cpu == WORK_CPU_UNBOUND)
-		cpu = wq_select_unbound_cpu(raw_smp_processor_id());
-
 	/* pwq which will be used unless @work is executing elsewhere */
-	if (!(wq->flags & WQ_UNBOUND))
-		pwq = per_cpu_ptr(wq->cpu_pwqs, cpu);
-	else
+	if (wq->flags & WQ_UNBOUND) {
+		if (req_cpu == WORK_CPU_UNBOUND)
+			cpu = wq_select_unbound_cpu(raw_smp_processor_id());
 		pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu));
+	} else {
+		if (req_cpu == WORK_CPU_UNBOUND)
+			cpu = raw_smp_processor_id();
+		pwq = per_cpu_ptr(wq->cpu_pwqs, cpu);
+	}
 
 	/*
 	 * If @work was previously on a different pool, it might still be



  reply	other threads:[~2019-12-11 10:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-11 10:46 [RFC 0/4] workqueue: fix selecting cpu for queuing work and cleanup Hillf Danton
2019-12-11 10:59 ` Hillf Danton [this message]
2019-12-11 23:07   ` [RFC 1/4] workqueue: fix selecting cpu for queuing work Daniel Jordan
2020-01-23 22:37     ` Daniel Jordan
2020-01-24  1:01     ` Hillf Danton
2019-12-11 11:12 ` [RFC 2/4] workqueue: use smp_processor_id() on " Hillf Danton
2019-12-11 11:22 ` [RFC 3/4] workqueue: reap dead pool workqueue " Hillf Danton
2019-12-11 23:25   ` Daniel Jordan
2019-12-12  2:28   ` Hillf Danton
2019-12-11 11:33 ` [RFC 4/4] workqueue: use integer for cpu " Hillf Danton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191211105919.10652-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.