From owner-svn-src-all@FreeBSD.ORG Thu Jan 9 03:33:12 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D5BD3DEB; Thu, 9 Jan 2014 03:33:12 +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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A7AFD117C; Thu, 9 Jan 2014 03:33:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s093XCkv017408; Thu, 9 Jan 2014 03:33:12 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s093XCXr017407; Thu, 9 Jan 2014 03:33:12 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201401090333.s093XCXr017407@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 9 Jan 2014 03:33:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260468 - stable/9/sys/amd64/amd64 X-SVN-Group: stable-9 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.17 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, 09 Jan 2014 03:33:12 -0000 Author: kib Date: Thu Jan 9 03:33:12 2014 New Revision: 260468 URL: http://svnweb.freebsd.org/changeset/base/260468 Log: MFC r260205: Update the description for pmap_remove_pages() to match the modern times. Assert that the pmap passed to pmap_remove_pages() is only active on current CPU. Modified: stable/9/sys/amd64/amd64/pmap.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/amd64/pmap.c ============================================================================== --- stable/9/sys/amd64/amd64/pmap.c Thu Jan 9 03:32:03 2014 (r260467) +++ stable/9/sys/amd64/amd64/pmap.c Thu Jan 9 03:33:12 2014 (r260468) @@ -4386,12 +4386,20 @@ pmap_page_is_mapped(vm_page_t m) } /* - * Remove all pages from specified address space - * this aids process exit speeds. Also, this code - * is special cased for current process only, but - * can have the more generic (and slightly slower) - * mode enabled. This is much faster than pmap_remove - * in the case of running down an entire address space. + * Destroy all managed, non-wired mappings in the given user-space + * pmap. This pmap cannot be active on any processor besides the + * caller. + * + * This function cannot be applied to the kernel pmap. Moreover, it + * is not intended for general use. It is only to be used during + * process termination. Consequently, it can be implemented in ways + * that make it faster than pmap_remove(). First, it can more quickly + * destroy mappings by iterating over the pmap's collection of PV + * entries, rather than searching the page table. Second, it doesn't + * have to test and clear the page table entries atomically, because + * no processor is currently accessing the user address space. In + * particular, a page table entry's dirty bit won't change state once + * this function starts. */ void pmap_remove_pages(pmap_t pmap) @@ -4408,10 +4416,25 @@ pmap_remove_pages(pmap_t pmap) uint64_t inuse, bitmask; int allfree, field, freed, idx; - if (pmap != PCPU_GET(curpmap)) { - printf("warning: pmap_remove_pages called with non-current pmap\n"); - return; + /* + * Assert that the given pmap is only active on the current + * CPU. Unfortunately, we cannot block another CPU from + * activating the pmap while this function is executing. + */ + KASSERT(pmap == PCPU_GET(curpmap), ("non-current pmap %p", pmap)); +#ifdef INVARIANTS + { + cpuset_t other_cpus; + + other_cpus = all_cpus; + critical_enter(); + CPU_CLR(PCPU_GET(cpuid), &other_cpus); + CPU_AND(&other_cpus, &pmap->pm_active); + critical_exit(); + KASSERT(CPU_EMPTY(&other_cpus), ("pmap active %p", pmap)); } +#endif + lock = NULL; rw_rlock(&pvh_global_lock); PMAP_LOCK(pmap);