From: Andrew Morton <akpm@linux-foundation.org>
To: Tejun Heo <tj@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH v2.6.36-rc7] init: don't call flush_scheduled_work() from do_initcalls()
Date: Fri, 22 Oct 2010 11:09:25 -0700 [thread overview]
Message-ID: <20101022110925.ea1263f8.akpm@linux-foundation.org> (raw)
In-Reply-To: <4CC14ADA.9080706@kernel.org>
On Fri, 22 Oct 2010 10:27:06 +0200 Tejun Heo <tj@kernel.org> wrote:
> > If you really don't like people sending you angry emails then I suppose
> > you could add some warning here if a scheduled work is pending, and
> > that the scheduled work's callback existed in init.text memory. Which
> > would be a bit of a pain to implement.
> >
> > Oh well. The oops traces will make it fairly clear what happened.
>
> I haven't pushed the patch to Linus yet. I'll remove it for now and
> try to implement something which at least checks the text section of
> pending and running works.
mm.. I think we'd be OK to merge it. Any such code is pretty badly
buggy and is probably also crashable with a well-timed rmmod.
It'll also be code which few people ever use, so any runtime checks
won't get us very good coverage.
Still, if it's not too hard to implement an "are there any scheduled
works which live in initmem" check then I guess that would be the
prudent approach. A quite gross way of implementing that might be
something like
init/main.c | 3 +++
kernel/workqueue.c | 11 ++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff -puN init/main.c~a init/main.c
--- a/init/main.c~a
+++ a/init/main.c
@@ -125,6 +125,7 @@ static char *ramdisk_execute_command;
unsigned int setup_max_cpus = NR_CPUS;
EXPORT_SYMBOL(setup_max_cpus);
+int scheduled_work_hack;
/*
* Setup routine for controlling SMP activation
@@ -780,7 +781,9 @@ static void __init do_initcalls(void)
do_one_initcall(*fn);
/* Make sure there is no pending stuff from the initcall sequence */
+ scheduled_work_hack++;
flush_scheduled_work();
+ scheduled_work_hack++;
}
/*
diff -puN kernel/workqueue.c~a kernel/workqueue.c
--- a/kernel/workqueue.c~a
+++ a/kernel/workqueue.c
@@ -41,6 +41,7 @@
#include <linux/debug_locks.h>
#include <linux/lockdep.h>
#include <linux/idr.h>
+#include <asm/sections.h>
#define CREATE_TRACE_POINTS
#include <trace/events/workqueue.h>
@@ -1819,7 +1820,15 @@ __acquires(&gcwq->lock)
lock_map_acquire(&cwq->wq->lockdep_map);
lock_map_acquire(&lockdep_map);
trace_workqueue_execute_start(work);
- f(work);
+ {
+ extern int scheduled_work_hack;
+
+ if (scheduled_work_hack &&
+ (f >= (void *)__init_begin && f < (void *)__init_end))
+ eek();
+ else
+ f(work);
+ }
/*
* While we must be careful to not use "work" after this, the trace
* point will only record its address.
_
next prev parent reply other threads:[~2010-10-22 18:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-15 15:13 [PATCH v2.6.36-rc7] init: don't call flush_scheduled_work() from do_initcalls() Tejun Heo
2010-10-19 15:28 ` Tejun Heo
2010-10-22 0:12 ` Andrew Morton
2010-10-22 8:27 ` Tejun Heo
2010-10-22 18:09 ` Andrew Morton [this message]
2010-11-03 10:59 ` Tejun Heo
2010-11-03 12:48 ` Andrew Morton
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=20101022110925.ea1263f8.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.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.