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


Ignore:
Timestamp:
2018-12-08T23:32:55Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Children:
dd74b5b
Parents:
de0af3a
git-author:
Jiri Svoboda <jiri@…> (2018-12-05 18:39:06)
git-committer:
Jiri Svoboda <jiri@…> (2018-12-08 23:32:55)
Message:

Replace B+tree with ordered dict. for used space

Replace the use of B+tree with ordered dictionary for used space,
adding a little bit more abstraction around used space tracking.
This allows performing TLB shootdown while shrinking an area
in a single sequence. A generic used_space_remove() is no longer
needed.

File:
1 edited

Legend:

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

    rde0af3a r7be8d4d  
    4848#include <synch/mutex.h>
    4949#include <adt/list.h>
    50 #include <adt/btree.h>
    5150#include <errno.h>
    5251#include <typedefs.h>
     
    122121         */
    123122        mutex_lock(&area->sh_info->lock);
    124         list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
    125             node) {
    126                 unsigned int i;
    127 
    128                 for (i = 0; i < node->keys; i++) {
    129                         uintptr_t base = node->key[i];
    130                         size_t count = (size_t) node->value[i];
    131                         unsigned int j;
    132 
    133                         for (j = 0; j < count; j++) {
    134                                 pte_t pte;
    135                                 bool found;
    136 
    137                                 page_table_lock(area->as, false);
    138                                 found = page_mapping_find(area->as,
    139                                     base + P2SZ(j), false, &pte);
    140 
    141                                 (void)found;
    142                                 assert(found);
    143                                 assert(PTE_VALID(&pte));
    144                                 assert(PTE_PRESENT(&pte));
    145 
    146                                 as_pagemap_insert(&area->sh_info->pagemap,
    147                                     (base + P2SZ(j)) - area->base,
    148                                     PTE_GET_FRAME(&pte));
    149                                 page_table_unlock(area->as, false);
    150 
    151                                 pfn_t pfn = ADDR2PFN(PTE_GET_FRAME(&pte));
    152                                 frame_reference_add(pfn);
    153                         }
    154 
     123        used_space_ival_t *ival = used_space_first(&area->used_space);
     124        while (ival != NULL) {
     125                uintptr_t base = ival->page;
     126                size_t count = ival->count;
     127                unsigned int j;
     128
     129                for (j = 0; j < count; j++) {
     130                        pte_t pte;
     131                        bool found;
     132
     133                        page_table_lock(area->as, false);
     134                        found = page_mapping_find(area->as, base + P2SZ(j),
     135                            false, &pte);
     136
     137                        (void)found;
     138                        assert(found);
     139                        assert(PTE_VALID(&pte));
     140                        assert(PTE_PRESENT(&pte));
     141
     142                        as_pagemap_insert(&area->sh_info->pagemap,
     143                            (base + P2SZ(j)) - area->base, PTE_GET_FRAME(&pte));
     144                        page_table_unlock(area->as, false);
     145
     146                        pfn_t pfn = ADDR2PFN(PTE_GET_FRAME(&pte));
     147                        frame_reference_add(pfn);
    155148                }
     149
     150                ival = used_space_next(ival);
    156151        }
    157152        mutex_unlock(&area->sh_info->lock);
     
    264259         */
    265260        page_mapping_insert(AS, upage, frame, as_area_get_flags(area));
    266         if (!used_space_insert(area, upage, 1))
     261        if (!used_space_insert(&area->used_space, upage, 1))
    267262                panic("Cannot insert used space.");
    268263
Note: See TracChangeset for help on using the changeset viewer.