Messages in this thread Patch in this message | | | Date | Thu, 9 Feb 2012 20:45:19 +0400 | From | Anton Vorontsov <> | Subject | [PATCH] sched: Turn lock_task_sighand() into a static inline |
| |
It appears that sparse tool understands static inline functions for context balance checking, so let's turn the macros into an inline func.
This makes the code a little bit more robust.
Suggested-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org> ---
On Wed, Feb 08, 2012 at 04:27:50PM +0100, Oleg Nesterov wrote: > On 02/07, Anton Vorontsov wrote: > > > > On Mon, Feb 06, 2012 at 04:27:32PM -0500, KOSAKI Motohiro wrote: > > > > > > Some __cond_lock() caller are inline functions. Is this bad? > > > > No, that's great, actually. :-) Not obvious, but seems like > > sparse understands __cond_lock in inline functions, so I'd > > better use it. > > Hmm, great... > > may be you can update lock_task_sighand() too ? (in a separate > patch of course).
Sure thing. Here it goes...
include/linux/sched.h | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h index e82f721..22ae10e 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2394,12 +2394,15 @@ static inline void task_unlock(struct task_struct *p) 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 struct sighand_struct *lock_task_sighand(struct task_struct *tsk, + unsigned long *flags) +{ + struct sighand_struct *ret; + + ret = __lock_task_sighand(tsk, flags); + (void)__cond_lock(&tsk->sighand->siglock, ret); + return ret; +} static inline void unlock_task_sighand(struct task_struct *tsk, unsigned long *flags) -- 1.7.8.3
| |