Date: Mon, 3 Feb 2020 22:49:05 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357473 - head/sys/kern Message-ID: <202002032249.013Mn5E4093713@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002032249.013Mn5E4093713>