Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Jul 2013 09:01:45 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r253077 - head/sys/kern
Message-ID:  <201307090901.r6991j64023941@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Tue Jul  9 09:01:44 2013
New Revision: 253077
URL: http://svnweb.freebsd.org/changeset/base/253077

Log:
  should_yield: protect from td_swvoltick being uninitialized or too stale
  
  The distance between ticks and td_swvoltick should be calculated as
  an unsigned number.  Previously we could end up comparing a negative
  number with hogticks in which case should_yield() would give incorrect
  answer.
  
  We should probably ensure that td_swvoltick is properly initialized.
  
  Sponsored by:	HybridCluster
  MFC after:	5 days

Modified:
  head/sys/kern/kern_synch.c

Modified: head/sys/kern/kern_synch.c
==============================================================================
--- head/sys/kern/kern_synch.c	Tue Jul  9 08:59:39 2013	(r253076)
+++ head/sys/kern/kern_synch.c	Tue Jul  9 09:01:44 2013	(r253077)
@@ -581,7 +581,7 @@ int
 should_yield(void)
 {
 
-	return (ticks - curthread->td_swvoltick >= hogticks);
+	return ((unsigned int)(ticks - curthread->td_swvoltick) >= hogticks);
 }
 
 void



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