mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Roland Dreier <rdreier@cisco.com>
Cc: linux-kernel@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Stefan Richter <stefanr@s5r6.in-berlin.de>
Subject: [PATCH 1/1] introduce __cancel_delayed_work()
Date: Fri, 28 Aug 2009 20:00:15 +0200	[thread overview]
Message-ID: <20090828180015.GB19326@redhat.com> (raw)
In-Reply-To: <20090828175931.GA19326@redhat.com>

cancel_delayed_work() has to use del_timer_sync() to guarantee the
timer function is not running after return. But most users doesn't
actually need this, and del_timer_sync() has problems: it is not
useable from interrupt, and it depends on every lock which could
be taken from irq.

Introduce __cancel_delayed_work() which calls del_timer() instead.

The immediate reason for this patch is
http://bugzilla.kernel.org/show_bug.cgi?id=13757
but hopefully this helper makes sense anyway.

As for 13757 bug, actually we need requeue_delayed_work(), but its
semantics is not clear yet.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>

--- MINI/include/linux/workqueue.h~CDW	2009-08-27 20:17:08.000000000 +0200
+++ MINI/include/linux/workqueue.h	2009-08-27 20:22:48.000000000 +0200
@@ -240,6 +240,21 @@ static inline int cancel_delayed_work(st
 	return ret;
 }
 
+/*
+ * Like above, but uses del_timer() instead of del_timer_sync(). This means,
+ * if it returns 0 the timer function may be running and the queueing is in
+ * progress.
+ */
+static inline int __cancel_delayed_work(struct delayed_work *work)
+{
+	int ret;
+
+	ret = del_timer(&work->timer);
+	if (ret)
+		work_clear_pending(&work->work);
+	return ret;
+}
+
 extern int cancel_delayed_work_sync(struct delayed_work *work);
 
 /* Obsolete. use cancel_delayed_work_sync() */


  reply	other threads:[~2009-08-28 18:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-20 21:51 Is adding requeue_delayed_work() a good idea Roland Dreier
2009-08-21 11:55 ` Oleg Nesterov
2009-08-21 21:53   ` Roland Dreier
2009-08-22 10:35     ` Stefan Richter
2009-08-24 18:01     ` Oleg Nesterov
2009-08-24 21:11       ` Roland Dreier
2009-08-25  9:39         ` Oleg Nesterov
2009-08-26 18:42           ` Roland Dreier
2009-08-28 17:59             ` [PATCH 0/1] introduce __cancel_delayed_work() Oleg Nesterov
2009-08-28 18:00               ` Oleg Nesterov [this message]
2009-09-01 16:09                 ` [PATCH 1/1] " Roland Dreier
2009-09-01 16:40                   ` Dmitry Torokhov
2009-09-01 22:29                     ` Andrew Morton
2009-09-01  0:44             ` Is adding requeue_delayed_work() a good idea Dmitry Torokhov

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=20090828180015.GB19326@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdreier@cisco.com \
    --cc=stefanr@s5r6.in-berlin.de \
    /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®