Changeset de0af3a in mainline for kernel/generic/src/mm/backend_anon.c


Ignore:
Timestamp:
2018-12-03T18:29:53Z (5 years ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0777a933, 7be8d4d
Parents:
a0765f6
git-author:
Jiri Svoboda <jiri@…> (2018-12-03 16:53:27)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2018-12-03 18:29:53)
Message:

Use ordered dictionary for pagemap instead of B+tree

At the same time we add a little bit more abstraction around the pagemap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/backend_anon.c

    ra0765f6 rde0af3a  
    144144                                assert(PTE_PRESENT(&pte));
    145145
    146                                 btree_insert(&area->sh_info->pagemap,
     146                                as_pagemap_insert(&area->sh_info->pagemap,
    147147                                    (base + P2SZ(j)) - area->base,
    148                                     (void *) PTE_GET_FRAME(&pte), NULL);
     148                                    PTE_GET_FRAME(&pte));
    149149                                page_table_unlock(area->as, false);
    150150
     
    201201        mutex_lock(&area->sh_info->lock);
    202202        if (area->sh_info->shared) {
    203                 btree_node_t *leaf;
    204 
    205203                /*
    206204                 * The area is shared, chances are that the mapping can be found
     
    210208                 * mapping, a new frame is allocated and the mapping is created.
    211209                 */
    212                 frame = (uintptr_t) btree_search(&area->sh_info->pagemap,
    213                     upage - area->base, &leaf);
    214                 if (!frame) {
    215                         bool allocate = true;
    216                         unsigned int i;
     210                errno_t rc = as_pagemap_find(&area->sh_info->pagemap,
     211                    upage - area->base, &frame);
     212                if (rc != EOK) {
     213                        /* Need to allocate the frame */
     214                        kpage = km_temporary_page_get(&frame,
     215                            FRAME_NO_RESERVE);
     216                        memsetb((void *) kpage, PAGE_SIZE, 0);
     217                        km_temporary_page_put(kpage);
    217218
    218219                        /*
    219                          * Zero can be returned as a valid frame address.
    220                          * Just a small workaround.
     220                         * Insert the address of the newly allocated
     221                         * frame to the pagemap.
    221222                         */
    222                         for (i = 0; i < leaf->keys; i++) {
    223                                 if (leaf->key[i] == upage - area->base) {
    224                                         allocate = false;
    225                                         break;
    226                                 }
    227                         }
    228                         if (allocate) {
    229                                 kpage = km_temporary_page_get(&frame,
    230                                     FRAME_NO_RESERVE);
    231                                 memsetb((void *) kpage, PAGE_SIZE, 0);
    232                                 km_temporary_page_put(kpage);
    233 
    234                                 /*
    235                                  * Insert the address of the newly allocated
    236                                  * frame to the pagemap.
    237                                  */
    238                                 btree_insert(&area->sh_info->pagemap,
    239                                     upage - area->base, (void *) frame, leaf);
    240                         }
     223                        as_pagemap_insert(&area->sh_info->pagemap,
     224                            upage - area->base, frame);
    241225                }
    242226                frame_reference_add(ADDR2PFN(frame));
Note: See TracChangeset for help on using the changeset viewer.