From: Thomas Gleixner <tglx@linutronix.de>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Ingo Molnar <mingo@elte.hu>, Roland McGrath <roland@redhat.com>,
George Anzinger <george@mvista.com>,
linux-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
"Paul E. McKenney" <paulmck@us.ibm.com>
Subject: Re: [PATCH 2.6.13-rc6-rt9] PI aware dynamic priority adjustment
Date: Sat, 20 Aug 2005 18:04:08 +0200 [thread overview]
Message-ID: <1124553848.23647.635.camel@tglx.tec.linutronix.de> (raw)
In-Reply-To: <430739D4.681DB651@tv-sign.ru>
On Sat, 2005-08-20 at 18:10 +0400, Oleg Nesterov wrote:
> posix_timer_event() first checks that the thread (SIGEV_THREAD_ID
> case) does not have PF_EXITING flag, then it calls send_sigqueue()
> which locks task list. But if the thread exits in between the kernel
> will oops.
> posix_timer_event() runs under k_itimer.it_lock, but this does not
> help if that thread was not the only one in thread group, in this
> case we don't call exit_itimers().
I added exit_notify_itimers() for that case. It is synchronized vs.
posix_timer_event() via the timer lock and therefor protects against the
race described above.
It solves the problem for the only user of send_sigqueue for now, but I
think we should have a more general interface to such functionality to
allow simple usage.
tglx
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff -uprN --exclude-from=/usr/local/bin/diffit.exclude linux-2.6.13-rc6/include/linux/sched.h linux-2.6.13-rc6.work/include/linux/sched.h
--- linux-2.6.13-rc6/include/linux/sched.h 2005-08-13 12:25:56.000000000 +0200
+++ linux-2.6.13-rc6.work/include/linux/sched.h 2005-08-20 17:43:36.000000000 +0200
@@ -1051,6 +1051,7 @@ extern void __exit_signal(struct task_st
extern void exit_sighand(struct task_struct *);
extern void __exit_sighand(struct task_struct *);
extern void exit_itimers(struct signal_struct *);
+extern void exit_notify_itimers(struct signal_struct *);
extern NORET_TYPE void do_group_exit(int);
diff -uprN --exclude-from=/usr/local/bin/diffit.exclude linux-2.6.13-rc6/kernel/posix-timers.c linux-2.6.13-rc6.work/kernel/posix-timers.c
--- linux-2.6.13-rc6/kernel/posix-timers.c 2005-08-13 12:25:58.000000000 +0200
+++ linux-2.6.13-rc6.work/kernel/posix-timers.c 2005-08-20 17:43:36.000000000 +0200
@@ -1169,6 +1169,33 @@ void exit_itimers(struct signal_struct *
}
/*
+ * This is called by __exit_signal, when there are still references to
+ * the shared signal_struct
+ */
+void exit_notify_itimers(struct signal_struct *sig)
+{
+ struct k_itimer *timer;
+ struct list_head *tmp;
+ unsigned long flags;
+
+ list_for_each(tmp, &sig->posix_timers) {
+
+ timer = list_entry(tmp, struct k_itimer, list);
+
+ /* Protect against posix_timer_fn */
+ spin_lock_irqsave(&timer->it_lock, flags);
+ if (timer->it_process == current) {
+
+ if (timer->it_sigev_notify == (SIGEV_SIGNAL|SIGEV_THREAD_ID))
+ timer->it_sigev_notify = SIGEV_SIGNAL;
+
+ timer->it_process = timer->it_process->group_leader;
+ }
+ spin_lock_irqrestore(&timer->it_lock, flags);
+ }
+}
+
+/*
* And now for the "clock" calls
*
* These functions are called both from timer functions (with the timer
diff -uprN --exclude-from=/usr/local/bin/diffit.exclude linux-2.6.13-rc6/kernel/signal.c linux-2.6.13-rc6.work/kernel/signal.c
--- linux-2.6.13-rc6/kernel/signal.c 2005-08-13 12:25:58.000000000 +0200
+++ linux-2.6.13-rc6.work/kernel/signal.c 2005-08-20 17:57:46.000000000 +0200
@@ -390,6 +390,7 @@ void __exit_signal(struct task_struct *t
sig->nvcsw += tsk->nvcsw;
sig->nivcsw += tsk->nivcsw;
sig->sched_time += tsk->sched_time;
+ exit_notify_itimers(sig);
spin_unlock(&sighand->siglock);
sig = NULL; /* Marker for below. */
}
@@ -1381,13 +1382,12 @@ send_sigqueue(int sig, struct sigqueue *
int ret = 0;
/*
- * We need the tasklist lock even for the specific
- * thread case (when we don't need to follow the group
- * lists) in order to avoid races with "p->sighand"
- * going away or changing from under us.
+ * No need to hold tasklist lock here.
+ * posix_timer_event() is synchronized via
+ * exit_itimers() and exit_notify_itimers() to
+ * be protected against p->sighand == NULL
*/
BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
- read_lock(&tasklist_lock);
spin_lock_irqsave(&p->sighand->siglock, flags);
if (unlikely(!list_empty(&q->list))) {
@@ -1414,7 +1414,6 @@ send_sigqueue(int sig, struct sigqueue *
out:
spin_unlock_irqrestore(&p->sighand->siglock, flags);
- read_unlock(&tasklist_lock);
return(ret);
}
next prev parent reply other threads:[~2005-08-20 16:04 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-18 6:01 2.6.13-rc6-rt9 Ingo Molnar
2005-08-18 15:24 ` 2.6.13-rc6-rt9 Thomas Gleixner
2005-08-18 16:08 ` 2.6.13-rc6-rt9 Thomas Gleixner
2005-08-18 21:17 ` 2.6.13-rc6-rt9 Thomas Gleixner
2005-08-18 22:54 ` [2.6.13-rc6-rt9 patch] fix DECNET_ROUTER=y compile Adrian Bunk
2005-08-22 7:59 ` Ingo Molnar
2005-08-18 22:54 ` 2.6.13-rc6-rt9: compile errors Adrian Bunk
2005-08-22 8:44 ` Ingo Molnar
2005-08-19 0:05 ` 2.6.13-rc6-rt9 Chuck Harding
2005-08-19 6:39 ` 2.6.13-rc6-rt9 Steven Rostedt
2005-08-19 13:00 ` 2.6.13-rc6-rt9 Steven Rostedt
2005-08-19 15:36 ` 2.6.13-rc6-rt9 Steven Rostedt
2005-08-22 7:57 ` 2.6.13-rc6-rt9 Ingo Molnar
2005-08-22 7:58 ` 2.6.13-rc6-rt9 Ingo Molnar
2005-08-23 12:36 ` 2.6.13-rc6-rt9 Ingo Molnar
2005-08-23 12:50 ` 2.6.13-rc6-rt9 Steven Rostedt
2005-08-23 12:56 ` 2.6.13-rc6-rt9 Ingo Molnar
2005-08-19 16:56 ` 2.6.13-rc6-rt9 Peter Zijlstra
2005-08-19 18:30 ` 2.6.13-rc6-rt9 Peter Zijlstra
2005-08-19 18:43 ` 2.6.13-rc6-rt9 Paul E. McKenney
2005-08-20 19:27 ` 2.6.13-rc6-rt9 Peter Zijlstra
2005-08-20 21:24 ` 2.6.13-rc6-rt9 Jeff Dike
2005-09-29 7:54 ` 2.6.13-rc6-rt9 Peter Zijlstra
2005-09-30 1:00 ` 2.6.13-rc6-rt9 Paul E. McKenney
2005-09-30 1:07 ` 2.6.13-rc6-rt9 Thomas Gleixner
2005-09-30 1:46 ` 2.6.13-rc6-rt9 Paul E. McKenney
2005-09-30 6:17 ` 2.6.13-rc6-rt9 Thomas Gleixner
2005-08-19 21:50 ` 2.6.13-rc6-rt9 Darren Hart
2005-08-25 6:24 ` 2.6.13-rc6-rt9 Ingo Molnar
2005-08-19 22:13 ` 2.6.13-rc6-rt9 Darren Hart
2005-08-19 23:00 ` 2.6.13-rc6-rt9 Thomas Gleixner
2005-08-20 15:13 ` 2.6.13-rc6-rt9 Darren Hart
2005-08-19 23:48 ` [PATCH 2.6.13-rc6-rt9] PI aware dynamic priority adjustment Thomas Gleixner
2005-08-20 0:19 ` George Anzinger
2005-08-20 0:36 ` Thomas Gleixner
2005-08-20 1:36 ` George Anzinger
2005-09-26 21:03 ` Roland McGrath
2005-08-20 14:10 ` Oleg Nesterov
2005-08-20 16:04 ` Thomas Gleixner [this message]
2005-08-20 17:50 ` Oleg Nesterov
2005-08-22 21:37 ` George Anzinger
2005-08-20 16:58 ` [PATCH] fix send_sigqueue() vs thread exit race Oleg Nesterov
2005-08-21 9:44 ` Thomas Gleixner
2005-08-21 10:41 ` Oleg Nesterov
2005-08-21 12:38 ` Thomas Gleixner
2005-08-21 10:59 ` Oleg Nesterov
2005-08-21 21:24 ` Thomas Gleixner
2005-08-21 21:50 ` Thomas Gleixner
2005-08-22 6:39 ` Oleg Nesterov
2005-08-22 8:08 ` Thomas Gleixner
2005-08-22 8:52 ` Oleg Nesterov
2005-08-22 10:06 ` Thomas Gleixner
2005-08-22 16:45 ` Oleg Nesterov
2005-08-23 10:13 ` Thomas Gleixner
2005-08-23 16:17 ` Oleg Nesterov
2005-08-23 18:29 ` Thomas Gleixner
2005-09-24 13:42 ` [PATCH] fix exit_itimers() vs posix_timer_event() AB-BA deadlock Oleg Nesterov
2005-09-25 5:44 ` Andrew Morton
2005-09-25 14:07 ` [PATCH] fix exit_itimers() vs posix_timer_event() AB-BAdeadlock Oleg Nesterov
2005-10-23 16:50 ` Oleg Nesterov
2005-08-23 10:42 ` [PATCH] fix send_sigqueue() vs thread exit race Thomas Gleixner
2005-08-22 7:38 ` [PATCH 2.6.13-rc6-rt9] PI aware dynamic priority adjustment Ingo Molnar
2005-08-22 7:41 ` Ingo Molnar
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=1124553848.23647.635.camel@tglx.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=george@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=paulmck@us.ibm.com \
--cc=roland@redhat.com \
--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 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®