From: Andi Kleen <andi@firstfloor.org>
To: linux-kernel@vger.kernel.org
Cc: fengguang.wu@intel.com, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH] HWPOISON: Allow schedule_on_each_cpu() from keventd
Date: Thu, 22 Oct 2009 08:02:31 +0200 [thread overview]
Message-ID: <1256191352-6903-8-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1256191352-6903-7-git-send-email-andi@firstfloor.org>
From: Andi Kleen <ak@linux.intel.com>
Right now when calling schedule_on_each_cpu() from keventd there
is a deadlock because it tries to schedule a work item on the current CPU
too. This happens via lru_add_drain_all() in hwpoison.
Just call the function for the current CPU in this case. This is actually
faster too.
Debugging with Fengguang Wu & Max Asbock
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
kernel/workqueue.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index addfe2d..f61a2fe 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -667,21 +667,38 @@ EXPORT_SYMBOL(schedule_delayed_work_on);
int schedule_on_each_cpu(work_func_t func)
{
int cpu;
+ int orig = -1;
struct work_struct *works;
works = alloc_percpu(struct work_struct);
if (!works)
return -ENOMEM;
+ /*
+ * when running in keventd don't schedule a work item on itself.
+ * Can just call directly because the work queue is already bound.
+ * This also is faster.
+ * Make this a generic parameter for other workqueues?
+ */
+ if (current_is_keventd()) {
+ orig = raw_smp_processor_id();
+ INIT_WORK(per_cpu_ptr(works, orig), func);
+ func(per_cpu_ptr(works, orig));
+ }
+
get_online_cpus();
for_each_online_cpu(cpu) {
struct work_struct *work = per_cpu_ptr(works, cpu);
+ if (cpu == orig)
+ continue;
INIT_WORK(work, func);
schedule_work_on(cpu, work);
}
- for_each_online_cpu(cpu)
- flush_work(per_cpu_ptr(works, cpu));
+ for_each_online_cpu(cpu) {
+ if (cpu != orig)
+ flush_work(per_cpu_ptr(works, cpu));
+ }
put_online_cpus();
free_percpu(works);
return 0;
--
1.6.0.2
next prev parent reply other threads:[~2009-10-22 6:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <i>
2009-10-22 6:02 ` HWPOISON updates for 2.6.32-rc5 for review Andi Kleen
2009-10-22 6:02 ` [PATCH] HWPOISON: Clean up PR_MCE_KILL interface Andi Kleen
2009-10-22 6:02 ` [PATCH] HWPOISON: Add brief hwpoison description to Documentation Andi Kleen
2009-10-22 6:02 ` [PATCH] HWPOISON: return early on non-LRU pages Andi Kleen
2009-10-22 6:02 ` [PATCH] HWPOISON: Fix page count leak in hwpoison late kill in do_swap_page Andi Kleen
2009-10-22 6:02 ` [PATCH] HWPOISON: fix oops on ksm pages Andi Kleen
2009-10-22 6:02 ` [PATCH] HWPOISON: fix/proc/meminfo alignment Andi Kleen
2009-10-22 6:02 ` Andi Kleen [this message]
2009-10-22 6:02 ` [PATCH] HWPOISON: fix invalid page count in printk output Andi Kleen
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=1256191352-6903-8-git-send-email-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=ak@linux.intel.com \
--cc=fengguang.wu@intel.com \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome