Changeset 2299914 in mainline for genarch/src


Ignore:
Timestamp:
2006-03-16T12:57:31Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e898a8d7
Parents:
b7dcabb
Message:

Page table locking.

Location:
genarch/src/mm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • genarch/src/mm/as_ht.c

    rb7dcabb r2299914  
    3535#include <memstr.h>
    3636#include <adt/hash_table.h>
     37#include <synch/spinlock.h>
    3738
    3839static pte_t *ht_create(int flags);
    3940
     41static void ht_lock(as_t *as, bool lock);
     42static void ht_unlock(as_t *as, bool unlock);
     43
    4044as_operations_t as_ht_operations = {
    41         .page_table_create = ht_create
     45        .page_table_create = ht_create,
     46        .page_table_lock = ht_lock,
     47        .page_table_unlock = ht_unlock,
    4248};
    4349
     
    5965        return NULL;
    6066}
     67
     68/** Lock page table.
     69 *
     70 * Lock address space and page hash table.
     71 * Interrupts must be disabled.
     72 *
     73 * @param as Address space.
     74 * @param lock If false, do not attempt to lock the address space.
     75 */
     76void ht_lock(as_t *as, bool lock)
     77{
     78        if (lock)
     79                spinlock_lock(&as->lock);
     80        spinlock_lock(&page_ht_lock);
     81}
     82
     83/** Unlock page table.
     84 *
     85 * Unlock address space and page hash table.
     86 * Interrupts must be disabled.
     87 *
     88 * @param as Address space.
     89 * @param unlock If false, do not attempt to lock the address space.
     90 */
     91void ht_unlock(as_t *as, bool unlock)
     92{
     93        spinlock_unlock(&page_ht_lock);
     94        if (unlock)
     95                spinlock_unlock(&as->lock);
     96}
  • genarch/src/mm/as_pt.c

    rb7dcabb r2299914  
    4040static pte_t *ptl0_create(int flags);
    4141
     42static void pt_lock(as_t *as, bool lock);
     43static void pt_unlock(as_t *as, bool unlock);
     44
    4245as_operations_t as_pt_operations = {
    43         .page_table_create = ptl0_create
     46        .page_table_create = ptl0_create,
     47        .page_table_lock = pt_lock,
     48        .page_table_unlock = pt_unlock
    4449};
    4550
     
    7782        return (pte_t *) KA2PA((__address) dst_ptl0);
    7883}
     84
     85/** Lock page tables.
     86 *
     87 * Lock only the address space.
     88 * Interrupts must be disabled.
     89 *
     90 * @param as Address space.
     91 * @param lock If false, do not attempt to lock the address space.
     92 */
     93void pt_lock(as_t *as, bool lock)
     94{
     95        if (lock)
     96                spinlock_lock(&as->lock);
     97}
     98
     99/** Unlock page tables.
     100 *
     101 * Unlock the address space.
     102 * Interrupts must be disabled.
     103 *
     104 * @param as Address space.
     105 * @param unlock If false, do not attempt to unlock the address space.
     106 */
     107void pt_unlock(as_t *as, bool unlock)
     108{
     109        if (unlock)
     110                spinlock_unlock(&as->lock);
     111}
  • genarch/src/mm/page_ht.c

    rb7dcabb r2299914  
    5353
    5454/**
    55  * This lock protects the page hash table.
     55 * This lock protects the page hash table. It must be acquired
     56 * after address space lock and after any address space area
     57 * locks.
    5658 */
    5759SPINLOCK_INITIALIZE(page_ht_lock);
     
    156158 * using 'flags'.
    157159 *
    158  * The address space must be locked and interruptsmust be disabled.
     160 * The page table must be locked and interrupts must be disabled.
    159161 *
    160162 * @param as Address space to which page belongs.
     
    168170        __native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) };
    169171       
    170         spinlock_lock(&page_ht_lock);
    171 
    172172        if (!hash_table_find(&page_ht, key)) {
    173173                t = (pte_t *) malloc(sizeof(pte_t), FRAME_ATOMIC);
     
    187187                hash_table_insert(&page_ht, key, &t->link);
    188188        }
    189        
    190         spinlock_unlock(&page_ht_lock);
    191189}
    192190
     
    197195 * this call visible.
    198196 *
    199  * The address space must be locked and interrupts must be disabled.
     197 * The page table must be locked and interrupts must be disabled.
    200198 *
    201199 * @param as Address space to wich page belongs.
     
    206204        __native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) };
    207205       
    208         spinlock_lock(&page_ht_lock);
    209 
    210206        /*
    211207         * Note that removed PTE's will be freed
     
    213209         */
    214210        hash_table_remove(&page_ht, key, 2);
    215 
    216         spinlock_unlock(&page_ht_lock);
    217211}
    218212
     
    222216 * Find mapping for virtual page.
    223217 *
    224  * The address space must be locked and interrupts must be disabled.
     218 * The page table must be locked and interrupts must be disabled.
    225219 *
    226220 * @param as Address space to wich page belongs.
     
    235229        __native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) };
    236230       
    237         spinlock_lock(&page_ht_lock);
    238 
    239231        hlp = hash_table_find(&page_ht, key);
    240232        if (hlp)
    241233                t = hash_table_get_instance(hlp, pte_t, link);
    242234
    243         spinlock_unlock(&page_ht_lock);
    244235        return t;
    245236}
  • genarch/src/mm/page_pt.c

    rb7dcabb r2299914  
    5353 * using 'flags'.
    5454 *
    55  * The address space must be locked and interrupts must be disabled.
     55 * The page table must be locked and interrupts must be disabled.
    5656 *
    5757 * @param as Address space to wich page belongs.
     
    106106 * Empty page tables except PTL0 are freed.
    107107 *
    108  * The address space must be locked and interrupts must be disabled.
     108 * The page table must be locked and interrupts must be disabled.
    109109 *
    110110 * @param as Address space to wich page belongs.
     
    226226 * Find mapping for virtual page.
    227227 *
    228  * The address space must be locked and interrupts must be disabled.
     228 * The page table must be locked and interrupts must be disabled.
    229229 *
    230230 * @param as Address space to which page belongs.
Note: See TracChangeset for help on using the changeset viewer.