From owner-svn-src-head@freebsd.org Thu Oct 22 09:33:35 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ABF4BA1C953; Thu, 22 Oct 2015 09:33:35 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5AFF91D20; Thu, 22 Oct 2015 09:33:35 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9M9XYCF028343; Thu, 22 Oct 2015 09:33:34 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9M9XYRm028340; Thu, 22 Oct 2015 09:33:34 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201510220933.t9M9XYRm028340@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Thu, 22 Oct 2015 09:33:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289748 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2015 09:33:35 -0000 Author: ed Date: Thu Oct 22 09:33:34 2015 New Revision: 289748 URL: https://svnweb.freebsd.org/changeset/base/289748 Log: Add a way to distinguish between forking and thread creation in schedtail. For CloudABI we need to initialize the registers of new threads differently based on whether the thread got created through a fork or through simple thread creation. Add a flag, TDP_FORKING, that is set by do_fork() and cleared by fork_exit(). This can be tested against in schedtail. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D3973 Modified: head/sys/kern/kern_fork.c head/sys/kern/subr_syscall.c head/sys/sys/proc.h Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Thu Oct 22 09:07:53 2015 (r289747) +++ head/sys/kern/kern_fork.c Thu Oct 22 09:33:34 2015 (r289748) @@ -586,7 +586,7 @@ do_fork(struct thread *td, int flags, st * been preserved. */ p2->p_flag |= p1->p_flag & P_SUGID; - td2->td_pflags |= td->td_pflags & TDP_ALTSTACK; + td2->td_pflags |= (td->td_pflags & TDP_ALTSTACK) | TDP_FORKING; SESS_LOCK(p1->p_session); if (p1->p_session->s_ttyvp != NULL && p1->p_flag & P_CONTROLT) p2->p_flag |= P_CONTROLT; @@ -1023,6 +1023,7 @@ fork_exit(void (*callout)(void *, struct if (p->p_sysent->sv_schedtail != NULL) (p->p_sysent->sv_schedtail)(td); + td->td_pflags &= ~TDP_FORKING; } /* Modified: head/sys/kern/subr_syscall.c ============================================================================== --- head/sys/kern/subr_syscall.c Thu Oct 22 09:07:53 2015 (r289747) +++ head/sys/kern/subr_syscall.c Thu Oct 22 09:33:34 2015 (r289748) @@ -176,6 +176,9 @@ syscallret(struct thread *td, int error, struct proc *p, *p2; int traced; + KASSERT((td->td_pflags & TDP_FORKING) == 0, + ("fork() did not clear TDP_FORKING upon completion")); + p = td->td_proc; /* Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Thu Oct 22 09:07:53 2015 (r289747) +++ head/sys/sys/proc.h Thu Oct 22 09:33:34 2015 (r289748) @@ -446,7 +446,7 @@ do { \ #define TDP_RESETSPUR 0x04000000 /* Reset spurious page fault history. */ #define TDP_NERRNO 0x08000000 /* Last errno is already in td_errno */ #define TDP_UIOHELD 0x10000000 /* Current uio has pages held in td_ma */ -#define TDP_UNUSED29 0x20000000 /* --available-- */ +#define TDP_FORKING 0x20000000 /* Thread is being created through fork() */ #define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */ /*