Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jul 2010 19:01:08 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r210073 - stable/7/sys/kern
Message-ID:  <201007141901.o6EJ18m2052469@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Jul 14 19:01:08 2010
New Revision: 210073
URL: http://svn.freebsd.org/changeset/base/210073

Log:
  MFC 208787:
  Assert that the thread lock is held in sched_pctcpu() instead of
  recursively acquiring it.  All of the current callers already hold the
  lock.

Modified:
  stable/7/sys/kern/sched_4bsd.c
  stable/7/sys/kern/sched_ule.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/kern/sched_4bsd.c
==============================================================================
--- stable/7/sys/kern/sched_4bsd.c	Wed Jul 14 19:00:44 2010	(r210072)
+++ stable/7/sys/kern/sched_4bsd.c	Wed Jul 14 19:01:08 2010	(r210073)
@@ -1407,6 +1407,7 @@ sched_pctcpu(struct thread *td)
 {
 	struct td_sched *ts;
 
+	THREAD_LOCK_ASSERT(td, MA_OWNED);
 	ts = td->td_sched;
 	return (ts->ts_pctcpu);
 }

Modified: stable/7/sys/kern/sched_ule.c
==============================================================================
--- stable/7/sys/kern/sched_ule.c	Wed Jul 14 19:00:44 2010	(r210072)
+++ stable/7/sys/kern/sched_ule.c	Wed Jul 14 19:01:08 2010	(r210073)
@@ -2514,7 +2514,7 @@ sched_pctcpu(struct thread *td)
 	if (ts == NULL)
 		return (0);
 
-	thread_lock(td);
+	THREAD_LOCK_ASSERT(td, MA_OWNED);
 	if (ts->ts_ticks) {
 		int rtick;
 
@@ -2523,7 +2523,6 @@ sched_pctcpu(struct thread *td)
 		rtick = min(SCHED_TICK_HZ(ts) / SCHED_TICK_SECS, hz);
 		pctcpu = (FSCALE * ((FSCALE * rtick)/hz)) >> FSHIFT;
 	}
-	thread_unlock(td);
 
 	return (pctcpu);
 }



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