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/arch/sparc64/src/mm/sun4u/tlb.c

    rdc05a9a r38dc82d  
    197197{
    198198        size_t index = (istate->tpc >> MMU_PAGE_WIDTH) % MMU_PAGES_PER_PAGE;
    199         pte_t *t;
    200 
    201         t = page_mapping_find(AS, istate->tpc, true);
    202         if (t && PTE_EXECUTABLE(t)) {
     199        pte_t t;
     200
     201        bool found = page_mapping_find(AS, istate->tpc, true, &t);
     202        if (found && PTE_EXECUTABLE(&t)) {
    203203                /*
    204204                 * The mapping was found in the software page hash table.
    205205                 * Insert it into ITLB.
    206206                 */
    207                 t->a = true;
    208                 itlb_pte_copy(t, index);
     207                t.a = true;
     208                itlb_pte_copy(&t, index);
    209209#ifdef CONFIG_TSB
    210                 itsb_pte_copy(t, index);
     210                itsb_pte_copy(&t, index);
    211211#endif
    212212        } else {
     
    233233        uintptr_t page_16k;
    234234        size_t index;
    235         pte_t *t;
     235        pte_t t;
    236236        as_t *as = AS;
    237237
     
    253253        }
    254254
    255         t = page_mapping_find(as, page_16k, true);
    256         if (t) {
     255        bool found = page_mapping_find(as, page_16k, true, &t);
     256        if (found) {
    257257                /*
    258258                 * The mapping was found in the software page hash table.
    259259                 * Insert it into DTLB.
    260260                 */
    261                 t->a = true;
    262                 dtlb_pte_copy(t, index, true);
     261                t.a = true;
     262                dtlb_pte_copy(&t, index, true);
    263263#ifdef CONFIG_TSB
    264                 dtsb_pte_copy(t, index, true);
     264                dtsb_pte_copy(&t, index, true);
    265265#endif
    266266        } else {
     
    283283        uintptr_t page_16k;
    284284        size_t index;
    285         pte_t *t;
     285        pte_t t;
    286286        as_t *as = AS;
    287287
     
    293293                as = AS_KERNEL;
    294294
    295         t = page_mapping_find(as, page_16k, true);
    296         if (t && PTE_WRITABLE(t)) {
     295        bool found = page_mapping_find(as, page_16k, true, &t);
     296        if (found && PTE_WRITABLE(&t)) {
    297297                /*
    298298                 * The mapping was found in the software page hash table and is
     
    300300                 * into DTLB.
    301301                 */
    302                 t->a = true;
    303                 t->d = true;
     302                t.a = true;
     303                t.d = true;
    304304                dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY,
    305305                    page_16k + index * MMU_PAGE_SIZE);
    306                 dtlb_pte_copy(t, index, false);
     306                dtlb_pte_copy(&t, index, false);
    307307#ifdef CONFIG_TSB
    308                 dtsb_pte_copy(t, index, false);
     308                dtsb_pte_copy(&t, index, false);
    309309#endif
    310310        } else {
Note: See TracChangeset for help on using the changeset viewer.