[PATCH] task_work: only grab task signal lock when needed

2020-08-13 Thread Jens Axboe
If JOBCTL_TASK_WORK is already set on the targeted task, then we need not go through {lock,unlock}_task_sighand() to set it again and queue a signal wakeup. This is safe as we're checking it _after_ adding the new task_work with cmpxchg(). The ordering is as follows: task_work_add()

Re: [PATCH] task_work: only grab task signal lock when needed

2020-08-13 Thread Oleg Nesterov
On 08/12, Jens Axboe wrote: > > On 8/12/20 8:54 AM, Oleg Nesterov wrote: > > > > --- x/kernel/signal.c > > +++ x/kernel/signal.c > > @@ -2541,7 +2541,7 @@ bool get_signal(struct ksignal *ksig) > > > > relock: > > spin_lock_irq(&sighand->siglock); > > - current->jobctl &= ~JOBCTL_TASK_WORK; >

Re: [PATCH] task_work: only grab task signal lock when needed

2020-08-12 Thread Jens Axboe
On 8/12/20 8:54 AM, Oleg Nesterov wrote: > On 08/11, Oleg Nesterov wrote: >> >> On 08/11, Jens Axboe wrote: >>> >>> --- a/kernel/task_work.c >>> +++ b/kernel/task_work.c >>> @@ -42,7 +42,8 @@ task_work_add(struct task_struct *task, struct >>> callback_head *work, int notify) >>> set_no

Re: [PATCH] task_work: only grab task signal lock when needed

2020-08-12 Thread Peter Zijlstra
On Wed, Aug 12, 2020 at 04:54:23PM +0200, Oleg Nesterov wrote: > I see nothing better than the additional change below. Peter, do you see > another solution? Nope -- although I don't claim to understand the signal code much. > This needs a comment to explain that this mb() pairs with another bar

Re: [PATCH] task_work: only grab task signal lock when needed

2020-08-12 Thread Oleg Nesterov
On 08/11, Oleg Nesterov wrote: > > On 08/11, Jens Axboe wrote: > > > > --- a/kernel/task_work.c > > +++ b/kernel/task_work.c > > @@ -42,7 +42,8 @@ task_work_add(struct task_struct *task, struct > > callback_head *work, int notify) > > set_notify_resume(task); > > break; > >

Re: [PATCH] task_work: only grab task signal lock when needed

2020-08-11 Thread Jens Axboe
On 8/11/20 9:23 AM, Oleg Nesterov wrote: > On 08/11, Jens Axboe wrote: >> >> --- a/kernel/task_work.c >> +++ b/kernel/task_work.c >> @@ -42,7 +42,8 @@ task_work_add(struct task_struct *task, struct >> callback_head *work, int notify) >> set_notify_resume(task); >> break;

Re: [PATCH] task_work: only grab task signal lock when needed

2020-08-11 Thread Oleg Nesterov
On 08/11, Jens Axboe wrote: > > --- a/kernel/task_work.c > +++ b/kernel/task_work.c > @@ -42,7 +42,8 @@ task_work_add(struct task_struct *task, struct > callback_head *work, int notify) > set_notify_resume(task); > break; > case TWA_SIGNAL: > - if (loc

[PATCH] task_work: only grab task signal lock when needed

2020-08-11 Thread Jens Axboe
If JOBCTL_TASK_WORK is already set on the targeted task, then we need not go through {lock,unlock}_task_sighand() to set it again and queue a signal wakeup. This is safe as we're checking it _after adding the new task_work with cmpxchg(). Signed-off-by: Jens Axboe --- Tested this with an intens