From owner-svn-src-all@freebsd.org Mon Sep 5 18:04:12 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2CBDAB96B2B; Mon, 5 Sep 2016 18:04:12 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pf0-x229.google.com (mail-pf0-x229.google.com [IPv6:2607:f8b0:400e:c00::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F0D96DF5; Mon, 5 Sep 2016 18:04:11 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-pf0-x229.google.com with SMTP id g202so43232303pfb.0; Mon, 05 Sep 2016 11:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MwCKYQ/c+m0UpwWX0E3qYgeZfra9PegBLQc87motGpo=; b=uMHTBp059fEaUJ3bTuJ/yhhVN1ABhDQra77P89t0GCOw3YklJQGW7fg0ylsBDY17B5 ltPgBB8GlsF+dUoHXbPDCN1LNBudk1ioGHNS+NoT0DJcNzz3BMK0QuvtBUW4wyogXs3K mC6vcBhjbkA+CWHXnO6Z8BVrNjggb9dMlnUXhVYUoqBRUeaZsP3TEX3wvW+RxkEKHYB1 70qRJcOIwmN2pITlgSrVZEXEYpt8wPJjT/9//ow27SImKoxi4cyqrrBTjkCT748zCspL Kj1eFh2oIiVcnRxmOjP6PSR5ZsjBvin/3HuTSqORKIoQXeezG3yI3hr93SuBg6lGDEn7 VaHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=MwCKYQ/c+m0UpwWX0E3qYgeZfra9PegBLQc87motGpo=; b=JHMfOkJK34snqK72d2D/a5SLmcXTAc93/K/suhPrZq91osHOuwjF67BfkSBqffKGEU l/BL/1YQfOtHwabMS4SJqedqyPlO4Gc9o/LnFlNllv/DCGzm1939rpM1Oq/LqF/q0zXM DSou1Yt9oAwHSHzZaffl7+ZwYPd7/2Oes+vfV4GZK9pf1wiWf84HxKV2N93YuoQy0yvJ O3bZ6bC4R55dm+aHi4Q46hDAU5VtJQlcathzzcnR8C8X3RnSIvz7cThox+ZGcocIAfpJ vAac1wxjx5sdgSzptPkg1HpgKrYOZZB3bY/IkbmSfhbzbn2cdTN8/tZ7pLH+XNknHghq /iIw== X-Gm-Message-State: AE9vXwMdq2mu3+n1ehRyu0N3YLSN/A8yeFb2mvKFtlYp2kitbRhjyXCA9rPiJFarw2rgaQ== X-Received: by 10.98.216.129 with SMTP id e123mr14282560pfg.123.1473098651455; Mon, 05 Sep 2016 11:04:11 -0700 (PDT) Received: from wkstn-mjohnston.west.isilon.com (c-76-104-201-218.hsd1.wa.comcast.net. [76.104.201.218]) by smtp.gmail.com with ESMTPSA id n80sm20613506pfi.25.2016.09.05.11.04.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Sep 2016 11:04:10 -0700 (PDT) Sender: Mark Johnston Date: Mon, 5 Sep 2016 11:09:17 -0700 From: Mark Johnston To: John Baldwin 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> References: <201609040029.u840Tn5D019584@repo.freebsd.org> <2134943.hUK9aHv09Y@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2134943.hUK9aHv09Y@ralph.baldwin.cx> User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Sep 2016 18:04:12 -0000 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.