Date: Wed, 18 May 2016 03:50:21 +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: r300109 - head/sys/kern Message-ID: <201605180350.u4I3oLTI010004@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Wed May 18 03:50:21 2016 New Revision: 300109 URL: https://svnweb.freebsd.org/changeset/base/300109 Log: Micro-optimize sleepq_broadcast(). - Avoid a conditional branch on the return value of sleepq_resume_thread() by ORing its return value into the boolean wakeup_swapper. This is consistent with other sleepqueue functions which just pass this return value to their caller. - sleepq_resume_thread() unconditionally removes the thread from its queue, so there's no need to maintain a pointer to the next element in the queue. MFC after: 2 weeks Modified: head/sys/kern/subr_sleepqueue.c Modified: head/sys/kern/subr_sleepqueue.c ============================================================================== --- head/sys/kern/subr_sleepqueue.c Wed May 18 03:50:18 2016 (r300108) +++ head/sys/kern/subr_sleepqueue.c Wed May 18 03:50:21 2016 (r300109) @@ -865,7 +865,7 @@ int sleepq_broadcast(void *wchan, int flags, int pri, int queue) { struct sleepqueue *sq; - struct thread *td, *tdn; + struct thread *td; int wakeup_swapper; CTR2(KTR_PROC, "sleepq_broadcast(%p, %d)", wchan, flags); @@ -879,10 +879,9 @@ sleepq_broadcast(void *wchan, int flags, /* Resume all blocked threads on the sleep queue. */ wakeup_swapper = 0; - TAILQ_FOREACH_SAFE(td, &sq->sq_blocked[queue], td_slpq, tdn) { + while ((td = TAILQ_FIRST(&sq->sq_blocked[queue])) != NULL) { thread_lock(td); - if (sleepq_resume_thread(sq, td, pri)) - wakeup_swapper = 1; + wakeup_swapper |= sleepq_resume_thread(sq, td, pri); thread_unlock(td); } return (wakeup_swapper);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605180350.u4I3oLTI010004>