Author: markj
Date: Mon Feb  3 22:49:05 2020
New Revision: 357473
URL: https://svnweb.freebsd.org/changeset/base/357473

Log:
  Fix the !SMP case in sched_add() after r355779.
  
  If the thread's lock is already that of the runqueue, don't recurse on
  the queue lock.
  
  Reviewed by:  jeff, kib
  Sponsored by: The FreeBSD Foundation
  Differential Revision:        https://reviews.freebsd.org/D23492

Modified:
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_ule.c
==============================================================================
--- head/sys/kern/sched_ule.c   Mon Feb  3 22:34:50 2020        (r357472)
+++ head/sys/kern/sched_ule.c   Mon Feb  3 22:49:05 2020        (r357473)
@@ -2605,15 +2605,17 @@ sched_add(struct thread *td, int flags)
                sched_setpreempt(td);
 #else
        tdq = TDQ_SELF();
-       TDQ_LOCK(tdq);
        /*
         * Now that the thread is moving to the run-queue, set the lock
         * to the scheduler's lock.
         */
-       if ((flags & SRQ_HOLD) != 0)
-               td->td_lock = TDQ_LOCKPTR(tdq);
-       else
-               thread_lock_set(td, TDQ_LOCKPTR(tdq));
+       if (td->td_lock != TDQ_LOCKPTR(tdq)) {
+               TDQ_LOCK(tdq);
+               if ((flags & SRQ_HOLD) != 0)
+                       td->td_lock = TDQ_LOCKPTR(tdq);
+               else
+                       thread_lock_set(td, TDQ_LOCKPTR(tdq));
+       }
        tdq_add(tdq, td, flags);
        if (!(flags & SRQ_YIELDING))
                sched_setpreempt(td);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to