Skip to contentSkip to conversation

introduce lock_task_sighand() helper

PATCH New Oleg Nesterov 1 participant 1 message Feb 18, 2006 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 introduce lock_task_sighand() helper

This patch adds lock_task_sighand() helper and converts group_send_sig_info() to use it. Hopefully we will have more users soon.

This patch also removes '!sighand->count' and '!p->usage' checks, I think they both are bogus, racy and unneeded (but probably it makes sense to restore them as BUG_ON()s).

->sighand is cleared and it's ->count is decremented in release_task() with sighand->siglock held, so it is a bug to have '!p->usage || !->count' after we already locked and verified it is the same. On the other hand, an already dead task without ->sighand can have a non-zero ->usage due to ptrace, for example.

If we read the stale value of ->sighand we must see the change after spin_lock(), because that change was done while holding that same old ->sighand.siglock.

include/linux/sched.h renamed from include/linux/sched.h~2_LTS +9 -0
@@ -1217,6 +1217,15 @@ static inline void task_unlock(struct ta
 	spin_unlock(&p->alloc_lock);
 }
 
+extern struct sighand_struct *lock_task_sighand(struct task_struct *tsk,
+							unsigned long *flags);
+
+static inline void unlock_task_sighand(struct task_struct *tsk,
+						unsigned long *flags)
+{
+	spin_unlock_irqrestore(&tsk->sighand->siglock, *flags);
+}
+
 #ifndef __HAVE_THREAD_FUNCTIONS
 
 #define task_thread_info(task) (task)->thread_info
kernel/signal.c renamed from kernel/signal.c~2_LTS +35 -25

66 lines not on this page · raw message