Changeset 879585a3 in mainline
- Timestamp:
- 2007-03-31T22:22:50Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 31d8e10
- Parents:
- 563c2dd
- Location:
- kernel
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia64/src/mm/as.c
r563c2dd r879585a3 37 37 #include <arch/mm/page.h> 38 38 #include <genarch/mm/as_ht.h> 39 #include <genarch/mm/page_ht.h> 39 40 #include <genarch/mm/asid_fifo.h> 40 41 #include <mm/asid.h> 41 #include <arch.h>42 42 #include <arch/barrier.h> 43 #include <synch/spinlock.h>44 43 45 44 /** Architecture dependent address space init. */ … … 56 55 void as_install_arch(as_t *as) 57 56 { 58 ipl_t ipl;59 57 region_register rr; 60 58 int i; 61 62 ipl = interrupts_disable();63 spinlock_lock(&as->lock);64 59 65 60 ASSERT(as->asid != ASID_INVALID); … … 81 76 srlz_d(); 82 77 srlz_i(); 83 84 spinlock_unlock(&as->lock);85 interrupts_restore(ipl);86 78 } 87 79 -
kernel/arch/mips32/src/mm/as.c
r563c2dd r879585a3 35 35 #include <arch/mm/as.h> 36 36 #include <genarch/mm/as_pt.h> 37 #include <genarch/mm/page_pt.h> 37 38 #include <genarch/mm/asid_fifo.h> 38 39 #include <arch/mm/tlb.h> … … 40 41 #include <mm/as.h> 41 42 #include <arch/cp0.h> 42 #include <arch.h>43 43 44 44 /** Architecture dependent address space init. */ … … 58 58 { 59 59 entry_hi_t hi; 60 ipl_t ipl;61 60 62 61 /* … … 65 64 hi.value = cp0_entry_hi_read(); 66 65 67 ipl = interrupts_disable();68 spinlock_lock(&as->lock);69 66 hi.asid = as->asid; 70 67 cp0_entry_hi_write(hi.value); 71 spinlock_unlock(&as->lock);72 interrupts_restore(ipl);73 68 } 74 69 -
kernel/arch/ppc32/src/mm/as.c
r563c2dd r879585a3 55 55 { 56 56 asid_t asid; 57 ipl_t ipl;58 57 uint32_t sr; 59 58 60 ipl = interrupts_disable();61 spinlock_lock(&as->lock);62 63 59 asid = as->asid; 64 60 … … 80 76 ); 81 77 } 82 83 spinlock_unlock(&as->lock);84 interrupts_restore(ipl);85 78 } 86 79 -
kernel/arch/ppc64/src/mm/as.c
r563c2dd r879585a3 27 27 */ 28 28 29 29 /** @addtogroup ppc64mm 30 30 * @{ 31 31 */ … … 42 42 } 43 43 44 44 /** @} 45 45 */ 46 46 -
kernel/arch/sparc64/src/mm/as.c
r563c2dd r879585a3 43 43 #include <arch/mm/tsb.h> 44 44 #include <arch/memstr.h> 45 #include <synch/mutex.h>46 45 #include <arch/asm.h> 47 46 #include <mm/frame.h> … … 101 100 { 102 101 #ifdef CONFIG_TSB 103 ipl_t ipl;104 105 ipl = interrupts_disable();106 mutex_lock_active(&as->lock); /* completely unnecessary, but polite */107 102 tsb_invalidate(as, 0, (count_t) -1); 108 mutex_unlock(&as->lock);109 interrupts_restore(ipl);110 103 #endif 111 104 return 0; … … 124 117 125 118 /* 126 * Note that we don't lock the address space.127 * That's correct - we can afford it here128 * because we only read members that are129 * currently read-only.119 * Note that we don't and may not lock the address space. That's ok 120 * since we only read members that are currently read-only. 121 * 122 * Moreover, the as->asid is protected by asidlock, which is being held. 130 123 */ 131 124 132 125 /* 133 * Write ASID to secondary context register. 134 * The primary context register has to be set 135 * from TL>0 so it will be filled from the 136 * secondary context register from the TL=1 137 * code just before switch to userspace. 126 * Write ASID to secondary context register. The primary context 127 * register has to be set from TL>0 so it will be filled from the 128 * secondary context register from the TL=1 code just before switch to 129 * userspace. 138 130 */ 139 131 ctx.v = 0; … … 185 177 186 178 /* 187 * Note that we don't lock the address space.188 * That's correct - we can afford it here189 * because we only read members that are190 * currently read-only.179 * Note that we don't and may not lock the address space. That's ok 180 * since we only read members that are currently read-only. 181 * 182 * Moreover, the as->asid is protected by asidlock, which is being held. 191 183 */ 192 184 -
kernel/genarch/src/mm/asid.c
r563c2dd r879585a3 63 63 #include <synch/spinlock.h> 64 64 #include <synch/mutex.h> 65 #include <arch.h>66 65 #include <adt/list.h> 67 66 #include <debug.h> 68 69 /**70 * asidlock protects the asids_allocated counter.71 */72 SPINLOCK_INITIALIZE(asidlock);73 67 74 68 static count_t asids_allocated = 0; … … 91 85 */ 92 86 93 spinlock_lock(&asidlock);94 87 if (asids_allocated == ASIDS_ALLOCABLE) { 95 88 … … 109 102 110 103 as = list_get_instance(tmp, as_t, inactive_as_with_asid_link); 111 mutex_lock_active(&as->lock);112 104 113 105 /* … … 131 123 as_invalidate_translation_cache(as, 0, (count_t) -1); 132 124 133 mutex_unlock(&as->lock);134 135 125 /* 136 126 * Get the system rid of the stolen ASID. … … 157 147 } 158 148 159 spinlock_unlock(&asidlock);160 161 149 return asid; 162 150 } … … 171 159 void asid_put(asid_t asid) 172 160 { 173 ipl_t ipl;174 175 ipl = interrupts_disable();176 spinlock_lock(&asidlock);177 178 161 asids_allocated--; 179 162 asid_put_arch(asid); 180 181 spinlock_unlock(&asidlock);182 interrupts_restore(ipl);183 163 } 184 164 -
kernel/generic/include/mm/as.h
r563c2dd r879585a3 90 90 /** Protected by asidlock. */ 91 91 link_t inactive_as_with_asid_link; 92 /** 93 * Number of processors on wich is this address space active. 94 * Protected by asidlock. 95 */ 96 count_t cpu_refcount; 97 /** 98 * Address space identifier. 99 * Constant on architectures that do not support ASIDs. 100 * Protected by asidlock. 101 */ 102 asid_t asid; 92 103 93 104 mutex_t lock; … … 96 107 count_t refcount; 97 108 98 /** Number of processors on wich is this address space active. */99 count_t cpu_refcount;100 101 109 /** B+tree of address space areas. */ 102 110 btree_t as_area_btree; 103 104 /**105 * Address space identifier.106 * Constant on architectures that do not support ASIDs.107 */108 asid_t asid;109 111 110 112 /** Non-generic content. */ … … 134 136 /** Protected by asidlock. */ 135 137 link_t inactive_as_with_asid_link; 138 /** 139 * Number of processors on wich is this address space active. 140 * Protected by asidlock. 141 */ 142 count_t cpu_refcount; 143 /** 144 * Address space identifier. 145 * Constant on architectures that do not support ASIDs. 146 * Protected by asidlock. 147 */ 148 asid_t asid; 136 149 137 150 mutex_t lock; … … 140 153 count_t refcount; 141 154 142 /** Number of processors on wich is this address space active. */143 count_t cpu_refcount;144 145 155 /** B+tree of address space areas. */ 146 156 btree_t as_area_btree; 147 148 /**149 * Address space identifier.150 * Constant on architectures that do not support ASIDs.151 */152 asid_t asid;153 157 154 158 /** Non-generic content. */ … … 250 254 #endif 251 255 252 SPINLOCK_EXTERN(inactive_as_with_asid_lock);253 256 extern link_t inactive_as_with_asid_head; 254 257 -
kernel/generic/src/mm/as.c
r563c2dd r879585a3 96 96 97 97 /** 98 * This lock protects inactive_as_with_asid_head list. It must be acquired 99 * before as_t mutex. 100 */ 101 SPINLOCK_INITIALIZE(inactive_as_with_asid_lock); 98 * This lock serializes access to the ASID subsystem. 99 * It protects: 100 * - inactive_as_with_asid_head list 101 * - as->asid for each as of the as_t type 102 * - asids_allocated counter 103 */ 104 SPINLOCK_INITIALIZE(asidlock); 102 105 103 106 /** … … 206 209 * it is safe not to lock its mutex. 207 210 */ 211 208 212 ipl = interrupts_disable(); 209 spinlock_lock(& inactive_as_with_asid_lock);213 spinlock_lock(&asidlock); 210 214 if (as->asid != ASID_INVALID && as != AS_KERNEL) { 211 215 if (as != AS && as->cpu_refcount == 0) … … 213 217 asid_put(as->asid); 214 218 } 215 spinlock_unlock(& inactive_as_with_asid_lock);219 spinlock_unlock(&asidlock); 216 220 217 221 /* … … 861 865 * 862 866 * Note that this function cannot sleep as it is essentially a part of 863 * scheduling. Sleeping here would lead to deadlock on wakeup. 867 * scheduling. Sleeping here would lead to deadlock on wakeup. Another 868 * thing which is forbidden in this context is locking the address space. 864 869 * 865 870 * @param old Old address space or NULL. … … 868 873 void as_switch(as_t *old_as, as_t *new_as) 869 874 { 870 ipl_t ipl; 871 bool needs_asid = false; 872 873 ipl = interrupts_disable(); 874 spinlock_lock(&inactive_as_with_asid_lock); 875 spinlock_lock(&asidlock); 875 876 876 877 /* … … 878 879 */ 879 880 if (old_as) { 880 mutex_lock_active(&old_as->lock);881 881 ASSERT(old_as->cpu_refcount); 882 882 if((--old_as->cpu_refcount == 0) && (old_as != AS_KERNEL)) { … … 891 891 &inactive_as_with_asid_head); 892 892 } 893 mutex_unlock(&old_as->lock);894 893 895 894 /* … … 903 902 * Second, prepare the new address space. 904 903 */ 905 mutex_lock_active(&new_as->lock);906 904 if ((new_as->cpu_refcount++ == 0) && (new_as != AS_KERNEL)) { 907 if (new_as->asid != ASID_INVALID) {905 if (new_as->asid != ASID_INVALID) 908 906 list_remove(&new_as->inactive_as_with_asid_link); 909 } else { 910 /* 911 * Defer call to asid_get() until new_as->lock is released. 912 */ 913 needs_asid = true; 914 } 907 else 908 new_as->asid = asid_get(); 915 909 } 916 910 #ifdef AS_PAGE_TABLE 917 911 SET_PTL0_ADDRESS(new_as->genarch.page_table); 918 912 #endif 919 mutex_unlock(&new_as->lock);920 921 if (needs_asid) {922 /*923 * Allocation of new ASID was deferred924 * until now in order to avoid deadlock.925 */926 asid_t asid;927 928 asid = asid_get();929 mutex_lock_active(&new_as->lock);930 new_as->asid = asid;931 mutex_unlock(&new_as->lock);932 }933 spinlock_unlock(&inactive_as_with_asid_lock);934 interrupts_restore(ipl);935 913 936 914 /* … … 939 917 */ 940 918 as_install_arch(new_as); 919 920 spinlock_unlock(&asidlock); 941 921 942 922 AS = new_as;
Note:
See TracChangeset
for help on using the changeset viewer.