Lines Matching refs:area

92 	area_id			area;
109 heap_area * area;
143 heap_area * areas; // sorted so that the desired area is always first
149 area_id area;
248 heap_area *area = heap->all_areas;
249 while (area) {
250 printf("\tarea %p: area: %" B_PRId32 "; base: 0x%08lx; size: %" B_PRIuSIZE "; "
252 area, area->area, area->base, area->size, area->page_count,
253 area->free_pages, area->free_page_count,
254 area->free_page_count == 1 ? "y" : "ies");
255 area = area->all_next;
287 heap_area *area = heap->all_areas;
288 while (area) {
290 for (uint32 i = 0; i < area->page_count; i++) {
291 heap_page *page = &area->page_table[i];
295 addr_t base = area->base + i * heap->page_size;
334 while (i + pageCount < area->page_count
335 && area->page_table[i + pageCount].in_use
336 && area->page_table[i + pageCount].bin_index
338 && area->page_table[i + pageCount].allocation_id
362 area = area->all_next;
382 heap_area *area = heap->all_areas;
383 while (area) {
385 for (uint32 i = 0; i < area->page_count; i++) {
386 heap_page *page = &area->page_table[i];
390 addr_t base = area->base + i * heap->page_size;
434 while (i + pageCount < area->page_count
435 && area->page_table[i + pageCount].in_use
436 && area->page_table[i + pageCount].bin_index
438 && area->page_table[i + pageCount].allocation_id
468 area = area->all_next;
488 heap_area *area = heap->all_areas;
489 while (area != NULL) {
493 heap_page *page = area->free_pages;
495 if ((addr_t)page < (addr_t)&area->page_table[0]
496 || (addr_t)page >= (addr_t)&area->page_table[area->page_count])
499 if (page->index >= area->page_count)
502 if ((addr_t)&area->page_table[page->index] != (addr_t)page)
518 if (area->free_page_count != freePageCount) {
520 area->free_page_count, freePageCount);
525 for (uint32 i = 0; i < area->page_count; i++) {
526 if (area->page_table[i].in_use)
531 if (freePageCount + usedPageCount != area->page_count) {
534 freePageCount, usedPageCount, area->page_count);
537 area = area->all_next;
541 area = heap->areas;
544 while (area != NULL) {
545 if (area->free_page_count < lastFreeCount)
546 panic("size ordering of area list broken\n");
548 if (area->prev != lastArea)
549 panic("area list entry has invalid prev link\n");
551 lastArea = area;
552 lastFreeCount = area->free_page_count;
553 area = area->next;
557 area = heap->all_areas;
558 while (area != NULL) {
559 if (lastArea != NULL && lastArea->base < area->base)
562 lastArea = area;
563 area = area->all_next;
573 area = heap->all_areas;
574 while (area) {
575 if (area == page->area)
577 area = area->all_next;
580 if (area == NULL) {
581 panic("page area not present in area list\n");
586 if ((addr_t)page < (addr_t)&area->page_table[0]
587 || (addr_t)page >= (addr_t)&area->page_table[area->page_count])
590 if (page->index >= area->page_count)
593 if ((addr_t)&area->page_table[page->index] != (addr_t)page) {
595 " (%p vs. %p)\n", &area->page_table[page->index],
618 addr_t pageBase = area->base + page->index * heap->page_size;
659 heap_area *area = (heap_area *)base;
660 area->area = areaID;
667 area->page_table = (heap_page *)base;
672 area->base = ROUNDUP(base, B_PAGE_SIZE);
673 area->size = size & ~(B_PAGE_SIZE - 1);
676 pageCount = area->size / heap->page_size;
677 area->page_count = pageCount;
680 memset((void *)area->page_table, 0, pageTableSize);
682 area->page_table[i].area = area;
683 area->page_table[i].index = i;
688 area->page_table[i - 1].next = &area->page_table[i];
689 area->page_table[i].prev = &area->page_table[i - 1];
691 area->free_pages = &area->page_table[0];
692 area->free_page_count = pageCount;
693 area->page_table[0].prev = NULL;
694 area->next = NULL;
699 // it's the only (empty) area in that heap
700 area->prev = NULL;
701 heap->areas = area;
703 // link in this area as the last one as it is completely empty
708 lastArea->next = area;
709 area->prev = lastArea;
712 // insert this area in the all_areas list so it stays ordered by base
713 if (heap->all_areas == NULL || heap->all_areas->base < area->base) {
714 area->all_next = heap->all_areas;
715 heap->all_areas = area;
718 while (insert->all_next && insert->all_next->base > area->base)
721 area->all_next = insert->all_next;
722 insert->all_next = area;
725 heap->total_pages += area->page_count;
726 heap->total_free_pages += area->free_page_count;
729 // this later on deletable area is yet empty - the empty count will be
730 // decremented as soon as this area is used for the first time
740 heap_remove_area(heap_allocator *heap, heap_area *area)
742 if (area->free_page_count != area->page_count) {
743 panic("tried removing heap area that has still pages in use");
747 if (area->prev == NULL && area->next == NULL) {
748 panic("tried removing the last non-full heap area");
752 if (heap->areas == area)
753 heap->areas = area->next;
754 if (area->prev != NULL)
755 area->prev->next = area->next;
756 if (area->next != NULL)
757 area->next->prev = area->prev;
759 if (heap->all_areas == area)
760 heap->all_areas = area->all_next;
764 if (previous->all_next == area) {
765 previous->all_next = area->all_next;
773 panic("removing heap area that is not in all list");
776 heap->total_pages -= area->page_count;
777 heap->total_free_pages -= area->free_page_count;
820 rw_lock_init(&heap->area_lock, "heap area lock");
829 heap_free_pages_added(heap_allocator *heap, heap_area *area, uint32 pageCount)
831 area->free_page_count += pageCount;
834 if (area->free_page_count == pageCount) {
835 // we need to add ourselfs to the area list of the heap
836 area->prev = NULL;
837 area->next = heap->areas;
838 if (area->next)
839 area->next->prev = area;
840 heap->areas = area;
842 // we might need to move back in the area list
843 if (area->next && area->next->free_page_count < area->free_page_count) {
845 heap_area *insert = area->next;
847 && insert->next->free_page_count < area->free_page_count)
850 if (area->prev)
851 area->prev->next = area->next;
852 if (area->next)
853 area->next->prev = area->prev;
854 if (heap->areas == area)
855 heap->areas = area->next;
857 area->prev = insert;
858 area->next = insert->next;
859 if (area->next)
860 area->next->prev = area;
861 insert->next = area;
865 if (area->free_page_count == area->page_count && area->area >= 0)
871 heap_free_pages_removed(heap_allocator *heap, heap_area *area, uint32 pageCount)
873 if (area->free_page_count == area->page_count && area->area >= 0) {
874 // this area was completely empty
878 area->free_page_count -= pageCount;
881 if (area->free_page_count == 0) {
882 // the area is now full so we remove it from the area list
883 if (area->prev)
884 area->prev->next = area->next;
885 if (area->next)
886 area->next->prev = area->prev;
887 if (heap->areas == area)
888 heap->areas = area->next;
889 area->next = area->prev = NULL;
891 // we might need to move forward in the area list
892 if (area->prev && area->prev->free_page_count > area->free_page_count) {
894 heap_area *insert = area->prev;
896 && insert->prev->free_page_count > area->free_page_count)
899 if (area->prev)
900 area->prev->next = area->next;
901 if (area->next)
902 area->next->prev = area->prev;
904 area->prev = insert->prev;
905 area->next = insert;
906 if (area->prev)
907 area->prev->next = area;
909 heap->areas = area;
910 insert->prev = area;
946 heap_area *area = heap->areas;
947 while (area) {
948 if (area->free_page_count < pageCount) {
949 area = area->next;
955 const uint32 lastValid = area->page_count - pageCount + 1;
958 firstValid = (ROUNDUP(area->base, alignment) - area->base)
965 if (area->page_table[i].in_use)
971 if (area->page_table[i + j].in_use) {
983 area = area->next;
988 heap_page *page = &area->page_table[i];
992 heap_unlink_page(page, &area->free_pages);
999 heap_free_pages_removed(heap, area, pageCount);
1000 return &area->page_table[first];
1038 addr_t address = firstPage->area->base + firstPage->index * heap->page_size;
1056 heap_area *area = heap->areas;
1057 if (area == NULL) {
1065 page = area->free_pages;
1066 area->free_pages = page->next;
1070 heap_free_pages_removed(heap, area, 1);
1094 address = (void *)(page->area->base + page->index * heap->page_size
1182 heap_area *area = heap->all_areas;
1183 while (area) {
1185 // base at the top, we need only find the first area with a base
1187 if (area->base <= (addr_t)address) {
1188 if ((addr_t)address >= area->base + area->size) {
1194 // this area contains the allocation, we're done searching
1198 area = area->all_next;
1201 if (area == NULL) {
1208 heap_page *page = &area->page_table[((addr_t)address - area->base)
1220 addr_t pageBase = area->base + page->index * heap->page_size;
1283 heap_link_page(page, &area->free_pages);
1284 heap_free_pages_added(heap, area, 1);
1316 uint32 maxPages = area->page_count - page->index;
1332 heap_link_page(&page[i], &area->free_pages);
1363 heap_free_pages_added(heap, area, pageCount);
1372 area = heap->areas;
1373 while (area != NULL && heap->empty_areas > 1) {
1374 heap_area *next = area->next;
1375 if (area->area >= 0
1376 && area->free_page_count == area->page_count
1377 && heap_remove_area(heap, area) == B_OK) {
1378 delete_area(area->area);
1382 area = next;
1395 heap_area *area = heap->all_areas;
1396 while (area) {
1398 // base at the top, we need only find the first area with a base
1401 if (area->base <= (addr_t)address) {
1402 if ((addr_t)address >= area->base + area->size) {
1408 // this area contains the allocation, we're done searching
1412 area = area->all_next;
1415 if (area == NULL) {
1422 heap_page *page = &area->page_table[((addr_t)address - area->base)
1442 uint32 maxPages = area->page_count - page->index;
1513 heap_area *area = heap->all_areas;
1514 while (area) {
1516 // base at the top, we need only find the first area with a base
1518 if (area->base <= (addr_t)address) {
1519 if ((addr_t)address >= area->base + area->size) {
1525 // this area contains the allocation, we're done searching
1529 area = area->all_next;
1532 if (area == NULL) {
1537 heap_page *page = &area->page_table[((addr_t)address - area->base)
1547 addr_t pageBase = area->base + page->index * heap->page_size;
1578 uint32 maxPages = area->page_count - page->index;
1623 INFO(("heap: couldn't allocate heap area \"%s\"\n", name));
1731 area_id allocationArea = create_area("guarded area", &address,
1734 panic("heap: failed to create area for guarded allocation of %" B_PRIuSIZE
1748 info->area = allocationArea;
1756 // is at the end of the usable space of the requested area
1759 INFO(("heap: allocated area %" B_PRId32 " for guarded allocation of %" B_PRIuSIZE " bytes\n",
1779 // or maybe it was a huge allocation using an area
1781 area_id area = area_for(address);
1782 if (area >= B_OK && get_area_info(area, &areaInfo) == B_OK) {
1786 if (info->magic == kAreaAllocationMagic && info->area == area
1853 area_id allocationArea = create_area("memalign area", &address,
1856 panic("heap: failed to create area for huge allocation of %" B_PRIuSIZE
1863 info->area = allocationArea;
1877 INFO(("heap: allocated area %" B_PRId32 " for huge allocation of %" B_PRIuSIZE " bytes\n",
1892 // add new area and try again
1893 heap_create_new_heap_area(heap, "additional heap area", HEAP_GROW_SIZE);
1934 // or maybe it was a huge allocation using an area
1936 area_id area = area_for(address);
1937 if (area >= B_OK && get_area_info(area, &areaInfo) == B_OK) {
1941 if (info->magic == kAreaAllocationMagic && info->area == area
1944 delete_area(area);
1945 INFO(("free(): freed huge allocation by deleting area %" B_PRId32 "\n",
1946 area));
1976 // or maybe it was a huge allocation using an area
1978 area_id area = area_for(address);
1979 if (area >= B_OK && get_area_info(area, &areaInfo) == B_OK) {
1983 if (info->magic == kAreaAllocationMagic && info->area == area
1995 " fits in old area %" B_PRId32 " with "
1997 newSize, area, available, newAddress));
2011 " fits in old area %" B_PRId32 " with "
2013 newSize, area, available));
2019 // have to allocate/copy/free - TODO maybe resize the area instead?
2028 delete_area(area);
2030 " and deleted old area %" B_PRId32 "\n",
2031 newAddress, newSize, area));