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

    rdc05a9a r38dc82d  
    484484{
    485485        uintptr_t va;
    486         pte_t *t;
     486        pte_t t;
    487487       
    488488        va = istate->cr_ifa; /* faulting address */
     
    490490        ASSERT(!is_kernel_fault(va));
    491491
    492         t = page_mapping_find(AS, va, true);
    493         if (t) {
     492        bool found = page_mapping_find(AS, va, true, &t);
     493        if (found) {
    494494                /*
    495495                 * The mapping was found in software page hash table.
    496496                 * Insert it into data translation cache.
    497497                 */
    498                 itc_pte_copy(t);
     498                itc_pte_copy(&t);
    499499        } else {
    500500                /*
     
    600600       
    601601       
    602         pte_t *entry = page_mapping_find(as, va, true);
    603         if (entry) {
     602        pte_t t;
     603        bool found = page_mapping_find(as, va, true, &t);
     604        if (found) {
    604605                /*
    605606                 * The mapping was found in the software page hash table.
    606607                 * Insert it into data translation cache.
    607608                 */
    608                 dtc_pte_copy(entry);
     609                dtc_pte_copy(&t);
    609610        } else {
    610611                if (try_memmap_io_insertion(va, istate))
     
    641642{
    642643        uintptr_t va;
    643         pte_t *t;
     644        pte_t t;
    644645        as_t *as = AS;
    645646       
     
    649650                as = AS_KERNEL;
    650651
    651         t = page_mapping_find(as, va, true);
    652         ASSERT((t) && (t->p));
    653         if ((t) && (t->p) && (t->w)) {
     652        bool found = page_mapping_find(as, va, true, &t);
     653
     654        ASSERT(found);
     655        ASSERT(t.p);
     656
     657        if (found && t.p && t.w) {
    654658                /*
    655659                 * Update the Dirty bit in page tables and reinsert
    656660                 * the mapping into DTC.
    657661                 */
    658                 t->d = true;
    659                 dtc_pte_copy(t);
     662                t.d = true;
     663                dtc_pte_copy(&t);
    660664        } else {
    661665                as_page_fault(va, PF_ACCESS_WRITE, istate);
     
    672676{
    673677        uintptr_t va;
    674         pte_t *t;
     678        pte_t t;
    675679       
    676680        va = istate->cr_ifa;  /* faulting address */
     
    678682        ASSERT(!is_kernel_fault(va));
    679683       
    680         t = page_mapping_find(AS, va, true);
    681         ASSERT((t) && (t->p));
    682         if ((t) && (t->p) && (t->x)) {
     684        bool found = page_mapping_find(AS, va, true, &t);
     685
     686        ASSERT(found);
     687        ASSERT(t.p);
     688
     689        if (found && t.p && t.x) {
    683690                /*
    684691                 * Update the Accessed bit in page tables and reinsert
    685692                 * the mapping into ITC.
    686693                 */
    687                 t->a = true;
    688                 itc_pte_copy(t);
     694                t.a = true;
     695                itc_pte_copy(&t);
    689696        } else {
    690697                as_page_fault(va, PF_ACCESS_EXEC, istate);
     
    701708{
    702709        uintptr_t va;
    703         pte_t *t;
     710        pte_t t;
    704711        as_t *as = AS;
    705712       
     
    709716                as = AS_KERNEL;
    710717
    711         t = page_mapping_find(as, va, true);
    712         ASSERT((t) && (t->p));
    713         if ((t) && (t->p)) {
     718        bool found = page_mapping_find(as, va, true, &t);
     719
     720        ASSERT(found);
     721        ASSERT(t.p);
     722
     723        if (found && t.p) {
    714724                /*
    715725                 * Update the Accessed bit in page tables and reinsert
    716726                 * the mapping into DTC.
    717727                 */
    718                 t->a = true;
    719                 dtc_pte_copy(t);
     728                t.a = true;
     729                dtc_pte_copy(&t);
    720730        } else {
    721731                if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
     
    736746{
    737747        uintptr_t va;
    738         pte_t *t;
     748        pte_t t;
    739749       
    740750        va = istate->cr_ifa;  /* faulting address */
     
    745755         * Assume a write to a read-only page.
    746756         */
    747         t = page_mapping_find(AS, va, true);
    748         ASSERT((t) && (t->p));
    749         ASSERT(!t->w);
     757        bool found = page_mapping_find(AS, va, true, &t);
     758
     759        ASSERT(found);
     760        ASSERT(t.p);
     761        ASSERT(!t.w);
     762
    750763        as_page_fault(va, PF_ACCESS_WRITE, istate);
    751764}
     
    760773{
    761774        uintptr_t va;
    762         pte_t *t;
     775        pte_t t;
    763776       
    764777        va = istate->cr_ifa;  /* faulting address */
     
    766779        ASSERT(!is_kernel_fault(va));
    767780
    768         t = page_mapping_find(AS, va, true);
    769         ASSERT(t);
    770        
    771         if (t->p) {
     781        bool found = page_mapping_find(AS, va, true, &t);
     782
     783        ASSERT(found);
     784       
     785        if (t.p) {
    772786                /*
    773787                 * If the Present bit is set in page hash table, just copy it
    774788                 * and update ITC/DTC.
    775789                 */
    776                 if (t->x)
    777                         itc_pte_copy(t);
     790                if (t.x)
     791                        itc_pte_copy(&t);
    778792                else
    779                         dtc_pte_copy(t);
     793                        dtc_pte_copy(&t);
    780794        } else {
    781795                as_page_fault(va, PF_ACCESS_READ, istate);
Note: See TracChangeset for help on using the changeset viewer.