Changeset 89bcb520 in mainline
- Timestamp:
- 2011-04-16T16:53:49Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 28295955
- Parents:
- fe754c8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/frame.c
rfe754c8 r89bcb520 45 45 #include <typedefs.h> 46 46 #include <mm/frame.h> 47 #include <mm/reserve.h> 47 48 #include <mm/as.h> 48 49 #include <panic.h> … … 472 473 * @param frame_idx Frame index relative to zone. 473 474 * 474 */ 475 NO_TRACE static void zone_frame_free(zone_t *zone, size_t frame_idx) 475 * @return Number of freed frames. 476 * 477 */ 478 NO_TRACE static size_t zone_frame_free(zone_t *zone, size_t frame_idx) 476 479 { 477 480 ASSERT(zone_flags_available(zone->flags)); 478 481 479 482 frame_t *frame = &zone->frames[frame_idx]; 480 481 /* Remember frame order */ 482 uint8_t order = frame->buddy_order; 483 size_t size = 1 << frame->buddy_order; 483 484 484 485 ASSERT(frame->refcount); … … 488 489 489 490 /* Update zone information. */ 490 zone->free_count += (1 << order); 491 zone->busy_count -= (1 << order); 492 } 491 zone->free_count += size; 492 zone->busy_count -= size; 493 } 494 495 return size; 493 496 } 494 497 … … 645 648 for (i = 0; i < cframes; i++) { 646 649 zones.info[znum].busy_count++; 647 zone_frame_free(&zones.info[znum],650 (void) zone_frame_free(&zones.info[znum], 648 651 pfn - zones.info[znum].base + i); 649 652 } … … 683 686 /* Free unneeded frames */ 684 687 for (i = count; i < (size_t) (1 << order); i++) 685 zone_frame_free(&zones.info[znum], i + frame_idx);688 (void) zone_frame_free(&zones.info[znum], i + frame_idx); 686 689 } 687 690 … … 997 1000 size_t hint = pzone ? (*pzone) : 0; 998 1001 1002 /* 1003 * If not told otherwise, we must first reserve the memory. 1004 */ 1005 if (!(flags & FRAME_NO_RESERVE)) { 1006 if (flags & FRAME_ATOMIC) { 1007 if (!reserve_try_alloc(size)) 1008 return NULL; 1009 } else { 1010 reserve_force_alloc(size); 1011 } 1012 } 1013 999 1014 loop: 1000 1015 irq_spinlock_lock(&zones.lock, true); … … 1031 1046 if (flags & FRAME_ATOMIC) { 1032 1047 irq_spinlock_unlock(&zones.lock, true); 1048 if (!(flags & FRAME_NO_RESERVE)) 1049 reserve_free(size); 1033 1050 return NULL; 1034 1051 } … … 1108 1125 void frame_free_generic(uintptr_t frame, frame_flags_t flags) 1109 1126 { 1127 size_t size; 1128 1110 1129 irq_spinlock_lock(&zones.lock, true); 1111 1130 … … 1115 1134 pfn_t pfn = ADDR2PFN(frame); 1116 1135 size_t znum = find_zone(pfn, 1, 0); 1136 1117 1137 1118 1138 ASSERT(znum != (size_t) -1); 1119 1139 1120 zone_frame_free(&zones.info[znum], pfn - zones.info[znum].base);1140 size = zone_frame_free(&zones.info[znum], pfn - zones.info[znum].base); 1121 1141 1122 1142 irq_spinlock_unlock(&zones.lock, true); … … 1134 1154 } 1135 1155 mutex_unlock(&mem_avail_mtx); 1156 1157 if (!(flags & FRAME_NO_RESERVE)) 1158 reserve_free(size); 1136 1159 } 1137 1160
Note:
See TracChangeset
for help on using the changeset viewer.