Subject: Re: lazy pmap switch
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: Stephan Uphoff <ups@tree.com>
List: port-i386
Date: 02/07/2004 21:29:33
hi,

YAMAMOTO Takashi wrote:
> hi,
>
> currently we too oftenly switch between address spaces.
> (eg. everytime when we start idling.)
> and on i386, it means flushing all user tlbs.
> to resolve the issue, i'd like to postpone loading cr3
> until it's really needed.
> i'll commit the attached diffs if no one objects.
>
> YAMAMOTO Takashi

SWEET !

I think there are two minor race conditions.

One is between fuswintr/suswintr and pmap_load().
If pmap_load() is interrupted after "ci->ci_want_pmapload = 0;"
but before switching cr3 - the functions fuswintr/suswint called in 
the interrupt can access the wrong address space.
Just moving the "ci->ci_want_pmapload = 0;" should fix that problem.

The second is between pmap_reactivate and pmap_tlb_shootdown.
Example: CPU A reactivates pmap after CPU B checks the active CPUs in 
pmap_tlb_shootdown
but before setting  "pmap->pm_weakrefs = 0;"
I don't think this can be solved without using a lock. (pq_slock?)

	Stephan