From: Oleg Nesterov <oleg@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Jann Horn <jannh@google.com>
Subject: Re: [PATCH] task_work: only grab task signal lock when needed
Date: Thu, 13 Aug 2020 13:48:05 +0200 [thread overview]
Message-ID: <20200813114804.GA30049@redhat.com> (raw)
In-Reply-To: <7c0eca6b-a9aa-4228-6abf-2eb4372f8fa7@kernel.dk>
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;
> > + smp_store_mb(current->jobctl, current->jobctl & ~JOBCTL_TASK_WORK);
> > if (unlikely(current->task_works)) {
> > spin_unlock_irq(&sighand->siglock);
> > task_work_run();
> >
>
> I think this should work when paired with the READ_ONCE() on the
> task_work_add() side.
It pairs with mb (implied by cmpxchg) before READ_ONCE. So we roughly have
task_work_add: get_signal:
STORE(task->task_works, new_work); STORE(task->jobctl);
mb(); mb();
LOAD(task->jobctl); LOAD(task->task_works);
and we can rely on STORE-MB-LOAD.
> I haven't managed to reproduce badness with the
> existing one that doesn't have the smp_store_mb() here, so can't verify
> much beyond that...
Yes, the race is very unlikely. And the problem is minor, the target task
can miss the new work added by TWA_SIGNAL and return from get_signal() without
TIF_SIGPENDING.
> Are you going to send this out as a complete patch?
Jens, could you please send the patch? I am on vacation and travelling.
Feel free to add my ACK.
Oleg.
next prev parent reply other threads:[~2020-08-13 11:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-11 14:25 [PATCH] task_work: only grab task signal lock when needed Jens Axboe
2020-08-11 15:23 ` Oleg Nesterov
2020-08-11 16:45 ` Jens Axboe
2020-08-12 14:54 ` Oleg Nesterov
2020-08-12 20:06 ` Peter Zijlstra
2020-08-12 23:13 ` Jens Axboe
2020-08-13 11:48 ` Oleg Nesterov [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-08-13 15:07 Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200813114804.GA30049@redhat.com \
--to=oleg@redhat.com \
--cc=axboe@kernel.dk \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.