Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 720 → Rev 721

/kernel/branches/falloc_bad/test/mm/falloc1/test.c
33,7 → 33,7
#include <arch/types.h>
#include <debug.h>
 
#define MAX_FRAMES 1024
#define MAX_FRAMES 2048
#define MAX_ORDER 8
#define TEST_RUNS 4
 
52,7 → 52,12
printf("Allocating %d frames blocks ... ", 1<<order);
allocated = 0;
for (i=0;i<MAX_FRAMES>>order;i++) {
frames[allocated] = frame_alloc(FRAME_NON_BLOCKING,order, &status);
frames[allocated] = frame_alloc(FRAME_NON_BLOCKING, order, &status);
if (frames[allocated] % (FRAME_SIZE << order) != 0) {
panic("Test failed. Block at address %X (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
}
if (status == 0) {
allocated++;
} else {
/kernel/branches/falloc_bad/generic/include/mm/frame.h
49,10 → 49,13
#define FRAME2ADDR(zone, frame) ((zone)->base + ((frame) - (zone)->frames) * FRAME_SIZE)
#define ADDR2FRAME(zone, addr) (&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
#define FRAME_INDEX(zone, frame) ((index_t)((frame) - (zone)->frames))
#define FRAME_INDEX_ABS(zone, frame) (((index_t)((frame) - (zone)->frames)) + (zone)->base_index)
#define FRAME_INDEX_VALID(zone, index) (((index) >= 0) && ((index) < ((zone)->free_count + (zone)->busy_count)))
#define IS_BUDDY_ORDER_OK(index, order) ((~(((__native) -1) << (order)) & (index)) == 0)
#define IS_BUDDY_LEFT_BLOCK(zone, frame) (((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
#define IS_BUDDY_RIGHT_BLOCK(zone, frame) (((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
#define IS_BUDDY_LEFT_BLOCK_ABS(zone, frame) (((FRAME_INDEX_ABS((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
#define IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame) (((FRAME_INDEX_ABS((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
 
#define ZONE_BLACKLIST_SIZE 4
 
61,6 → 64,7
 
SPINLOCK_DECLARE(lock); /**< this lock protects everything below */
__address base; /**< physical address of the first frame in the frames array */
index_t base_index; /**< frame index offset of the zone base */
frame_t *frames; /**< array of frame_t structures in this zone */
count_t free_count; /**< number of free frame_t structures */
count_t busy_count; /**< number of busy frame_t structures */
/kernel/branches/falloc_bad/generic/src/mm/frame.c
133,7 → 133,6
goto loop;
}
 
/* Allocate frames from zone buddy system */
tmp = buddy_system_alloc(zone->buddy_system, order);
160,7 → 159,7
ASSERT(status != NULL);
*status = FRAME_OK;
}
printf("frame_alloc() returns %P\n", v);
return v;
}
 
179,6 → 178,8
zone_t *z;
zone_t *zone = NULL;
frame_t *frame;
int order;
ASSERT(addr % FRAME_SIZE == 0);
ipl = interrupts_disable();
209,6 → 210,9
ASSERT(zone != NULL);
frame = ADDR2FRAME(zone, addr);
/* remember frame order */
order = frame->buddy_order;
 
ASSERT(frame->refcount);
 
217,8 → 221,8
}
 
/* Update zone information. */
zone->free_count += (1 << frame->buddy_order);
zone->busy_count -= (1 << frame->buddy_order);
zone->free_count += (1 << order);
zone->busy_count -= (1 << order);
spinlock_unlock(&zone->lock);
spinlock_unlock(&zone_head_lock);
321,6 → 325,8
spinlock_initialize(&z->lock, "zone_lock");
z->base = start;
z->base_index = start / FRAME_SIZE;
z->flags = flags;
 
z->free_count = cnt;
348,6 → 354,7
z->frames[i].refcount = 0;
buddy_system_free(z->buddy_system, &z->frames[i].buddy_link);
}
}
return z;
}
400,11 → 407,11
 
frame = list_get_instance(block, frame_t, buddy_link);
zone = (zone_t *) b->data;
ASSERT(IS_BUDDY_ORDER_OK(FRAME_INDEX_ABS(zone, frame), frame->buddy_order));
ASSERT(IS_BUDDY_ORDER_OK(FRAME_INDEX(zone, frame), frame->buddy_order));
is_left = IS_BUDDY_LEFT_BLOCK(zone, frame);
is_right = IS_BUDDY_RIGHT_BLOCK(zone, frame);
is_left = IS_BUDDY_LEFT_BLOCK_ABS(zone, frame);
is_right = IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame);
ASSERT(is_left ^ is_right);
/kernel/branches/falloc_bad/arch/mips32/src/mm/frame.c
50,5 → 50,5
arc_frame_init();
else
zone_create_in_region(KA2PA(KERNEL_LOAD_ADDRESS),
config.memory_size & ~(FRAME_SIZE-1));
(config.memory_size & ~(FRAME_SIZE-1)));
}