From owner-svn-src-all@FreeBSD.ORG Sat May 16 09:13:56 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EBB918BC; Sat, 16 May 2015 09:13:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 D979D1DE5; Sat, 16 May 2015 09:13:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4G9DuUK044002; Sat, 16 May 2015 09:13:56 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4G9DuKi044001; Sat, 16 May 2015 09:13:56 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201505160913.t4G9DuKi044001@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 16 May 2015 09:13:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r283004 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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: Sat, 16 May 2015 09:13:57 -0000 Author: kib Date: Sat May 16 09:13:56 2015 New Revision: 283004 URL: https://svnweb.freebsd.org/changeset/base/283004 Log: MFC r282679: Do not return from thread_single(SINGLE_BOUNDARY) until all stopped thread are guarenteed to be removed from the processors. Modified: stable/10/sys/kern/kern_thread.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_thread.c ============================================================================== --- stable/10/sys/kern/kern_thread.c Sat May 16 08:12:00 2015 (r283003) +++ stable/10/sys/kern/kern_thread.c Sat May 16 09:13:56 2015 (r283004) @@ -758,6 +758,29 @@ stopme: PROC_LOCK(p); PROC_SLOCK(p); } + } else if (mode == SINGLE_BOUNDARY) { + /* + * Wait until all suspended threads are removed from + * the processors. The thread_suspend_check() + * increments p_boundary_count while it is still + * running, which makes it possible for the execve() + * to destroy vmspace while our other threads are + * still using the address space. + * + * We lock the thread, which is only allowed to + * succeed after context switch code finished using + * the address space. + */ + FOREACH_THREAD_IN_PROC(p, td2) { + if (td2 == td) + continue; + thread_lock(td2); + KASSERT((td2->td_flags & TDF_BOUNDARY) != 0, + ("td %p not on boundary", td2)); + KASSERT(TD_IS_SUSPENDED(td2), + ("td %p is not suspended", td2)); + thread_unlock(td2); + } } PROC_SUNLOCK(p); return (0);