On Wed, Sep 09, 2020 at 06:23:22PM +0200, Martin Pieuchot wrote:
> On 09/09/20(Wed) 10:02, Claudio Jeker wrote:
> > On Wed, Sep 09, 2020 at 08:33:30AM +0200, Martin Pieuchot wrote:
> > > Per-process data structures needed to suspend the execution of threads
> > > are since recently protected by the SCHED_LOCK().  So the KERNEL_LOCK()
> > > dance inside issignal() is no longer necessary and can be removed, ok?
> > 
> > This is not quite right. single_thread_set() still needs the
> > KERNEL_LOCK() to avoid racing against itself.
> 
> Which data structure still requires the KERNEL_LOCK()?  Are you talking
> about the per-process list of threads?
> 
> Isn't the SCHED_LOCK() enough to prevent racing against itself?

The main problem is a race for setting ps_single. It is possible that two
threads enter single_thread_set() both succeed on single_thread_check()
but now the first thread will get stomped over by the second thread.
The code is not quite right and it needs to be restructured to be safe.
It probably needs a similar setup finish dance like sleep.

-- 
:wq Claudio

Reply via email to