Changeset 874878a in mainline
- Timestamp:
- 2006-02-09T09:33:21Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bfb87df
- Parents:
- 7e4e532
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/mm/frame.c
r7e4e532 r874878a 576 576 * We have several cases 577 577 * - the conf. data is outside of zone -> exit, shall we call frame_free?? 578 * - the conf. data was created by zone_create -> free every frame 579 * - the conf. data was created by merge in frame_alloc -> free first frame 580 * (the difference is in order) 578 * - the conf. data was created by zone_create or 579 * updated with reduce_region -> free every frame 580 * 581 * @param newzone The actual zone where freeing should occur 582 * @param oldzone Pointer to old zone configuration data that should 583 * be freed from new zone 581 584 */ 582 585 static void return_config_frames(zone_t *newzone, zone_t *oldzone) … … 594 597 595 598 frame = &newzone->frames[pfn - newzone->base]; 596 if (frame->buddy_order) { 597 /* Normally zone config data is hidden, show it again */ 598 newzone->busy_count += (1 << frame->buddy_order); 599 zone_frame_free(newzone, pfn - newzone->base); 600 return; 601 } 599 ASSERT(!frame->buddy_order); 602 600 603 601 for (i=0; i < cframes; i++) { 604 602 newzone->busy_count++; 605 603 zone_frame_free(newzone, pfn+i-newzone->base); 604 } 605 } 606 607 608 /** Reduce allocated block to count of order 0 frames 609 * 610 * The allocated block need 2^order frames of space. Reduce all frames 611 * in block to order 0 and free the unneded frames. This means, that 612 * when freeing the block, you have to free every frame from block. 613 * 614 * @param zone 615 * @param frame_idx Index to block 616 * @param count Allocated space in block 617 */ 618 static void zone_reduce_region(zone_t *zone, pfn_t frame_idx, count_t count) 619 { 620 count_t i; 621 __u8 order; 622 frame_t *frame; 623 624 ASSERT(frame_idx+count < zone->count); 625 626 order = zone->frames[frame_idx].buddy_order; 627 ASSERT((1 << order) >= count); 628 629 /* Reduce all blocks to order 0 */ 630 for (i=0; i < (1 << order); i++) { 631 frame = &zone->frames[i + frame_idx]; 632 frame->buddy_order = 0; 633 if (! frame->refcount) 634 frame->refcount = 1; 635 ASSERT(frame->refcount == 1); 636 } 637 /* Free unneeded frames */ 638 for (i=count; i < (1 << order); i++) { 639 zone_frame_free(zone, i + frame_idx); 606 640 } 607 641 } … … 654 688 _zone_merge(newzone, zone1, zone2); 655 689 690 /* Free unneeded config frames */ 691 zone_reduce_region(newzone, pfn - newzone->base, cframes); 656 692 /* Subtract zone information from busy frames */ 657 newzone->busy_count -= (1 << order); 658 693 newzone->busy_count -= cframes; 694 695 /* Replace existing zones in zoneinfo list */ 659 696 zones.info[z1] = newzone; 660 697 for (i=z2+1;i < zones.count;i++) … … 984 1021 zone = zones.info[i]; 985 1022 spinlock_lock(&zone->lock); 986 printf("%d 1023 printf("%d: %L\t%d\t\t%d\n",i,PFN2ADDR(zone->base), 987 1024 zone->free_count, zone->busy_count); 988 1025 spinlock_unlock(&zone->lock); … … 1005 1042 1006 1043 for (i=0;i < zones.count; i++) { 1007 if (i == num || zones.info[i]->base == ADDR2PFN(num)) {1044 if (i == num || PFN2ADDR(zones.info[i]->base) == num) { 1008 1045 zone = zones.info[i]; 1009 1046 break; -
test/mm/falloc1/test.c
r7e4e532 r874878a 41 41 42 42 void test(void) { 43 __address * frames = (__address *) malloc(MAX_FRAMES*sizeof(__address)); 43 __address * frames = (__address *) malloc(MAX_FRAMES*sizeof(__address), 44 0); 44 45 int results[MAX_ORDER+1]; 45 46
Note:
See TracChangeset
for help on using the changeset viewer.