Changeset 38dc82d in mainline for kernel/generic/src/mm/page.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/generic/src/mm/page.c

    rdc05a9a r38dc82d  
    137137/** Find mapping for virtual page.
    138138 *
    139  * @param as     Address space to which page belongs.
    140  * @param page   Virtual page.
    141  * @param nolock True if the page tables need not be locked.
    142  *
    143  * @return NULL if there is no such mapping; requested mapping
    144  *         otherwise.
    145  *
    146  */
    147 NO_TRACE pte_t *page_mapping_find(as_t *as, uintptr_t page, bool nolock)
     139 * @param as       Address space to which page belongs.
     140 * @param page     Virtual page.
     141 * @param nolock   True if the page tables need not be locked.
     142 * @param[out] pte Structure that will receive a copy of the found PTE.
     143 *
     144 * @return True if the mapping was found, false otherwise.
     145 */
     146NO_TRACE bool page_mapping_find(as_t *as, uintptr_t page, bool nolock,
     147    pte_t *pte)
    148148{
    149149        ASSERT(nolock || page_table_locked(as));
     
    153153       
    154154        return page_mapping_operations->mapping_find(as,
    155             ALIGN_DOWN(page, PAGE_SIZE), nolock);
     155            ALIGN_DOWN(page, PAGE_SIZE), nolock, pte);
    156156}
    157157
     
    173173        page_table_lock(AS, true);
    174174       
    175         pte_t *pte = page_mapping_find(AS, virt, false);
    176         if ((!PTE_VALID(pte)) || (!PTE_PRESENT(pte))) {
     175        pte_t pte;
     176        bool found = page_mapping_find(AS, virt, false, &pte);
     177        if (!found || !PTE_VALID(&pte) || !PTE_PRESENT(&pte)) {
    177178                page_table_unlock(AS, true);
    178179                return ENOENT;
    179180        }
    180181       
    181         *phys = PTE_GET_FRAME(pte) +
     182        *phys = PTE_GET_FRAME(&pte) +
    182183            (virt - ALIGN_DOWN(virt, PAGE_SIZE));
    183184       
Note: See TracChangeset for help on using the changeset viewer.