Changeset eef75f6 in mainline


Ignore:
Timestamp:
2005-12-05T19:09:14Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
95498e5
Parents:
61e6c39
Message:

Buddy allocator cleanup and fixes.

  • Add some comments.
  • Update zone information on frames allocation/deallocation.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • arch/ia64/Makefile.inc

    r61e6c39 reef75f6  
    3939#
    4040
    41 CFLAGS += -mconstant-gp -fno-unwind-tables -minline-int-divide-min-latency
     41CFLAGS += -mconstant-gp -fno-unwind-tables
    4242LFLAGS += -EL
    4343AFLAGS += -mconstant-gp
  • generic/include/mm/frame.h

    r61e6c39 reef75f6  
    5454        __address base;         /**< physical address of the first frame in the frames array */
    5555        frame_t *frames;        /**< array of frame_t structures in this zone */
    56         count_t free_count;     /**< number of frame_t structures in free list */
    57         count_t busy_count;     /**< number of frame_t structures not in free list */
     56        count_t free_count;     /**< number of free frame_t structures */
     57        count_t busy_count;     /**< number of busy frame_t structures */
    5858       
    5959        buddy_system_t * buddy_system; /**< buddy system for the zone */
  • generic/src/mm/frame.c

    r61e6c39 reef75f6  
    4444link_t zone_head;                /**< list of all zones in the system */
    4545
     46/** Blacklist containing non-available areas of memory.
     47 *
     48 * This blacklist is used to exclude frames that cannot be allocated
     49 * (e.g. kernel memory) from available memory map.
     50 */
    4651region_t zone_blacklist[ZONE_BLACKLIST_SIZE];
    4752count_t zone_blacklist_count = 0;
     
    123128
    124129        /* Allocate frames from zone buddy system */
    125         cur = buddy_system_alloc(zone->buddy_system, order);
    126        
    127         /* frame will be actually a first frame of the block */
    128         frame = list_get_instance(cur, frame_t, buddy_link);
     130        tmp = buddy_system_alloc(zone->buddy_system, order);
     131       
     132        ASSERT(tmp);
     133       
     134        /* Update zone information. */
     135        zone->free_count -= (1 << order);
     136        zone->busy_count += (1 << order);
     137
     138        /* Frame will be actually a first frame of the block. */
     139        frame = list_get_instance(tmp, frame_t, buddy_link);
    129140       
    130141        /* get frame address */
    131142        v = FRAME2ADDR(zone, frame);
    132143
    133         if (flags & FRAME_KA)
    134                 v = PA2KA(v);
    135        
    136144        spinlock_unlock(&zone->lock);
    137145        spinlock_unlock(&zone_head_lock);
    138146        interrupts_restore(ipl);
     147
     148
     149        if (flags & FRAME_KA)
     150                v = PA2KA(v);
     151       
    139152        return v;
    140 
    141153}
    142154
     
    191203                buddy_system_free(zone->buddy_system, &frame->buddy_link);
    192204        }
    193        
    194         spinlock_unlock(&zone->lock);   
    195        
     205
     206        /* Update zone information. */
     207        zone->free_count += (1 << frame->buddy_order);
     208        zone->busy_count -= (1 << frame->buddy_order);
     209       
     210        spinlock_unlock(&zone->lock);
    196211        spinlock_unlock(&zone_head_lock);
    197212        interrupts_restore(ipl);
     
    231246}
    232247
    233 
     248/** Create frame zones in region of available memory.
     249 *
     250 * Avoid any black listed areas of non-available memory.
     251 * Assume that the black listed areas cannot overlap
     252 * one another or cross available memory region boundaries.
     253 *
     254 * @param base Base address of available memory region.
     255 * @param size Size of the region.
     256 */
    234257void zone_create_in_region(__address base, size_t size) {
    235258        int i;
     
    269292
    270293
    271 
    272294/** Create frame zone
    273295 *
     
    374396 */
    375397link_t * zone_buddy_find_buddy(buddy_system_t *b, link_t * block) {
    376         frame_t * frame, * f;
     398        frame_t * frame;
    377399        zone_t * zone;
    378         link_t * cur;
    379400        count_t index;
    380401        bool is_left, is_right;
     
    383404        zone = (zone_t *) b->data;
    384405       
    385         /*
    386          * (FRAME_INDEX % 2^(ORDER+1)) == 0 ===> LEFT BUDDY
    387          * (FRAME_INDEX % 2^(ORDER+1)) == 2^(ORDER) ===> RIGHT BUDDY
    388          */
    389 
    390406        is_left = IS_BUDDY_LEFT_BLOCK(zone, frame);
    391407        is_right = !is_left;
     
    407423        }
    408424       
    409         return NULL;
    410        
     425        return NULL;   
    411426}
    412427
Note: See TracChangeset for help on using the changeset viewer.