From owner-freebsd-smp Sun Dec 15 08:28:55 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id IAA13535 for smp-outgoing; Sun, 15 Dec 1996 08:28:55 -0800 (PST) Received: from dyson.iquest.net (dyson.iquest.net [198.70.144.127]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id IAA13524; Sun, 15 Dec 1996 08:28:49 -0800 (PST) Received: (from root@localhost) by dyson.iquest.net (8.8.2/8.6.9) id LAA05010; Sun, 15 Dec 1996 11:28:31 -0500 (EST) From: "John S. Dyson" Message-Id: <199612151628.LAA05010@dyson.iquest.net> Subject: Re: some questions concerning TLB shootdowns in FreeBSD To: phk@critter.tfs.com (Poul-Henning Kamp) Date: Sun, 15 Dec 1996 11:28:31 -0500 (EST) Cc: peter@spinner.dialix.com, dyson@freebsd.org, smp@freebsd.org, haertel@ichips.intel.com In-Reply-To: <9319.850645034@critter.tfs.com> from "Poul-Henning Kamp" at Dec 15, 96 11:17:14 am X-Mailer: ELM [version 2.4 PL24 ME8] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-smp@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > In message <199612151003.SAA14741@spinner.DIALix.COM>, Peter Wemm writes: > >Poul-Henning Kamp wrote: > >> In message <199612150121.JAA12763@spinner.DIALix.COM>, Peter Wemm writes: > >> > >> >However, the shared address space code that I was working on in > >> >-current (for kernel assisted threading in the smp kernel) means > >> >that a single vmspace/pmap/etc can be shared among multiple processes > >> >and this changes the above picture since two cpu's can be using > >> >the user mode parts of the same page tables at once, one in executing > >> >in user mode, one in the kernel. > >> > >> But we could still have a per-cpu flags: > >> "I'm not in a shared address-space" > >> > >> Ie, this would only be set if the CPU was in userland in a non-threaded > >> process. > > > >eg, something like: > >if (is_userland && curproc->p_vmspace->vm_refcnt > 1) > > send_tlb_invalidate(); > > Well more like: > > for (i=0;i if (is_userland(i) && curproc[i]->p_vmspace->vm_refcnt > 1) > send_tlb_invalidate(i); > This won't work because processes seldom have the entire address space shared (vm_refcnt.) I am sure that when we get true kernel multithreading that will not be true though. In order to test if a section of an address space is shared, you have to do something like this (and this can take LOTS of time.) (I might have levels of indirection off here, I am also not taking into account submaps -- which complicate the code further, by entailing recursively calling the map/object traversal again -- but recursion is a major no-no in the kernel, as we have found.) for(i=0;ip_vmspace->vm_map->header.next; while (tmpe != &map->header) { if ((tmpe->is_sub_map == 0) && (tmpe->is_a_map == 0)) { tobj = tmpe->object.vm_object; while(tobj) { if (tobj->ref_count > 1) { send_tlb_invalidate(i); goto nextcpu; } tobj = tobj->backing_object; } } else { /* * here on a new map -- need to recurse or * somesuch here -- yuck!!! */ } tmpe = tmpe->next; } nextcpu: } John