From: Oleg Nesterov <oleg@tv-sign.ru>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/9] timer locking optimization
Date: Tue, 29 Nov 2005 15:57:59 +0300 [thread overview]
Message-ID: <438C5057.A54AFA83@tv-sign.ru> (raw)
Roman Zippel wrote:
>
> + base = timer->base;
> + spin_lock_irqsave(&base->lock, *flags);
> + while (unlikely(base != timer->base)) {
> + /* The timer has migrated to another CPU */
> + spin_unlock(&base->lock);
> cpu_relax();
> + base = timer->base;
> + spin_lock(&base->lock);
This spins with interrupts disabled, not good, imho.
> int __mod_timer(struct timer_list *timer, unsigned long expires)
> @@ -212,6 +207,7 @@ int __mod_timer(struct timer_list *timer
>
> base = lock_timer_base(timer, &flags);
>
> +restart:
> if (timer_pending(timer)) {
> detach_timer(timer, 0);
> ret = 1;
> @@ -231,11 +227,16 @@ int __mod_timer(struct timer_list *timer
> /* The timer remains on a former base */
> new_base = container_of(base, tvec_base_t, t_base);
> } else {
> - /* See the comment in lock_timer_base() */
> - timer->base = NULL;
> + /*
> + * We shortly release the timer and the timer can
> + * migrate to another cpu, so recheck the base after
> + * getting the lock.
> + */
> + timer->base = &new_base->t_base;
> spin_unlock(&base->lock);
> spin_lock(&new_base->t_base.lock);
> - timer->base = &new_base->t_base;
> + if (unlikely(timer->base != &new_base->t_base))
> + goto restart;
This is not right.
This way you can delete the timer (ret == 1), notice that timer's base
was changed after re-locking, goto restart, and get ret == 0.
Also, you have wrong value of 'base' after 'goto restart'.
Oleg.
next reply other threads:[~2005-11-29 11:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-29 12:57 Oleg Nesterov [this message]
2005-11-29 12:17 ` Roman Zippel
2005-11-30 2:32 ` Roman Zippel
2005-11-30 9:59 ` Oleg Nesterov
2005-11-30 15:07 ` Roman Zippel
2005-11-30 18:17 ` Oleg Nesterov
2005-11-30 11:23 ` Oleg Nesterov
2005-11-30 11:06 ` Roman Zippel
-- strict thread matches above, loose matches on Subject: below --
2005-11-29 1:34 Roman Zippel
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=438C5057.A54AFA83@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=zippel@linux-m68k.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
all inboxes | Powered by JetHome®