From: Oleg Nesterov <oleg@tv-sign.ru>
To: David Howells <dhowells@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Miller <davem@davemloft.net>,
ebiederm@xmission.com, containers@lists.osdl.org,
hch@infradead.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: Getting the new RxRPC patches upstream
Date: Tue, 24 Apr 2007 23:34:04 +0400 [thread overview]
Message-ID: <20070424193404.GA5042@tv-sign.ru> (raw)
In-Reply-To: <17966.1177438970@redhat.com>
On 04/24, David Howells wrote:
>
> Oleg Nesterov <oleg@tv-sign.ru> wrote:
>
> > Sure, I'll grep for cancel_delayed_work(). But unless I missed something,
> > this change should be completely transparent for all users. Otherwise, it
> > is buggy.
>
> I guess you will have to make sure that cancel_delayed_work() is always
> followed by a flush of the workqueue, otherwise you might get this situation:
>
> CPU 0 CPU 1
> =============================== =======================
> <timer expires>
> cancel_delayed_work(x) == 0 -->delayed_work_timer_fn(x)
> kfree(x); -->do_IRQ()
> y = kmalloc(); // reuses x
> <--do_IRQ()
> __queue_work(x)
> --- OOPS ---
>
> That's my main concern. If you are certain that can't happen, then fair
> enough.
Yes sure. Note that this is documented:
/*
* Kill off a pending schedule_delayed_work(). Note that the work callback
* function may still be running on return from cancel_delayed_work(). Run
* flush_workqueue() or cancel_work_sync() to wait on it.
*/
This comment is not very precise though. If the work doesn't re-arm itself,
we need cancel_work_sync() only if cancel_delayed_work() returns 0.
So there is no difference with the proposed change. Except, return value == 0
means:
currently (del_timer_sync): callback may still be running or scheduled
with del_timer: may still be running, or scheduled, or will be scheduled
right now.
However, this is the same from the caller POV.
> Can you show me a patch illustrating exactly how you want to change
> cancel_delayed_work()? I can't remember whether you've done so already, but
> if you have, I can't find it. Is it basically this?:
>
> static inline int cancel_delayed_work(struct delayed_work *work)
> {
> int ret;
>
> - ret = del_timer_sync(&work->timer);
> + ret = del_timer(&work->timer);
> if (ret)
> work_release(&work->work);
> return ret;
> }
Yes, exactly. The patch is trivial, but I need some time to write the
understandable changelog...
> I was thinking this situation might be a problem:
>
> CPU 0 CPU 1
> =============================== =======================
> <timer expires>
> cancel_delayed_work(x) == 0 -->delayed_work_timer_fn(x)
> schedule_delayed_work(x,0) -->do_IRQ()
> <keventd scheduled>
> x->work()
> <--do_IRQ()
> __queue_work(x)
>
> But it won't, will it?
Yes, I think this should be OK. schedule_delayed_work() will notice
_PENDING and abort, so the last "x->work()" doesn't happen.
What can happen is
<timer expires>
cancel_delayed_work(x) == 0
-->delayed_work_timer_fn(x)
__queue_work(x)
<keventd scheduled>
x->work()
schedule_delayed_work(x,0)
<the work is scheduled again>
, so we can have an "unneeded schedule", but this is very unlikely.
Oleg.
next prev parent reply other threads:[~2007-04-24 19:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <11769696211263-git-send-email-ebiederm@xmission.com>
[not found] ` <m1slawn9eb.fsf@ebiederm.dsl.xmission.com>
[not found] ` <29341.1176975158@redhat.com>
[not found] ` <m1lkgoms4j.fsf@ebiederm.dsl.xmission.com>
2007-04-19 14:18 ` Getting the new RxRPC patches upstream David Howells
2007-04-19 15:50 ` Eric W. Biederman
2007-04-19 16:18 ` David Howells
2007-04-19 19:14 ` Eric W. Biederman
2007-04-19 20:14 ` David Miller
2007-04-20 1:15 ` Herbert Xu
2007-04-20 8:02 ` David Howells
2007-04-20 8:58 ` David Miller
2007-04-20 10:41 ` David Howells
2007-04-20 18:38 ` Andrew Morton
2007-04-20 21:28 ` Oleg Nesterov
2007-04-23 8:32 ` David Howells
2007-04-23 17:11 ` Oleg Nesterov
2007-04-24 13:37 ` David Howells
2007-04-24 14:22 ` Oleg Nesterov
2007-04-24 15:51 ` David Howells
2007-04-24 16:40 ` Oleg Nesterov
2007-04-24 16:58 ` David Howells
2007-04-24 17:33 ` Oleg Nesterov
2007-04-24 18:22 ` David Howells
2007-04-24 19:34 ` Oleg Nesterov [this message]
2007-04-25 8:10 ` David Howells
2007-04-25 10:41 ` Oleg Nesterov
2007-04-25 10:45 ` David Howells
2007-04-25 13:48 ` David Howells
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=20070424193404.GA5042@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.osdl.org \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).