Re: [PATCH] signal: annotate lock_task_sighand()

From: Namhyung Kim
Date: Sat Sep 25 2010 - 10:31:33 EST


Add missing Cc.


On Sat, Sep 25, 2010 at 23:04, Namhyung Kim <namhyung@xxxxxxxxx> wrote:
> 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.
>
> Suggested-by: Eric Dumazet <eric.dumazet@xxxxxxxxx>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxx>
Cc: Oleg Nesterov <oleg@xxxxxxxxxx>
Cc: Roland McGrath <roland@xxxxxxxxxx>

> ---
>  include/linux/sched.h |    9 ++++++++-
>  kernel/signal.c       |    3 ++-
>  2 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 1e2a6db..9937998 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -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)
>  {
> diff --git a/kernel/signal.c b/kernel/signal.c
> index bded651..e4e8cfe 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -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
>
>



--
Regards,
Namhyung Kim
--
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/