Changeset fb63c06 in mainline for kernel/genarch/src/mm/page_ht.c


Ignore:
Timestamp:
2016-09-01T16:37:51Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2a2fbc8
Parents:
346b12a2
Message:

Make page hash table critical sections smaller

After the change of the page mapping interface to work exclusively with
a copy of the actual PTE, the critical section around page hash table
look-ups, insertions and deletions can be much smaller.

This change necessitated the change of the page_ht_lock mutex into a
spinlock, because the page mapping API can be used from within TLB
shootdown sequence, which is basically a spinlock-protected critical
section and we cannot take a mutex while holding a spinlock.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/mm/page_ht.c

    r346b12a2 rfb63c06  
    7171 *
    7272 */
    73 mutex_t page_ht_lock;
     73IRQ_SPINLOCK_STATIC_INITIALIZE(page_ht_lock);
    7474
    7575/** Page hash table.
     
    193193
    194194        ASSERT(page_table_locked(as));
     195
     196        irq_spinlock_lock(&page_ht_lock, true);
    195197       
    196198        if (!hash_table_find(&page_ht, key)) {
     
    219221                hash_table_insert(&page_ht, key, &pte->link);
    220222        }
     223
     224        irq_spinlock_unlock(&page_ht_lock, true);
    221225}
    222226
     
    240244        ASSERT(page_table_locked(as));
    241245       
     246        irq_spinlock_lock(&page_ht_lock, true);
     247
    242248        /*
    243249         * Note that removed PTE's will be freed
     
    245251         */
    246252        hash_table_remove(&page_ht, key, 2);
     253
     254        irq_spinlock_unlock(&page_ht_lock, true);
    247255}
    248256
     
    255263
    256264        ASSERT(nolock || page_table_locked(as));
    257        
     265
    258266        link_t *cur = hash_table_find(&page_ht, key);
    259267        if (cur)
     
    274282bool ht_mapping_find(as_t *as, uintptr_t page, bool nolock, pte_t *pte)
    275283{
     284        irq_spinlock_lock(&page_ht_lock, true);
     285
    276286        pte_t *t = ht_mapping_find_internal(as, page, nolock);
    277287        if (t)
    278288                *pte = *t;
     289
     290        irq_spinlock_unlock(&page_ht_lock, true);
    279291       
    280292        return t != NULL;
     
    290302void ht_mapping_update(as_t *as, uintptr_t page, bool nolock, pte_t *pte)
    291303{
     304        irq_spinlock_lock(&page_ht_lock, true);
     305
    292306        pte_t *t = ht_mapping_find_internal(as, page, nolock);
    293307        if (!t)
     
    306320        t->a = pte->a;
    307321        t->d = pte->d;
     322
     323        irq_spinlock_unlock(&page_ht_lock, true);
    308324}
    309325
Note: See TracChangeset for help on using the changeset viewer.