Changeset 874878a in mainline


Ignore:
Timestamp:
2006-02-09T09:33:21Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bfb87df
Parents:
7e4e532
Message:

Use less frames for zone configuration data after merge.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • generic/src/mm/frame.c

    r7e4e532 r874878a  
    576576 * We have several cases
    577577 * - 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
    581584 */
    582585static void return_config_frames(zone_t *newzone, zone_t *oldzone)
     
    594597
    595598        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);
    602600
    603601        for (i=0; i < cframes; i++) {
    604602                newzone->busy_count++;
    605603                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 */
     618static 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);
    606640        }
    607641}
     
    654688        _zone_merge(newzone, zone1, zone2);
    655689
     690        /* Free unneeded config frames */
     691        zone_reduce_region(newzone, pfn - newzone->base,  cframes);
    656692        /* 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 */
    659696        zones.info[z1] = newzone;
    660697        for (i=z2+1;i < zones.count;i++)
     
    9841021                zone = zones.info[i];
    9851022                spinlock_lock(&zone->lock);
    986                 printf("%d  %L\t%d\t\t%d\n",i,PFN2ADDR(zone->base),
     1023                printf("%d: %L\t%d\t\t%d\n",i,PFN2ADDR(zone->base),
    9871024                       zone->free_count, zone->busy_count);
    9881025                spinlock_unlock(&zone->lock);
     
    10051042
    10061043        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) {
    10081045                        zone = zones.info[i];
    10091046                        break;
  • test/mm/falloc1/test.c

    r7e4e532 r874878a  
    4141
    4242void test(void) {
    43         __address * frames = (__address *) malloc(MAX_FRAMES*sizeof(__address));
     43        __address * frames = (__address *) malloc(MAX_FRAMES*sizeof(__address),
     44                                                  0);
    4445        int results[MAX_ORDER+1];
    4546       
Note: See TracChangeset for help on using the changeset viewer.