Subversion Repositories HelenOS

Compare Revisions

Regard whitespace Rev 2027 → Rev 2028

/trunk/kernel/test/mm/falloc2.def
0,0 → 1,6
{
"falloc2",
"Frame allocator test 2",
&test_falloc2,
true
},
/trunk/kernel/test/mm/slab1.def
0,0 → 1,6
{
"slab1",
"SLAB test 1",
&test_slab1,
true
},
/trunk/kernel/test/mm/purge1.def
0,0 → 1,8
#ifdef ia64
{
"purge1",
"Itanium TLB purge test",
&test_purge1,
true
},
#endif
/trunk/kernel/test/mm/slab2.def
0,0 → 1,6
{
"slab2",
"SLAB test 2",
&test_slab2,
true
},
/trunk/kernel/test/mm/falloc1.c
25,6 → 25,7
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <print.h>
#include <test.h>
#include <mm/page.h>
35,18 → 36,11
#include <debug.h>
#include <align.h>
 
#ifdef CONFIG_BENCH
#include <arch/cycle.h>
#endif
 
#define MAX_FRAMES 1024
#define MAX_ORDER 8
#define TEST_RUNS 2
 
void test_falloc1(void) {
#ifdef CONFIG_BENCH
uint64_t t0 = get_cycle();
#endif
char * test_falloc1(void) {
uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES*sizeof(uintptr_t), 0);
int results[MAX_ORDER+1];
54,7 → 48,8
int allocated;
 
ASSERT(TEST_RUNS > 1);
ASSERT(frames != NULL)
if (frames == NULL)
return "Unable to allocate frames";
 
for (run = 0; run < TEST_RUNS; run++) {
for (order = 0; order <= MAX_ORDER; order++) {
64,12 → 59,13
frames[allocated] = (uintptr_t) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
panic("Test failed. Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
printf("Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
return "Test failed";
}
if (frames[allocated]) {
if (frames[allocated])
allocated++;
} else {
else {
printf("done. ");
break;
}
78,16 → 74,14
printf("%d blocks allocated.\n", allocated);
if (run) {
if (results[order] != allocated) {
panic("Test failed. Frame leak possible.\n");
}
if (results[order] != allocated)
return "Possible frame leak";
} else
results[order] = allocated;
printf("Deallocating ... ");
for (i = 0; i < allocated; i++) {
for (i = 0; i < allocated; i++)
frame_free(KA2PA(frames[i]));
}
printf("done.\n");
}
}
94,10 → 88,5
 
free(frames);
printf("Test passed.\n");
#ifdef CONFIG_BENCH
uint64_t dt = get_cycle() - t0;
printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
#endif
return NULL;
}
 
/trunk/kernel/test/mm/falloc2.c
25,6 → 25,7
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <print.h>
#include <test.h>
#include <mm/page.h>
38,10 → 39,6
#include <memstr.h>
#include <arch.h>
 
#ifdef CONFIG_BENCH
#include <arch/cycle.h>
#endif
 
#define MAX_FRAMES 256
#define MAX_ORDER 8
 
48,12 → 45,10
#define THREAD_RUNS 1
#define THREADS 8
 
static void falloc(void * arg);
static void failed(void);
 
static atomic_t thread_count;
static atomic_t thread_fail;
 
void falloc(void * arg)
static void falloc(void * arg)
{
int order, run, allocated, i;
uint8_t val = THREAD->tid % THREADS;
60,7 → 55,12
index_t k;
uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC);
ASSERT(frames != NULL);
if (frames == NULL) {
printf("Thread #%d (cpu%d): Unable to allocate frames\n", THREAD->tid, CPU->id);
atomic_inc(&thread_fail);
atomic_dec(&thread_count);
return;
}
thread_detach(THREAD);
 
73,10 → 73,9
if (frames[allocated]) {
memsetb(frames[allocated], FRAME_SIZE << order, val);
allocated++;
} else {
} else
break;
}
}
printf("Thread #%d (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
 
printf("Thread #%d (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id);
84,7 → 83,8
for (k = 0; k <= ((FRAME_SIZE << order) - 1); k++) {
if (((uint8_t *) frames[i])[k] != val) {
printf("Thread #%d (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
failed();
atomic_inc(&thread_fail);
goto cleanup;
}
}
frame_free(KA2PA(frames[i]));
93,42 → 93,35
}
}
cleanup:
free(frames);
printf("Thread #%d (cpu%d): Exiting\n", THREAD->tid, CPU->id);
atomic_dec(&thread_count);
}
 
 
void failed(void)
char * test_falloc2(void)
{
panic("Test failed.\n");
}
unsigned int i;
 
 
void test_falloc2(void)
{
#ifdef CONFIG_BENCH
uint64_t t0 = get_cycle();
#endif
int i;
 
atomic_set(&thread_count, THREADS);
atomic_set(&thread_fail, 0);
for (i = 0; i < THREADS; i++) {
thread_t * thrd;
thrd = thread_create(falloc, NULL, TASK, 0, "falloc");
if (thrd)
thread_t * thrd = thread_create(falloc, NULL, TASK, 0, "falloc");
if (!thrd) {
printf("Could not create thread %d\n", i);
break;
}
thread_ready(thrd);
else
failed();
}
while (thread_count.count)
;
while (atomic_get(&thread_count) > 0) {
printf("Threads left: %d\n", atomic_get(&thread_count));
thread_sleep(1);
}
 
printf("Test passed.\n");
#ifdef CONFIG_BENCH
uint64_t dt = get_cycle() - t0;
printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
#endif
if (atomic_get(&thread_fail) == 0)
return NULL;
return "Test failed";
}
/trunk/kernel/test/mm/slab1.c
34,10 → 34,6
#include <panic.h>
#include <memstr.h>
 
