Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Nov 2019 17:59:18 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r354404 - stable/11/sys/kern
Message-ID:  <201911061759.xA6HxISr085064@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Nov  6 17:59:18 2019
New Revision: 354404
URL: https://svnweb.freebsd.org/changeset/base/354404

Log:
  MFC r305368 (by markj): Micro-optimize sleepq_signal().
  
  Lift a comparison out of the loop that finds the highest-priority thread
  on the queue.

Modified:
  stable/11/sys/kern/subr_sleepqueue.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/subr_sleepqueue.c
==============================================================================
--- stable/11/sys/kern/subr_sleepqueue.c	Wed Nov  6 17:49:38 2019	(r354403)
+++ stable/11/sys/kern/subr_sleepqueue.c	Wed Nov  6 17:59:18 2019	(r354404)
@@ -909,9 +909,9 @@ sleepq_signal(void *wchan, int flags, int pri, int que
 	 * been sleeping the longest since threads are always added to
 	 * the tail of sleep queues.
 	 */
-	besttd = NULL;
+	besttd = TAILQ_FIRST(&sq->sq_blocked[queue]);
 	TAILQ_FOREACH(td, &sq->sq_blocked[queue], td_slpq) {
-		if (besttd == NULL || td->td_priority < besttd->td_priority)
+		if (td->td_priority < besttd->td_priority)
 			besttd = td;
 	}
 	MPASS(besttd != NULL);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911061759.xA6HxISr085064>