From owner-p4-projects@FreeBSD.ORG Mon Jul 28 12:24:34 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 68CC81065672; Mon, 28 Jul 2008 12:24:34 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D09E106566B for ; Mon, 28 Jul 2008 12:24:34 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 147718FC08 for ; Mon, 28 Jul 2008 12:24:34 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m6SCOXA2096289 for ; Mon, 28 Jul 2008 12:24:33 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m6SCOXkf096287 for perforce@freebsd.org; Mon, 28 Jul 2008 12:24:33 GMT (envelope-from jhb@freebsd.org) Date: Mon, 28 Jul 2008 12:24:33 GMT Message-Id: <200807281224.m6SCOXkf096287@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 146105 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jul 2008 12:24:34 -0000 http://perforce.freebsd.org/chv.cgi?CH=146105 Change 146105 by jhb@jhb_zion on 2008/07/28 12:23:33 Grrrr, fork() clears td_flags after sched_fork() is called, so the TDF_AFFINITY flag was getting lost for new child processes. Move the flag into a new ts_flags field instead. Affected files ... .. //depot/projects/smpng/sys/kern/sched_4bsd.c#82 edit Differences ... ==== //depot/projects/smpng/sys/kern/sched_4bsd.c#82 (text+ko) ==== @@ -91,13 +91,16 @@ fixpt_t ts_pctcpu; /* (j) %cpu during p_swtime. */ int ts_cpticks; /* (j) Ticks of cpu time. */ int ts_slptime; /* (j) Seconds !RUNNING. */ + int ts_flags; struct runq *ts_runq; /* runq the thread is currently on */ }; /* flags kept in td_flags */ #define TDF_DIDRUN TDF_SCHED0 /* thread actually ran. */ #define TDF_BOUND TDF_SCHED1 /* Bound to one CPU. */ -#define TDF_AFFINITY TDF_SCHED2 /* Has a non-"full" CPU set. */ + +/* flags kept in ts_flags */ +#define TSF_AFFINITY 0x0001 /* Has a non-"full" CPU set. */ #define SKE_RUNQ_PCPU(ts) \ ((ts)->ts_runq != 0 && (ts)->ts_runq != &runq) @@ -738,9 +741,9 @@ childtd->td_estcpu = td->td_estcpu; childtd->td_lock = &sched_lock; childtd->td_cpuset = cpuset_ref(td->td_cpuset); - childtd->td_flags |= (td->td_flags & TDF_AFFINITY); ts = childtd->td_sched; bzero(ts, sizeof(*ts)); + ts->ts_flags |= (td->td_sched->ts_flags & TSF_AFFINITY); } void @@ -1232,7 +1235,7 @@ single_cpu = 1; CTR3(KTR_RUNQ, "sched_add: Put td_sched:%p(td:%p) on cpu%d runq", ts, td, cpu); - } else if (td->td_flags & TDF_AFFINITY) { + } else if (ts->ts_flags & TSF_AFFINITY) { /* Find a valid CPU for our cpuset */ cpu = sched_pickcpu(td); ts->ts_runq = &runq_pcpu[cpu]; @@ -1576,15 +1579,15 @@ THREAD_LOCK_ASSERT(td, MA_OWNED); /* - * Set the TDF_AFFINITY flag if there is at least one CPU this + * Set the TSF_AFFINITY flag if there is at least one CPU this * thread can't run on. */ - td->td_flags &= ~TDF_AFFINITY; + ts->ts_flags &= ~TSF_AFFINITY; for (cpu = 0; cpu <= mp_maxid; cpu++) { if (CPU_ABSENT(cpu)) continue; if (!THREAD_CAN_SCHED(td, cpu)) { - td->td_flags |= TDF_AFFINITY; + ts->ts_flags |= TSF_AFFINITY; break; } } @@ -1592,7 +1595,7 @@ /* * If this thread can run on all CPUs, nothing else to do. */ - if (!(td->td_flags & TDF_AFFINITY)) + if (!(ts->ts_flags & TSF_AFFINITY)) return; /* Pinned threads and bound threads should be left alone. */