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


Ignore:
Timestamp:
2016-08-31T14:16:45Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
346b12a2
Parents:
dc05a9a
Message:

Make page_mapping_find() return a copy rather than the actual PTE

This makes page_mapping_find() more suitable for use with lock-free data
structures such as CHT that guarantee existence of the data only for
some limited time while a condition holds (e.g. inside of a RCU-protected
critical section that must be around all CHT lookups).

File:
1 edited

Legend:

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

    rdc05a9a r38dc82d  
    5959static void ht_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int);
    6060static void ht_mapping_remove(as_t *, uintptr_t);
    61 static pte_t *ht_mapping_find(as_t *, uintptr_t, bool);
     61static bool ht_mapping_find(as_t *, uintptr_t, bool, pte_t *);
    6262static void ht_mapping_make_global(uintptr_t, size_t);
    6363
     
    248248/** Find mapping for virtual page in page hash table.
    249249 *
    250  * @param as     Address space to which page belongs.
    251  * @param page   Virtual page.
    252  * @param nolock True if the page tables need not be locked.
    253  *
    254  * @return NULL if there is no such mapping; requested mapping otherwise.
    255  *
    256  */
    257 pte_t *ht_mapping_find(as_t *as, uintptr_t page, bool nolock)
     250 * @param as       Address space to which page belongs.
     251 * @param page     Virtual page.
     252 * @param nolock   True if the page tables need not be locked.
     253 * @param[out] pte Structure that will receive a copy of the found PTE.
     254 *
     255 * @return True if the mapping was found, false otherwise.
     256 */
     257bool ht_mapping_find(as_t *as, uintptr_t page, bool nolock, pte_t *pte)
    258258{
    259259        sysarg_t key[2] = {
     
    266266        link_t *cur = hash_table_find(&page_ht, key);
    267267        if (cur)
    268                 return hash_table_get_instance(cur, pte_t, link);
    269        
    270         return NULL;
     268                *pte = *hash_table_get_instance(cur, pte_t, link);
     269       
     270        return cur != NULL;
    271271}
    272272
Note: See TracChangeset for help on using the changeset viewer.