#ifdef CONFIG_BENCH
#include <arch/cycle.h>
#endif
 
#define VAL_COUNT 1024
 
static void * data[VAL_COUNT];
103,14 → 99,13
testit(16385, 128);
}
 
 
#define THREADS 6
#define THR_MEM_COUNT 1024
#define THR_MEM_SIZE 128
 
void * thr_data[THREADS][THR_MEM_COUNT];
slab_cache_t *thr_cache;
semaphore_t thr_sem;
static void * thr_data[THREADS][THR_MEM_COUNT];
static slab_cache_t *thr_cache;
static semaphore_t thr_sem;
 
static void slabtest(void *data)
{
145,7 → 140,8
semaphore_initialize(&thr_sem,0);
for (i=0; i<THREADS; i++) {
if (!(t = thread_create(slabtest, (void *)(unative_t)i, TASK, 0, "slabtest")))
panic("could not create thread\n");
printf("Could not create thread %d\n", i);
else
thread_ready(t);
}
 
157,15 → 153,10
}
 
void test_slab1(void)
char * test_slab1(void)
{
#ifdef CONFIG_BENCH
uint64_t t0 = get_cycle();
#endif
testsimple();
testthreads();
#ifdef CONFIG_BENCH
uint64_t dt = get_cycle() - t0;
printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
#endif
return NULL;
}
/trunk/kernel/test/mm/purge1.c
26,6 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifdef ia64
 
#include <print.h>
#include <test.h>
#include <mm/page.h>
36,12 → 38,10
#include <arch/types.h>
#include <debug.h>
 
#ifdef ia64
 
extern void tlb_invalidate_all(void);
extern void tlb_invalidate_pages(asid_t asid, uintptr_t va, count_t cnt);
 
void test(void)
char * test(void)
{
tlb_entry_t entryi;
tlb_entry_t entryd;
80,13 → 80,8
tlb_invalidate_pages(8,0x0c000,14);
/*tlb_invalidate_all();*/
}
 
#else
 
void test_purge1(void)
{
printf("This test is availaible only on IA64 platform.\n");
return NULL;
}
 
#endif
/trunk/kernel/test/mm/slab2.c
37,10 → 37,6
#include <synch/condvar.h>
#include <synch/mutex.h>
 
#ifdef CONFIG_BENCH
#include <arch/cycle.h>
#endif
 
#define ITEM_SIZE 256
 
/** Fill memory with 2 caches, when allocation fails,
172,13 → 168,11
data = new;
}
 
 
printf("Thread #%d finished\n", THREAD->tid);
slab_print_list();
semaphore_up(&thr_sem);
}
 
 
static void multitest(int size)
{
/* Start 8 threads that just allocate as much as possible,
197,7 → 191,8
semaphore_initialize(&thr_sem,0);
for (i=0; i<THREADS; i++) {
if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest")))
panic("could not create thread\n");
printf("Could not create thread %d\n", i);
else
thread_ready(t);
}
thread_sleep(1);
210,12 → 205,8
printf("Stress test complete.\n");
}
 
void test_slab2(void)
char * test_slab2(void)
{
#ifdef CONFIG_BENCH
uint64_t t0 = get_cycle();
#endif
 
printf("Running reclaim single-thread test .. pass1\n");
totalmemtest();
printf("Running reclaim single-thread test .. pass2\n");
227,8 → 218,5
multitest(8192);
printf("All done.\n");
 
#ifdef CONFIG_BENCH
uint64_t dt = get_cycle() - t0;
printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
#endif
return NULL;
}
/trunk/kernel/test/mm/mapping1.def
0,0 → 1,6
{
"mapping1",
"Mapping test",
&test_mapping1,
false
},
/trunk/kernel/test/mm/mapping1.c
25,6 → 25,7
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <print.h>
#include <test.h>
#include <mm/page.h>
34,10 → 35,6
#include <arch/types.h>
#include <debug.h>
 
#ifdef CONFIG_BENCH
#include <arch/cycle.h>
#endif
 
#define PAGE0 0x10000000
#define PAGE1 (PAGE0+PAGE_SIZE)
 
44,16 → 41,11
#define VALUE0 0x01234567
#define VALUE1 0x89abcdef
 
void test_mapping1(void)
char * test_mapping1(void)
{
#ifdef CONFIG_BENCH
uint64_t t0 = get_cycle();
#endif
uintptr_t frame0, frame1;
uint32_t v0, v1;
 
printf("Memory management test mapping #1\n");
 
frame0 = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_KA);
frame1 = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_KA);
 
87,9 → 79,5
ASSERT(v0 == 0);
ASSERT(v1 == 0);
printf("Test passed.\n");
#ifdef CONFIG_BENCH
uint64_t dt = get_cycle() - t0;
printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
#endif
return NULL;
}
/trunk/kernel/test/mm/falloc1.def
0,0 → 1,6
{
"falloc1",
"Frame allocator test 1",
&test_falloc1,
true
},