Page MenuHomeFreeBSD

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

Authored by kib on Jul 31 2019, 7:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 11 2024, 11:11 AM
Unknown Object (File)
Oct 10 2024, 5:28 PM
Unknown Object (File)
Oct 5 2024, 12:02 AM
Unknown Object (File)
Sep 24 2024, 9:10 AM
Unknown Object (File)
Sep 24 2024, 4:16 AM
Unknown Object (File)
Sep 23 2024, 10:16 PM
Unknown Object (File)
Sep 23 2024, 12:49 AM
Unknown Object (File)
Sep 9 2024, 8:08 PM
Subscribers

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 - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 25620

Event Timeline

This revision is now accepted and ready to land.Jul 31 2019, 7:36 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