[RFC][PATCH 1/5] signal: Document signal locking rules

From: Matt Fleming
Date: Fri Sep 30 2011 - 11:13:09 EST


From: Matt Fleming <matt.fleming@xxxxxxxxx>

The current locking rules for signal handling and job control are
complex and pretty much undocumented. Fix that by explaining which
data structures are involved. At the moment, all the necessary locking
is covered by the per-process sighand->siglock but patches later in
the series will change that.

Cc: Tejun Heo <tj@xxxxxxxxxx>
Cc: Oleg Nesterov <oleg@xxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Anirudh Badam <abadam@xxxxxxxxxxxxxxxx>
Signed-off-by: Matt Fleming <matt.fleming@xxxxxxxxx>
---
kernel/signal.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 3868e66..54fc552 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -38,6 +38,33 @@
#include "audit.h" /* audit_signal_info() */

/*
+ * signal locking rules:
+ *
+ * - sighand->siglock (spinlock) protects,
+ *
+ * * the tsk->sighand pointer from being modified, see de_thread() and
+ * __exit_signal(). If you need to dereference tsk->sighand (for
+ * example when locking ->siglock) and tsk is not current, you must
+ * call lock_task_sighand().
+ *
+ * * most things under tsk->signal
+ *
+ * * tsk->sighand->action[]
+ *
+ * * tsk->last_siginfo
+ * * tsk->group_stop
+ * * tsk->pending
+ * * tsk->jobctl
+ *
+ * * the atomic operation of checking tsk->jobctl, tsk->pending and
+ * tsk->signal->shared_pending and setting/clearing TIF_SIGPENDING,
+ * see recalc_sigpending().
+ *
+ * * tsk->cpu_timers
+ *
+ */
+
+/*
* SLAB caches for signal bits.
*/

--
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/