Date: Mon, 5 Sep 2016 11:09:17 -0700 From: Mark Johnston <markj@freebsd.org> To: John Baldwin <jhb@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r305368 - head/sys/kern Message-ID: <20160905180917.GC70066@wkstn-mjohnston.west.isilon.com> In-Reply-To: <2134943.hUK9aHv09Y@ralph.baldwin.cx> References: <201609040029.u840Tn5D019584@repo.freebsd.org> <2134943.hUK9aHv09Y@ralph.baldwin.cx>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Sep 05, 2016 at 10:30:24AM -0700, John Baldwin wrote: > On Sunday, September 04, 2016 12:29:49 AM Mark Johnston wrote: > > Author: markj > > Date: Sun Sep 4 00:29:48 2016 > > New Revision: 305368 > > URL: https://svnweb.freebsd.org/changeset/base/305368 > > > > Log: > > Micro-optimize sleepq_signal(). > > > > Lift a comparison out of the loop that finds the highest-priority thread > > on the queue. > > > > MFC after: 1 week > > Could this safely use TAILQ_FOREACH_FROM? Are you suggesting something like this? besttd = TAILQ_FIRST(&sq->sq_blocked[queue]); td = TAILQ_NEXT(besttd, td_slpq); TAILQ_FOREACH_FROM(td, &sq->sq_blocked[queue], td_slpq) { ... I think that would work, and it avoids visiting the first element unnecessarily when the queue contains more than one element. If the queue contains one element, we'd visit it because of TAILQ_FOREACH_FROM's surprising behaviour of iterating over the entire queue when the listelem is NULL.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160905180917.GC70066>