Page MenuHomeFreeBSD

Make umtxq_check_susp() to correctly handle thread exit requests.
ClosedPublic

Authored by kib on Jul 31 2019, 7:34 PM.

Details

Summary

The check for P_SINGLE_EXIT was shadowed by the P_SHOULDSTOP || traced check.

Reported by: bdrewery

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kib created this revision.Jul 31 2019, 7:34 PM
markj accepted this revision.Jul 31 2019, 7:36 PM
This revision is now accepted and ready to land.Jul 31 2019, 7:36 PM
kib added a subscriber: bdrewery.Jul 31 2019, 7:40 PM

This doesn't seem to fix the SIGKILL issue.

~ # procstat -kk 19680
  PID    TID COMM                TDNAME              KSTACK
19680 101200 python2.7           -                   __mtx_lock_sleep+0x118 __mtx_lock_flags+0x102 _sleep+0x334 umtxq_busy+0xb7 do_sem_wait+0x150 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
19680 101634 python2.7           -                   mi_switch+0x174 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x41c __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
19680 101635 python2.7           -                   _mtx_lock_spin_cookie+0x231 __mtx_lock_spin_flags+0xf8 wakeup_one+0xf do_sem_wait+0x26f __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
~ # kill -9 19680
~ # procstat -kk 19680
  PID    TID COMM                TDNAME              KSTACK
19680 101200 python2.7           -                   __mtx_lock_flags+0xc1 do_sem_wait+0x218 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
19680 101634 python2.7           -                   mi_switch+0x174 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x41c __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
19680 101635 python2.7           -                   __mtx_lock_sleep+0x118 __mtx_lock_flags+0x102 do_sem_wait+0x148 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
~ # procstat -i 19680|grep -v -- ---|grep KILL
19680 python2.7        KILL     P--


/usr/src # svn diff sys/kern/kern_umtx.c
Index: sys/kern/kern_umtx.c
===================================================================
--- sys/kern/kern_umtx.c        (revision 350358)
+++ sys/kern/kern_umtx.c        (working copy)
@@ -723,13 +723,11 @@ umtxq_check_susp(struct thread *td, bool sleep)
        error = 0;
        p = td->td_proc;
        PROC_LOCK(p);
-       if (P_SHOULDSTOP(p) ||
-           ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_SUSPEND))) {
-               if (p->p_flag & P_SINGLE_EXIT)
-                       error = EINTR;
-               else
-                       error = sleep ? thread_suspend_check(0) : ERESTART;
-       }
+       if (p->p_flag & P_SINGLE_EXIT)
+               error = EINTR;
+       else if (P_SHOULDSTOP(p) ||
+           ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_SUSPEND)))
+               error = sleep ? thread_suspend_check(0) : ERESTART;
        PROC_UNLOCK(p);
        return (error);
 }
/usr/src # sysctl kern.bootfile
kern.bootfile: /boot/testkernel/kernel
This revision was automatically updated to reflect the committed changes.