From: Oleg Nesterov <oleg@tv-sign.ru>
To: Tom Zanussi <zanussi@comcast.net>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] relay: use plain timer instead of delayed work
Date: Sun, 6 May 2007 16:47:42 +0400 [thread overview]
Message-ID: <20070506124742.GA102@tv-sign.ru> (raw)
In-Reply-To: <1178426780.29337.67.camel@ubuntu>
On 05/05, Tom Zanussi wrote:
>
> This patch makes relay use timers instead of workqueues for reader
> waking.
A couple of very minor nits,
> @@ -337,11 +334,11 @@ static void __relay_reset(struct rchan_buf *buf, unsigned int init)
> if (init) {
> init_waitqueue_head(&buf->read_wait);
> kref_init(&buf->kref);
> - INIT_DELAYED_WORK(&buf->wake_readers, NULL);
> - } else {
> - cancel_delayed_work(&buf->wake_readers);
> - flush_scheduled_work();
> - }
> + init_timer(&buf->timer);
> + buf->timer.data = (unsigned long)buf;
> + buf->timer.function = wakeup_readers;
I'd suggest to use setup_timer(&buf->timer, wakeup_readers, buf);
> @@ -609,9 +605,16 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
> buf->padding[old_subbuf];
> smp_mb();
> if (waitqueue_active(&buf->read_wait)) {
> - PREPARE_DELAYED_WORK(&buf->wake_readers,
> - wakeup_readers);
> - schedule_delayed_work(&buf->wake_readers, 1);
> + /*
> + * Calling wake_up_interruptible() from here
> + * will deadlock if we happen to be logging
> + * from the scheduler (trying to re-grab
> + * rq->lock), so defer it.
> + */
> + if (!timer_pending(&buf->timer)) {
> + buf->timer.expires = jiffies + 1;
> + add_timer(&buf->timer);
> + }
I think it is better to use __mod_timer(&buf->timer, jiffies + 1). In that
case this "if (!timer_pending(&buf->timer))" is not strictly needed, yes?
Imho, add_timer() is almost never should be used. The only valid usage is when
timer->expires was already set by somebody else.
Btw, thanks for your explanation about deferred wakeup.
Oleg.
next prev parent reply other threads:[~2007-05-06 12:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-06 4:46 [PATCH] relay: use plain timer instead of delayed work Tom Zanussi
2007-05-06 10:10 ` Satyam Sharma
2007-05-07 3:31 ` Tom Zanussi
2007-05-07 6:35 ` Satyam Sharma
2007-05-06 12:47 ` Oleg Nesterov [this message]
2007-05-07 3:29 ` Tom Zanussi
-- strict thread matches above, loose matches on Subject: below --
2007-05-07 3:35 Tom Zanussi
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=20070506124742.GA102@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zanussi@comcast.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