From: Andrew Morton <akpm@digeo.com>
To: Roland Dreier <roland@topspin.com>
Cc: spstarr@sh0n.net, rml@tech9.net, rmk@arm.linux.org.uk,
linux-kernel@vger.kernel.org
Subject: Re: [BUG][2.5.66bk9+] - tty hangings - patches, dmesg & sysctl+T info
Date: Tue, 8 Apr 2003 21:56:51 -0700 [thread overview]
Message-ID: <20030408215651.503685ee.akpm@digeo.com> (raw)
In-Reply-To: <52znn0mg3o.fsf@topspin.com>
Roland Dreier <roland@topspin.com> wrote:
>
> Still, I like the idea of this patch, since it resolves the livelock.
> But I don't think the implementation is quite right. insert_sequence
> doesn't get incremented until delayed_work_timer_fn(). That means
> that a driver (tty_io.c, for example) could call
> schedule_delayed_work(), then call flush_scheduled_work() before
> delayed_work_timer_fn() has run for that work.
The driver needs to run cancel_delayed_work() before calling
flush_scheduled_work(). The tty patch is already doing that, and I think
that plugs the holes.
Here's a full changelog.
The workqueue code currently has a notion of a per-cpu queue being "busy".
flush_scheduled_work()'s responsibility is to wait for a queue to be not busy.
Problem is, flush_scheduled_work() can easily hang up.
- The workqueue is deemed "busy" when there are pending (timer-based)
works. But if someone repeatedly schedules new work in the delayed
callback, the queue will never fall idle, and flush_scheduled_work() will
not complete.
- If someone reschedules work (not delayed work) in the work function, that
too will cause the queue to never go idle, and flush_scheduled_work() will
not terminate.
So what this patch does is:
- Create a new "cancel_delayed_work()" which will try to kill off any
timer-based works.
- Change flush_scheduled_work() so that it is immune to people re-adding
work in the work callout handler.
We can do this by recognising that the caller does *not* want to wait
until the workqueue is "empty". The caller merely wants to wait until all
works which were pending at the time flush_scheduled_work() was called have
completed.
The patch uses a couple of sequence numbers for that.
So now, if someone wants to reliably remove delayed work they should do:
/*
* Make sure that my work-callback will no longer schedule new work
*/
my_driver_is_shutting_down = 1;
/*
* Kill off any pending delayed work
*/
cancel_delayed_work(&my_work);
/*
* OK, there will be no new works scheduled. But there may be one
* currently queued or in progress. So wait for that to complete.
*/
flush_scheduled_work();
And change the flush_workqueue() sleep to be uninterruptible. We worry that
delivery of a signal may cause the wait to return too early.
next prev parent reply other threads:[~2003-04-09 4:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-06 20:09 [BUG][2.5.66bk9+] - changes to timers still broken - we don't oops anymore Shawn Starr
2003-04-06 20:20 ` Roland Dreier
2003-04-06 20:38 ` Andrew Morton
2003-04-06 21:00 ` Shawn Starr
2003-04-09 2:12 ` [BUG][2.5.66bk9+] - tty hangings - patches, dmesg & sysctl+T info Shawn Starr
2003-04-09 4:12 ` Andrew Morton
2003-04-09 4:47 ` Roland Dreier
2003-04-09 4:56 ` Andrew Morton [this message]
2003-04-09 4:16 ` Roland Dreier
2003-04-09 4:27 ` Andrew Morton
2003-04-09 4:52 ` Roland Dreier
2003-04-09 5:01 ` Shawn Starr
2003-04-12 16:08 Shawn Starr
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=20030408215651.503685ee.akpm@digeo.com \
--to=akpm@digeo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk@arm.linux.org.uk \
--cc=rml@tech9.net \
--cc=roland@topspin.com \
--cc=spstarr@sh0n.net \
/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
all inboxes | Powered by JetHome®