Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Apr 2009 19:54:17 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Jeff Roberson <jeff@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r191643 - in head/sys: kern sys
Message-ID:  <20090429165417.GG40751@deviant.kiev.zoral.com.ua>
In-Reply-To: <200904290315.n3T3FiJW067558@svn.freebsd.org>
References:  <200904290315.n3T3FiJW067558@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--7fVr/IRGAG9sAW4J
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Apr 29, 2009 at 03:15:44AM +0000, Jeff Roberson wrote:
> Author: jeff
> Date: Wed Apr 29 03:15:43 2009
> New Revision: 191643
> URL: http://svn.freebsd.org/changeset/base/191643
>=20
> Log:
>    - Remove the bogus idle thread state code.  This may have a race in it
>      and it only optimized out an ipi or mwait in very few cases.
>    - Skip the adaptive idle code when running on SMT or HTT cores.  This
>      just wastes cpu time that could be used on a busy thread on the same
>      core.
>    - Rename CG_FLAG_THREAD to CG_FLAG_SMT to be more descriptive.  Re-use
>      CG_FLAG_THREAD to mean SMT or HTT.
>  =20
>   Sponsored by:   Nokia
>=20
> Modified:
>   head/sys/kern/sched_ule.c
>   head/sys/kern/subr_smp.c
>   head/sys/sys/smp.h

Now I see a reason why it is better #ifdef SMP the code that uses CG_FLAG_*.
Also, we should check for tdq_cg !=3D NULL in one more place.

See the patch below, instead of exposing CG_FLAG_* for !SMP configs.

diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 680572d..fe3a119 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -891,6 +891,7 @@ tdq_move(struct tdq *from, struct tdq *to)
 	return (1);
 }
=20
+#ifdef SMP
 /*
  * This tdq has idled.  Try to steal a thread from another cpu and switch
  * to it.
@@ -947,6 +948,7 @@ tdq_idled(struct tdq *tdq)
 	spinlock_exit();
 	return (1);
 }
+#endif
=20
 /*
  * Notify a remote cpu of new work.  Sends an IPI if criteria are met.
@@ -2525,7 +2527,9 @@ sched_idletd(void *dummy)
 	struct thread *td;
 	struct tdq *tdq;
 	int switchcnt;
+#ifdef SMP
 	int i;
+#endif
=20
 	mtx_assert(&Giant, MA_NOTOWNED);
 	td =3D curthread;
@@ -2543,7 +2547,9 @@ sched_idletd(void *dummy)
 		 * loops while on SMT machines as this simply steals
 		 * cycles from cores doing useful work.
 		 */
-		if ((tdq->tdq_cg->cg_flags & CG_FLAG_THREAD) =3D=3D 0 &&
+#ifdef SMP
+		if (tdq->tdq_cg !=3D NULL &&
+		    (tdq->tdq_cg->cg_flags & CG_FLAG_THREAD) =3D=3D 0 &&
 		    switchcnt > sched_idlespinthresh) {
 			for (i =3D 0; i < sched_idlespins; i++) {
 				if (tdq->tdq_load)
@@ -2551,6 +2557,7 @@ sched_idletd(void *dummy)
 				cpu_spinwait();
 			}
 		}
+#endif
 		switchcnt =3D tdq->tdq_switchcnt + tdq->tdq_oldswitchcnt;
 		if (tdq->tdq_load =3D=3D 0)
 			cpu_idle(switchcnt > 1);

--7fVr/IRGAG9sAW4J
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)

iEYEARECAAYFAkn4hjgACgkQC3+MBN1Mb4hsoACfVDIzV4KqZR5Zi/scpiolmWf6
L/UAn0dGosIBRmlW16kn/07cNChsla6g
=MG++
-----END PGP SIGNATURE-----

--7fVr/IRGAG9sAW4J--



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