git: 6df1359e5542 - main - sleepqueue(9): Remove sbinuptime() from sleepq_timeout().

Alexander Motin mav at FreeBSD.org
Sun Oct 3 01:08:46 UTC 2021


The branch main has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=6df1359e5542f69179c142be1ea099d447e273d1

commit 6df1359e5542f69179c142be1ea099d447e273d1
Author:     Alexander Motin <mav at FreeBSD.org>
AuthorDate: 2021-10-03 00:57:55 +0000
Commit:     Alexander Motin <mav at FreeBSD.org>
CommitDate: 2021-10-03 01:08:41 +0000

    sleepqueue(9): Remove sbinuptime() from sleepq_timeout().
    
    Callout c_time is always bigger or equal than the scheduled time.  It
    is also smaller than sbinuptime() and can't change while the callback
    is running.  So we reliably can use it instead of sbinuptime() here.
    In case there was a race and the callout was rescheduled to the later
    time, the callback will be called again.
    
    According to profiles it saves ~5% of the timer interrupt time even
    with fast TSC timecounter.
    
    MFC after:      1 month
---
 sys/kern/subr_sleepqueue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/kern/subr_sleepqueue.c b/sys/kern/subr_sleepqueue.c
index b146a978a60c..61efb1b9f377 100644
--- a/sys/kern/subr_sleepqueue.c
+++ b/sys/kern/subr_sleepqueue.c
@@ -1040,7 +1040,8 @@ sleepq_timeout(void *arg)
 	    (void *)td, (long)td->td_proc->p_pid, (void *)td->td_name);
 
 	thread_lock(td);
-	if (td->td_sleeptimo == 0 || td->td_sleeptimo > sbinuptime()) {
+	if (td->td_sleeptimo == 0 ||
+	    td->td_sleeptimo > td->td_slpcallout.c_time) {
 		/*
 		 * The thread does not want a timeout (yet).
 		 */


More information about the dev-commits-src-all mailing list