From: Roland Dreier <rdreier@cisco.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Is adding requeue_delayed_work() a good idea
Date: Mon, 24 Aug 2009 14:11:00 -0700 [thread overview]
Message-ID: <ada4orwvrx7.fsf@cisco.com> (raw)
In-Reply-To: <20090824180112.GC16202@redhat.com> (Oleg Nesterov's message of "Mon, 24 Aug 2009 20:01:12 +0200")
> > In my particular case it doesn't really matter. In the queued case it
> > could leave it to run whenever it gets to the head of the workqueue. In
> > the already running case then I think the timer should be reset. The
> > main point is that if I do requeue_delayed_work() I want to make sure
> > the work runs all the way through from the beginning at some point in
> > the future. The pattern I have in mind is something like:
> >
> > spin_lock_irqsave(&mydata_lock);
> > new_timeout = add_item_to_timeout_list();
> > requeue_delayed_work(wq, &process_timeout_list_work, new_timeout);
> > spin_unlock_irqsave(&mydata_lock);
> >
> > so if the process_timeout_list_work runs early or twice it doesn't
> > matter; I just want to make sure that the work runs from the beginning
> > and sees the new item I added to the list at some point after the
> > requeue.
>
> Hmm. But, asuming that process_timeout_list_work->func() takes mydata_lock
> too, you can just use queue_delayed_work() ?
>
> process_timeout_list_work can't miss new items, queue_delayed_work()
> can only fail if dwork is pending and its ->func has not started yet.
Maybe I misunderstand the code or misunderstand you, but looking at it:
int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
struct delayed_work *dwork, unsigned long delay)
{
int ret = 0;
struct timer_list *timer = &dwork->timer;
struct work_struct *work = &dwork->work;
if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) {
BUG_ON(timer_pending(timer));
BUG_ON(!list_empty(&work->entry));
//...
}
return ret;
}
if I have dwork already queued and try to requeue it for earlier it
seems that this will just silently return with the later expiration
still in effect.
Maybe I wasn't totally clear on what I want to happen; an example would
be if, say, I have delayed work queued with timer set to expire in 100
seconds and then a new piece of work is added that needs to expire in 1
second. So I want to requeue delayed work to run in 1 second, not wait
the 100 seconds for the original timeout work.
> I think we need requeue_xxx helper(s), but the exact semantics is not
> clear to me.
Not clear to me either unfortunately.
- R.
next prev parent reply other threads:[~2009-08-24 21:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 21:51 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 [this message]
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 ` [PATCH 1/1] " Oleg Nesterov
2009-09-01 16:09 ` 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=ada4orwvrx7.fsf@cisco.com \
--to=rdreier@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
/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
Powered by JetHome