Changeset 9dd730d1 in mainline


Ignore:
Timestamp:
2011-04-16T12:40:22Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8a2474f
Parents:
8b655705
Message:

Reserve only anonymous pages in ELF-backed address space areas.

File:
1 edited

Legend:

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

    r8b655705 r9dd730d1  
    7272bool elf_create(as_area_t *area)
    7373{
     74        elf_segment_header_t *entry = area->backend_data.segment;
     75        size_t nonanon_pages = ALIGN_DOWN(entry->p_filesz, PAGE_SIZE);
     76
    7477        /**
    7578         * @todo:
     
    7780         * supporting structures allocated during the page fault.
    7881         */
    79         return reserve_try_alloc(area->pages);
     82       
     83        if (area->pages <= nonanon_pages)
     84                return true;
     85       
     86        return reserve_try_alloc(area->pages - nonanon_pages);
    8087}
    8188
    8289bool elf_resize(as_area_t *area, size_t new_pages)
    8390{
    84         if (new_pages > area->pages)
    85                 return reserve_try_alloc(new_pages - area->pages);
    86         else if (new_pages < area->pages)
    87                 reserve_free(area->pages - new_pages);
     91        elf_segment_header_t *entry = area->backend_data.segment;
     92        size_t nonanon_pages = ALIGN_DOWN(entry->p_filesz, PAGE_SIZE);
     93
     94        if (new_pages > area->pages) {
     95                /* The area is growing. */
     96                if (area->pages >= nonanon_pages)
     97                        return reserve_try_alloc(new_pages - area->pages);
     98                else if (new_pages > nonanon_pages)
     99                        return reserve_try_alloc(new_pages - nonanon_pages);
     100        } else if (new_pages < area->pages) {
     101                /* The area is shrinking. */
     102                if (new_pages >= nonanon_pages)
     103                        reserve_free(area->pages - new_pages);
     104                else if (area->pages > nonanon_pages)
     105                        reserve_free(nonanon_pages - new_pages);
     106        }
    88107       
    89108        return true;
     
    180199void elf_destroy(as_area_t *area)
    181200{
    182         /**
    183          * @todo:
    184          * Unreserve only how much was really reserved.
    185          */
    186         reserve_free(area->pages);
     201        elf_segment_header_t *entry = area->backend_data.segment;
     202        size_t nonanon_pages = ALIGN_DOWN(entry->p_filesz, PAGE_SIZE);
     203
     204        if (area->pages > nonanon_pages)
     205                reserve_free(area->pages - nonanon_pages);
    187206}
    188207
Note: See TracChangeset for help on using the changeset viewer.