Changeset 38dc82d in mainline for kernel/generic/src/mm/backend_elf.c


Ignore:
Timestamp:
2016-08-31T14:16:45Z (8 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/backend_elf.c

    rdc05a9a r38dc82d  
    184184                       
    185185                        for (j = 0; j < count; j++) {
    186                                 pte_t *pte;
     186                                pte_t pte;
     187                                bool found;
    187188                       
    188189                                /*
     
    196197                               
    197198                                page_table_lock(area->as, false);
    198                                 pte = page_mapping_find(area->as,
    199                                     base + P2SZ(j), false);
    200                                 ASSERT(pte && PTE_VALID(pte) &&
    201                                     PTE_PRESENT(pte));
     199                                found = page_mapping_find(area->as,
     200                                    base + P2SZ(j), false, &pte);
     201
     202                                ASSERT(found);
     203                                ASSERT(PTE_VALID(&pte));
     204                                ASSERT(PTE_PRESENT(&pte));
     205
    202206                                btree_insert(&area->sh_info->pagemap,
    203207                                    (base + P2SZ(j)) - area->base,
    204                                     (void *) PTE_GET_FRAME(pte), NULL);
     208                                    (void *) PTE_GET_FRAME(&pte), NULL);
    205209                                page_table_unlock(area->as, false);
    206210
    207                                 pfn_t pfn = ADDR2PFN(PTE_GET_FRAME(pte));
     211                                pfn_t pfn = ADDR2PFN(PTE_GET_FRAME(&pte));
    208212                                frame_reference_add(pfn);
    209213                        }
     
    335339                        dirty = true;
    336340                } else {
    337                         pte_t *pte = page_mapping_find(AS_KERNEL,
    338                             base + i * FRAME_SIZE, true);
    339 
    340                         ASSERT(pte);
    341                         ASSERT(PTE_PRESENT(pte));
    342 
    343                         frame = PTE_GET_FRAME(pte);
     341                        pte_t pte;
     342                        bool found;
     343
     344                        found = page_mapping_find(AS_KERNEL,
     345                            base + i * FRAME_SIZE, true, &pte);
     346
     347                        ASSERT(found);
     348                        ASSERT(PTE_PRESENT(&pte));
     349
     350                        frame = PTE_GET_FRAME(&pte);
    344351                }       
    345352        } else if (upage >= start_anon) {
Note: See TracChangeset for help on using the changeset viewer.