From owner-svn-src-all@FreeBSD.ORG Thu Jan 6 22:24:01 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F15D5106567A; Thu, 6 Jan 2011 22:24:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D66B58FC14; Thu, 6 Jan 2011 22:24:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p06MO0U2030347; Thu, 6 Jan 2011 22:24:00 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p06MO0xq030343; Thu, 6 Jan 2011 22:24:00 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201101062224.p06MO0xq030343@svn.freebsd.org> From: John Baldwin Date: Thu, 6 Jan 2011 22:24:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217078 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jan 2011 22:24:01 -0000 Author: jhb Date: Thu Jan 6 22:24:00 2011 New Revision: 217078 URL: http://svn.freebsd.org/changeset/base/217078 Log: - Move sched_fork() later in fork() after the various sections of the new thread and proc have been copied and zeroed from the old thread and proc. Otherwise attempts to modify thread or process data in sched_fork() could be undone. - Don't copy td_{base,}_user_pri from the old thread to the new thread in sched_fork_thread() in ULE. This is already done courtesy the bcopy() of the thread copy region. - Always initialize the real priority (td_priority) of new threads to the new thread's base priority (td_base_pri) to avoid bogusly inheriting a borrowed priority from the parent thread. MFC after: 2 weeks Modified: head/sys/kern/kern_fork.c head/sys/kern/sched_4bsd.c head/sys/kern/sched_ule.c Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Thu Jan 6 22:19:15 2011 (r217077) +++ head/sys/kern/kern_fork.c Thu Jan 6 22:24:00 2011 (r217078) @@ -360,12 +360,6 @@ do_fork(struct thread *td, int flags, st p2->p_state = PRS_NEW; /* protect against others */ p2->p_pid = trypid; - /* - * Allow the scheduler to initialize the child. - */ - thread_lock(td); - sched_fork(td, td2); - thread_unlock(td); AUDIT_ARG_PID(p2->p_pid); LIST_INSERT_HEAD(&allproc, p2, p_list); LIST_INSERT_HEAD(PIDHASH(p2->p_pid), p2, p_hash); @@ -457,6 +451,13 @@ do_fork(struct thread *td, int flags, st #endif /* + * Allow the scheduler to initialize the child. + */ + thread_lock(td); + sched_fork(td, td2); + thread_unlock(td); + + /* * Duplicate sub-structures as needed. * Increase reference counts on shared objects. */ Modified: head/sys/kern/sched_4bsd.c ============================================================================== --- head/sys/kern/sched_4bsd.c Thu Jan 6 22:19:15 2011 (r217077) +++ head/sys/kern/sched_4bsd.c Thu Jan 6 22:24:00 2011 (r217078) @@ -759,6 +759,7 @@ sched_fork_thread(struct thread *td, str childtd->td_estcpu = td->td_estcpu; childtd->td_lock = &sched_lock; childtd->td_cpuset = cpuset_ref(td->td_cpuset); + childtd->td_priority = childtd->td_base_pri; ts = childtd->td_sched; bzero(ts, sizeof(*ts)); ts->ts_flags |= (td->td_sched->ts_flags & TSF_AFFINITY); Modified: head/sys/kern/sched_ule.c ============================================================================== --- head/sys/kern/sched_ule.c Thu Jan 6 22:19:15 2011 (r217077) +++ head/sys/kern/sched_ule.c Thu Jan 6 22:24:00 2011 (r217078) @@ -1961,14 +1961,16 @@ sched_fork_thread(struct thread *td, str ts2->ts_cpu = ts->ts_cpu; ts2->ts_flags = 0; /* - * Grab our parents cpu estimation information and priority. + * Grab our parents cpu estimation information. */ ts2->ts_ticks = ts->ts_ticks; ts2->ts_ltick = ts->ts_ltick; ts2->ts_incrtick = ts->ts_incrtick; ts2->ts_ftick = ts->ts_ftick; - child->td_user_pri = td->td_user_pri; - child->td_base_user_pri = td->td_base_user_pri; + /* + * Do not inherit any borrowed priority from the parent. + */ + child->td_priority = child->td_base_pri; /* * And update interactivity score. */