Subject: Re: port-alpha/25599
To: None <port-alpha-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: Jason Thorpe <thorpej@shagadelic.org>
List: netbsd-bugs
Date: 07/21/2005 15:30:02
The following reply was made to PR port-alpha/25599; it has been noted by GNATS.

From: Jason Thorpe <thorpej@shagadelic.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-alpha/25599
Date: Thu, 21 Jul 2005 08:29:46 -0700

 --Apple-Mail-7--228818181
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=US-ASCII;
 	delsp=yes;
 	format=flowed
 
 The attached patch should address the problem.  This is what it does:
 
 1. Disables the lazy allocation of lev1map in pmap_enter(), instead  
 doing it in pmap_create(), and freeing the lev1map in pmap_destroy 
 ().  This means that pm_lev1map is consistent for the life of the pmap.
 
 2. pmap_extract() is changed to use vtophys() for the kernel pmap.   
 This avoids locking the kernel pmap (kernel PT pages are never freed).
 
 3. Because of (1), pmap_asn_alloc() no longer needs to operate on a  
 locked pmap (pm_lev1map will never change over the life of a pmap,  
 and all other access to the pmap is done in per-CPU fields or with  
 atomic operations).
 
 4. Because of (3), pmap_activate() no longer needs to lock the pmap  
 to do its work, thus eliminating the deadlock with sched_lock.  This  
 is safe, because we are guaranteed that the pmap is still alive,  
 since by definition an LWP that uses it is about to run.
 
 The patch has been posted to port-alpha for testing.
 
 -- thorpej
 
 
 --Apple-Mail-7--228818181
 Content-Transfer-Encoding: 7bit
 Content-Type: application/octet-stream;
 	x-unix-mode=0644;
 	name="pmap-no-lazy-lev1map-patch.txt.uu"
 Content-Disposition: attachment;
 	filename=pmap-no-lazy-lev1map-patch.txt.uu
 
 begin 755 pmap-no-lazy-lev1map-patch.txt
 M26YD97@Z('!M87`N8PH]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]
 M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]"E)#4R!F:6QE
 M.B`O8W9S<F]O="]S<F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7VQE=C%M87`I('L*("-I9F1E9B!$14)51PI`0"`M
 M,S8Q,"PQ,2`K,S8V-BPW($!`('!M87!?87-N7V%L;&]C*'!M87!?="!P;6%P
 M+"!L;VYG(&-P=5]I9"D*(`D)("HO"B`)"7!M82T^<&UA7V%S;B`](%!-05!?
 M05-.7U)%4T525D5$.PH@(V5L<V4*+2-I9F1E9B!$24%'3D]35$E#"BT)"6EF
 M("AP;6$M/G!M85]A<VX@(3T@4$U!4%]!4TY?4D5315)6140I"BT)"0EP86YI
 M8R@B<&UA<%]A<VY?86QL;V,Z(&ME<FYE;%]L978Q;6%P('=I=&AO=70@(@HM
 M"0D)("`@(")034%07T%33E]215-%4E9%1"(I.PHM(V5N9&EF"BL)"4M!4U-%
 M4E0H<&UA+3YP;6%?87-N(#T](%!-05!?05-.7U)%4T525D5$*3L*("-E;F1I
 F9B`O*B!-54Q425!23T-%4U-/4B`J+PH@"0ER971U<FX["B`)?0H`
 `
 end
 
 --Apple-Mail-7--228818181--