public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, Pavel Machek <pavel@suse.cz>,
	pm list <linux-pm@lists.linux-foundation.org>,
	Zhang Rui <rui.zhang@intel.com>, Rus <harbour@sfinx.od.ua>
Subject: [PATCH -mm 5/8] Introduce new interface schedule_work_on
Date: Thu, 10 Jul 2008 02:03:26 +0200	[thread overview]
Message-ID: <200807100203.27170.rjw@sisk.pl> (raw)
In-Reply-To: <200807100152.17755.rjw@sisk.pl>

From: Zhang Rui <rui.zhang@intel.com>
Subject: Introduce new interface schedule_work_on

This interface allows adding a job on a specific cpu.

Although a work struct on a cpu will be scheduled to other cpu if the cpu dies,
there is a recursion if a work task tries to offline the cpu it's running on.
we need to schedule the task to a specific cpu in this case.
http://bugzilla.kernel.org/show_bug.cgi?id=10897

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Tested-by: Rus <harbour@sfinx.od.ua>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 include/linux/workqueue.h |    3 +++
 kernel/workqueue.c        |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

Index: linux-2.6/include/linux/workqueue.h
===================================================================
--- linux-2.6.orig/include/linux/workqueue.h	2007-05-04 10:57:08.000000000 +0800
+++ linux-2.6/include/linux/workqueue.h	2008-07-04 10:03:21.000000000 +0800
@@ -179,6 +179,8 @@
 extern void destroy_workqueue(struct workqueue_struct *wq);
 
 extern int queue_work(struct workqueue_struct *wq, struct work_struct *work);
+extern int queue_work_on(int cpu, 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_delayed_work_on(int cpu, struct workqueue_struct *wq,
@@ -188,6 +190,7 @@
 extern void flush_scheduled_work(void);
 
 extern int schedule_work(struct work_struct *work);
+extern int schedule_work_on(int cpu, struct work_struct *work);
 extern int schedule_delayed_work(struct delayed_work *work, unsigned long delay);
 extern int schedule_delayed_work_on(int cpu, struct delayed_work *work,
 					unsigned long delay);
Index: linux-2.6/kernel/workqueue.c
===================================================================
--- linux-2.6.orig/kernel/workqueue.c	2007-05-04 10:57:08.000000000 +0800
+++ linux-2.6/kernel/workqueue.c	2008-07-04 10:05:01.000000000 +0800
@@ -175,6 +175,32 @@
 }
 EXPORT_SYMBOL_GPL(queue_work);
 
+/**
+ * queue_work_on - queue work on specific cpu
+ * @cpu: CPU number to execute work on
+ * @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 a specific CPU
+ */
+int
+queue_work_on(int cpu, struct workqueue_struct *wq, struct work_struct *work)
+{
+	int ret = 0;
+
+	if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) {
+		BUG_ON(!list_empty(&work->entry));
+		preempt_disable();
+		__queue_work(wq_per_cpu(wq, cpu), work);
+		preempt_enable();
+		ret = 1;
+	}
+	return ret;
+}
+EXPORT_SYMBOL_GPL(queue_work_on);
+
 static void delayed_work_timer_fn(unsigned long __data)
 {
 	struct delayed_work *dwork = (struct delayed_work *)__data;
@@ -553,6 +579,19 @@
 }
 EXPORT_SYMBOL(schedule_work);
 
+/*
+ * schedule_work_on - put work task on a specific cpu
+ * @cpu: cpu to put the work task on
+ * @work: job to be done
+ *
+ * This puts a job on a specific cpu
+ */
+int schedule_work_on(int cpu, struct work_struct *work)
+{
+	return queue_work_on(cpu, keventd_wq, work);
+}
+EXPORT_SYMBOL(schedule_work_on);
+
 /**
  * schedule_delayed_work - put work task in global workqueue after delay
  * @dwork: job to be done


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/




  parent reply	other threads:[~2008-07-10  0:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-09 23:52 [PATCH -mm 0/8] PM patches for 2.6.27 Rafael J. Wysocki
2008-07-09 23:55 ` [PATCH -mm 1/8] PM: Add new PM_EVENT codes for runtime power transitions Rafael J. Wysocki
2008-07-10 11:34   ` Pavel Machek
2008-07-09 23:58 ` [PATCH -mm 2/8] AHCI: Speed-up resume Rafael J. Wysocki
2008-07-10 11:34   ` Pavel Machek
2008-07-10  0:00 ` [PATCH -mm 3/8] Hibernation: Simplify memory bitmap Rafael J. Wysocki
2008-07-10 11:34   ` Pavel Machek
2008-07-10  0:01 ` [PATCH -mm 4/8] serio: Speed-up resume Rafael J. Wysocki
2008-07-10 11:35   ` Pavel Machek
2008-07-10 15:11     ` Dmitry Torokhov
2008-07-10  0:03 ` Rafael J. Wysocki [this message]
2008-07-10 11:36   ` [PATCH -mm 5/8] Introduce new interface schedule_work_on Pavel Machek
2008-07-10  0:04 ` [PATCH -mm 6/8] Schedule sysrq poweroff on boot cpu Rafael J. Wysocki
2008-07-10 11:36   ` Pavel Machek
2008-07-10  0:05 ` [PATCH -mm 7/8] ACPI hibernation: Utilize hardware signature Rafael J. Wysocki
2008-07-10  8:34   ` Pavel Machek
2008-07-10  0:07 ` [PATCH -mm 8/8] ACPI PM: Add DMI quirk list for ACPI 1.0 suspend ordering Rafael J. Wysocki
2008-07-10 11:37   ` Pavel Machek

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=200807100203.27170.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=harbour@sfinx.od.ua \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=pavel@suse.cz \
    --cc=rui.zhang@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox