From: Oleg Nesterov <oleg@tv-sign.ru>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@osdl.org>, Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Re: [BUG] Race condition with it_real_fn in kernel/itimer.c
Date: Thu, 16 Jun 2005 11:44:22 +0400 [thread overview]
Message-ID: <42B12DD6.7028CBAE@tv-sign.ru> (raw)
In-Reply-To: 1118864043.4508.81.camel@localhost.localdomain
Steven Rostedt wrote:
>
> So, timer_pending tests if timer->base is NULL, but here we see that
> timer->base IS NULL before the function is called, and as I have said
> earlier, the it_real_arm can be called on two CPUS simultaneously. So
> here's another patch that should fix this race condition too.
>
> [...]
>
> + /*
> + * Call del_timer_sync unconditionally, since we don't
> + * know if it is running or not. We also need to unlock
> + * the siglock so that the it_real_fn called by ksoftirqd
> + * doesn't wait for us.
> + */
> + spin_unlock(&tsk->sighand->siglock);
> + del_timer_sync(&tsk->signal->real_timer);
> + spin_lock(&tsk->sighand->siglock);
I don't think this is 100% correct. After del_timer_sync() returns another
thread can come and call do_setitimer() and re-arm the timer (because with
your patch we are dropping tsk->sighand->siglock here). So this patch does
not garantees that the timer is not queued/running after del_timer_sync(),
and the it_real_arm can be called on two CPUS simultaneously again.
There is a try_to_del_timer_sync() in the -mm tree which is suitable here:
again:
spin_lock_irq(&tsk->sighand->siglock);
if (try_to_del_timer_sync(&tsk->signal->real_timer) < 0) {
spin_unlock_irq(&tsk->sighand->siglock);
goto again;
}
Oleg.
next prev parent reply other threads:[~2005-06-16 7:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-15 17:39 [BUG] Race condition with it_real_fn in kernel/itimer.c Oleg Nesterov
2005-06-15 18:37 ` Steven Rostedt
2005-06-15 19:34 ` [PATCH] " Steven Rostedt
2005-06-16 7:44 ` Oleg Nesterov [this message]
2005-06-16 11:33 ` Steven Rostedt
2005-06-16 11:44 ` Steven Rostedt
2005-06-16 14:30 ` [PATCH] Re: [BUG] Race condition with it_real_fn inkernel/itimer.c Oleg Nesterov
2005-06-16 9:03 ` [BUG] Race condition with it_real_fn in kernel/itimer.c Oleg Nesterov
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=42B12DD6.7028CBAE@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.