From owner-freebsd-current@freebsd.org Fri Jan 12 19:31:50 2018 Return-Path: Delivered-To: freebsd-current@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 7C5C0E77B90 for ; Fri, 12 Jan 2018 19:31:50 +0000 (UTC) (envelope-from eric@vangyzen.net) Received: from smtp.vangyzen.net (hotblack.vangyzen.net [199.48.133.146]) by mx1.freebsd.org (Postfix) with ESMTP id 67E1D7BAB9 for ; Fri, 12 Jan 2018 19:31:49 +0000 (UTC) (envelope-from eric@vangyzen.net) Received: from sweettea.beer.town (unknown [76.164.8.130]) by smtp.vangyzen.net (Postfix) with ESMTPSA id 52E865646F for ; Fri, 12 Jan 2018 13:31:43 -0600 (CST) From: Eric van Gyzen Subject: td_swvoltick To: FreeBSD Current Message-ID: <603d2786-86be-583c-9ff6-d8d73eddf77e@vangyzen.net> Date: Fri, 12 Jan 2018 13:31:41 -0600 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jan 2018 19:31:50 -0000 should_yield() compares thread::td_swvoltick to 'ticks' to determine whether a thread is hogging and should yield. Since td_swvoltick records 'ticks' /before/ the actual context switch, the calculation in should_yield() includes any time that the thread was switched out. It seems that should_yield() wants to know how long the thread has actually been running. Therefore, td_swvoltick should record 'ticks' /after/ sched_switch() returns. Does this make sense, or am I missing something? If this makes sense, I would probably keep the current assignment in mi_switch() and simply add a second assignment after the call to sched_switch(). That way, db_show_thread will still show useful data for sleeping threads. I would do the same for td_swinvolticks. I'll be happy to make the change myself. I just want a sanity check before I bother. Thanks in advance, Eric