Skip to contentSkip to conversation

signal: annotate lock_task_sighand()

PATCH Namhyung Kim 1 participant 1 message Sep 25, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Add missing Cc.

Quoted 8 lines · Namhyung Kim

lock_task_sighand() grabs sighand->siglock in case of returning non-NULL but unlock_task_sighand() releases it unconditionally. This leads sparse to complain about the lock context imbalance. Rename and wrap lock_task_sighand() using __cond_lock() macro to make sparse happy.

Cc Oleg Nesterov <[email protected]>
Cc Roland McGrath <[email protected]>
Quoted 45 lines

---
 include/linux/sched.h |    9 ++++++++-
 kernel/signal.c       |    3 ++-

 2 files changed, 10 insertions(+), 2 deletions(-)
include/linux/sched.h +8 -1
index 1e2a6db..9937998 100644
@@ -2210,9 +2210,16 @@ static inline void task_unlock(struct task_struct *p)
        spin_unlock(&p->alloc_lock);
  }
 
-extern struct sighand_struct *lock_task_sighand(struct task_struct *tsk,
+extern struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
                                                        unsigned long *flags);
 
+#define lock_task_sighand(tsk, flags)                                  \
+({     struct sighand_struct *__ss;                                    \
+       __cond_lock(&(tsk)->sighand->siglock,                           \
+                   (__ss = __lock_task_sighand(tsk, flags)));          \
+       __ss;                                                           \
+})                                                                     \
+
  static inline void unlock_task_sighand(struct task_struct *tsk,
                                                unsigned long *flags)
  {
kernel/signal.c +2 -2
index bded651..e4e8cfe 100644
@@ -1105,7 +1105,8 @@ int zap_other_threads(struct task_struct *p)
        return count;
  }
 
-struct sighand_struct *lock_task_sighand(struct task_struct *tsk, unsigned long *flags)
+struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
+                                          unsigned long *flags)
  {
        struct sighand_struct *sighand;
 
--

1.7.2.2

Signature · 2 lines
Regards,
Namhyung Kim