Changeset fb63c06 in mainline
- Timestamp:
- 2016-09-01T16:37:51Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2a2fbc8
- Parents:
- 346b12a2
- Location:
- kernel/genarch
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/include/genarch/mm/page_ht.h
r346b12a2 rfb63c06 44 44 #include <mm/page.h> 45 45 #include <mm/slab.h> 46 #include <synch/mutex.h>47 46 #include <adt/hash_table.h> 48 47 … … 66 65 67 66 extern slab_cache_t *pte_cache; 68 extern mutex_t page_ht_lock;69 67 extern hash_table_t page_ht; 70 68 extern hash_table_operations_t ht_operations; -
kernel/genarch/src/mm/as_ht.c
r346b12a2 rfb63c06 77 77 if (flags & FLAG_AS_KERNEL) { 78 78 hash_table_create(&page_ht, PAGE_HT_ENTRIES, 2, &ht_operations); 79 mutex_initialize(&page_ht_lock, MUTEX_PASSIVE);80 79 pte_cache = slab_cache_create("pte_t", sizeof(pte_t), 0, 81 80 NULL, NULL, SLAB_CACHE_MAGDEFERRED); … … 99 98 /** Lock page table. 100 99 * 101 * Lock address space and page hash table.100 * Lock address space. 102 101 * Interrupts must be disabled. 103 102 * … … 110 109 if (lock) 111 110 mutex_lock(&as->lock); 112 113 mutex_lock(&page_ht_lock);114 111 } 115 112 116 113 /** Unlock page table. 117 114 * 118 * Unlock address space and page hash table.115 * Unlock address space. 119 116 * Interrupts must be disabled. 120 117 * … … 125 122 void ht_unlock(as_t *as, bool unlock) 126 123 { 127 mutex_unlock(&page_ht_lock);128 129 124 if (unlock) 130 125 mutex_unlock(&as->lock); … … 140 135 bool ht_locked(as_t *as) 141 136 { 142 return (mutex_locked(&page_ht_lock) && mutex_locked(&as->lock));137 return mutex_locked(&as->lock); 143 138 } 144 139 -
kernel/genarch/src/mm/page_ht.c
r346b12a2 rfb63c06 71 71 * 72 72 */ 73 mutex_t page_ht_lock;73 IRQ_SPINLOCK_STATIC_INITIALIZE(page_ht_lock); 74 74 75 75 /** Page hash table. … … 193 193 194 194 ASSERT(page_table_locked(as)); 195 196 irq_spinlock_lock(&page_ht_lock, true); 195 197 196 198 if (!hash_table_find(&page_ht, key)) { … … 219 221 hash_table_insert(&page_ht, key, &pte->link); 220 222 } 223 224 irq_spinlock_unlock(&page_ht_lock, true); 221 225 } 222 226 … … 240 244 ASSERT(page_table_locked(as)); 241 245 246 irq_spinlock_lock(&page_ht_lock, true); 247 242 248 /* 243 249 * Note that removed PTE's will be freed … … 245 251 */ 246 252 hash_table_remove(&page_ht, key, 2); 253 254 irq_spinlock_unlock(&page_ht_lock, true); 247 255 } 248 256 … … 255 263 256 264 ASSERT(nolock || page_table_locked(as)); 257 265 258 266 link_t *cur = hash_table_find(&page_ht, key); 259 267 if (cur) … … 274 282 bool ht_mapping_find(as_t *as, uintptr_t page, bool nolock, pte_t *pte) 275 283 { 284 irq_spinlock_lock(&page_ht_lock, true); 285 276 286 pte_t *t = ht_mapping_find_internal(as, page, nolock); 277 287 if (t) 278 288 *pte = *t; 289 290 irq_spinlock_unlock(&page_ht_lock, true); 279 291 280 292 return t != NULL; … … 290 302 void ht_mapping_update(as_t *as, uintptr_t page, bool nolock, pte_t *pte) 291 303 { 304 irq_spinlock_lock(&page_ht_lock, true); 305 292 306 pte_t *t = ht_mapping_find_internal(as, page, nolock); 293 307 if (!t) … … 306 320 t->a = pte->a; 307 321 t->d = pte->d; 322 323 irq_spinlock_unlock(&page_ht_lock, true); 308 324 } 309 325
Note:
See TracChangeset
for help on using the changeset viewer.