LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: linux-kernel@vger.kernel.org
Cc: npiggin@suse.de, dgc@sgi.com, Jens Axboe <jens.axboe@oracle.com>
Subject: [PATCH 5/7] Add interface for queuing work on a specific CPU
Date: Wed, 12 Mar 2008 12:55:38 +0100	[thread overview]
Message-ID: <1205322940-20127-6-git-send-email-jens.axboe@oracle.com> (raw)
In-Reply-To: <1205322940-20127-1-git-send-email-jens.axboe@oracle.com>

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
---
 include/linux/workqueue.h |    2 ++
 kernel/workqueue.c        |   33 ++++++++++++++++++++++++++-------
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 542526c..fcc400b 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -181,6 +181,8 @@ extern void destroy_workqueue(struct workqueue_struct *wq);
 extern int queue_work(struct workqueue_struct *wq, struct work_struct *work);
 extern int queue_delayed_work(struct workqueue_struct *wq,
 			struct delayed_work *work, unsigned long delay);
+extern int queue_work_on_cpu(struct workqueue_struct *wq,
+			struct work_struct *work, int cpu);
 extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
 			struct delayed_work *work, unsigned long delay);
 
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ff06611..6bbd7b0 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -152,25 +152,44 @@ static void __queue_work(struct cpu_workqueue_struct *cwq,
 }
 
 /**
- * queue_work - queue work on a workqueue
+ * queue_work_on_cpu - queue work on a workqueue on a specific CPU
  * @wq: workqueue to use
  * @work: work to queue
+ * @cpu: cpu to queue the work on
  *
  * Returns 0 if @work was already on a queue, non-zero otherwise.
- *
- * We queue the work to the CPU it was submitted, but there is no
- * guarantee that it will be processed by that CPU.
  */
-int queue_work(struct workqueue_struct *wq, struct work_struct *work)
+int queue_work_on_cpu(struct workqueue_struct *wq, struct work_struct *work,
+		      int cpu)
 {
 	int ret = 0;
 
 	if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) {
 		BUG_ON(!list_empty(&work->entry));
-		__queue_work(wq_per_cpu(wq, get_cpu()), work);
-		put_cpu();
+		__queue_work(wq_per_cpu(wq, cpu), work);
 		ret = 1;
 	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(queue_work_on_cpu);
+
+/**
+ * queue_work - queue work on a workqueue
+ * @wq: workqueue to use
+ * @work: work to queue
+ *
+ * Returns 0 if @work was already on a queue, non-zero otherwise.
+ *
+ * We queue the work to the CPU it was submitted, but there is no
+ * guarantee that it will be processed by that CPU.
+ */
+int queue_work(struct workqueue_struct *wq, struct work_struct *work)
+{
+	int ret;
+
+	ret = queue_work_on_cpu(wq, work, get_cpu());
+	put_cpu();
 	return ret;
 }
 EXPORT_SYMBOL_GPL(queue_work);
-- 
1.5.4.GIT


  parent reply	other threads:[~2008-03-12 11:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-12 11:55 [PATCH 0/7] IO CPU affinity testing series Jens Axboe
2008-03-12 11:55 ` [PATCH 1/7] x86-64: introduce fast variant of smp_call_function_single() Jens Axboe
2008-03-14 18:21   ` Jeremy Fitzhardinge
2008-03-16 18:45     ` Jens Axboe
2008-03-16 22:58       ` Jeremy Fitzhardinge
2008-03-17  2:24         ` Nick Piggin
2008-03-17  7:25         ` Jens Axboe
2008-03-12 11:55 ` [PATCH 2/7] x86-64: speedup and tweak smp_call_function_single() Jens Axboe
2008-03-12 11:55 ` [PATCH 3/7] x86: add fast smp_call_function_single() Jens Axboe
2008-03-12 11:55 ` [PATCH 4/7] block: split softirq handling into blk-softirq.c Jens Axboe
2008-03-12 11:55 ` Jens Axboe [this message]
2008-03-12 11:55 ` [PATCH 6/7] block: make kblockd_schedule_work() take the queue as parameter Jens Axboe
2008-03-12 11:55 ` [PATCH 7/7] block: add test code for testing CPU affinity Jens Axboe
2008-03-12 16:41 ` [PATCH 0/7] IO CPU affinity testing series Alan D. Brunelle
2008-03-12 17:54   ` Jens Axboe
2008-03-12 20:37 ` Max Krasnyanskiy
2008-03-13 12:13   ` Jens Axboe
2008-03-13 14:54 ` Alan D. Brunelle
2008-03-13 15:00   ` Jens Axboe

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=1205322940-20127-6-git-send-email-jens.axboe@oracle.com \
    --to=jens.axboe@oracle.com \
    --cc=dgc@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --subject='Re: [PATCH 5/7] Add interface for queuing work on a specific CPU' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).