diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 7132026b..49602774 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -235,8 +235,9 @@ void irq_handler(struct state *s) void (*handler) (struct state * s); // at first, we check our work queues - check_workqueues(); - + if( s->int_no == 124 ) { + check_workqueues(); + } /* * Find out if we have a custom handler to run for this * IRQ and then finally, run it diff --git a/arch/x86/kernel/timer.c b/arch/x86/kernel/timer.c index 73c83a51..995fb747 100644 --- a/arch/x86/kernel/timer.c +++ b/arch/x86/kernel/timer.c @@ -81,7 +81,7 @@ void timer_wait(unsigned int ticks) uint64_t eticks = timer_ticks + ticks; while (timer_ticks < eticks) { - check_workqueues(); + //check_workqueues(); // recheck break condition if (timer_ticks >= eticks) diff --git a/arch/x86/scc/iRCCE_mailbox.c b/arch/x86/scc/iRCCE_mailbox.c index b01907d0..d2d946e1 100644 --- a/arch/x86/scc/iRCCE_mailbox.c +++ b/arch/x86/scc/iRCCE_mailbox.c @@ -39,6 +39,7 @@ #ifdef CONFIG_ROCKCREEK #include +#include // forward declaration static int iRCCE_mailbox_close_one(int rank, int check); @@ -90,7 +91,8 @@ void iRCCE_mailbox_print_header(iRCCE_MAIL_HEADER* header) { static int iRCCE_mail_fetch( int rank // rank from whom to empty mailbox ) { - + /* interrupts should already be disabled! */ + iRCCE_MAIL_HEADER* header; // check for memory in garbage collection or allocate new @@ -160,6 +162,10 @@ static int iRCCE_mail_fetch( //------------------------------------------------------------------------------ static int iRCCE_mailbox_check() { int i,j; + uint32_t flags; + + /* disable interrupts */ + flags = irq_nested_disable(); for( j=1; jnext = NULL; *header = help_header; + + /* enable interrupts */ + irq_nested_enable(flags); + return iRCCE_SUCCESS; + } } @@ -255,6 +273,11 @@ int iRCCE_mail_recv( int iRCCE_mail_release( iRCCE_MAIL_HEADER** header ) { + uint32_t flags; + + /* disable interrupts */ + flags = irq_nested_disable(); + // put header in garbage collection if( (iRCCE_mail_garbage.first == NULL) && (iRCCE_mail_garbage.last == NULL ) ) { @@ -270,6 +293,10 @@ int iRCCE_mail_release( // reset header *header = NULL; + + /* enable interrupts */ + irq_nested_enable(flags); + return iRCCE_SUCCESS; } @@ -309,6 +336,7 @@ int iRCCE_mail_send( char* payload, // pointer to buffer for header payload int dest // UE that will receive the header ) { + uint32_t flags; // check for an attempt to send in own mailbox if( dest == RCCE_IAM ) { @@ -344,6 +372,9 @@ int iRCCE_mail_send( RC_cache_invalidate(); iRCCE_memcpy_put( (void*)iRCCE_mailbox_send[dest], (void*)&header, RCCE_LINE_SIZE ); + + /* disable interrupts */ + flags = irq_nested_disable(); // set senders flag RC_cache_invalidate(); @@ -351,6 +382,9 @@ int iRCCE_mail_send( *(int *)RCCE_fool_write_combine_buffer = 1; RC_cache_invalidate(); + /* enable interrupts */ + irq_nested_enable(flags); + RCCE_release_lock( dest ); return iRCCE_SUCCESS; @@ -417,17 +451,24 @@ int iRCCE_mailbox_wait(void) { //------------------------------------------------------------------------------ int iRCCE_mailbox_flush(void) { int i; + uint32_t flags; for( i=0; inext; kfree( erase_header, sizeof(iRCCE_MAIL_HEADER) ); erase_header = iRCCE_mailbox_recv_queue[i].first; } + + /* enable interrupts */ + irq_nested_enable(flags); } return iRCCE_SUCCESS; } @@ -449,11 +490,16 @@ int iRCCE_mailbox_flush(void) { */ //------------------------------------------------------------------------------ static int iRCCE_mailbox_close_one(int rank, int check) { + uint32_t flags; RCCE_acquire_lock( RCCE_IAM ); + /* disable interrupts */ + flags = irq_nested_disable(); + // check if it contains new mail RC_cache_invalidate(); if( check && iRCCE_mailbox_recv[rank]->sent ) { + iRCCE_mail_fetch(rank); } @@ -465,10 +511,14 @@ static int iRCCE_mailbox_close_one(int rank, int check) { RC_cache_invalidate(); iRCCE_memcpy_put( (void*)iRCCE_mailbox_recv[rank], &help_header, RCCE_LINE_SIZE ); + + iRCCE_mailbox_status[rank] = iRCCE_MAILBOX_CLOSED; + + /* enable interrupts */ + irq_nested_enable(flags); RCCE_release_lock( RCCE_IAM ); - iRCCE_mailbox_status[rank] = iRCCE_MAILBOX_CLOSED; return iRCCE_SUCCESS; } diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index f0c8b957..58db46ab 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -189,22 +189,15 @@ int icc_send_irq(int ue) int icc_halt(void) { - uint32_t flags; - uint32_t do_send = 1; - - // iRCCE is not thread save => disable interrupts - flags = irq_nested_disable(); - icc_mail_check(); - - irq_nested_enable(flags); - HALT; return 0; } -#define ROUNDS 10000 +#define ROUNDS 300000 +#define CORE_A 1 // sender +#define CORE_B 9 // receiver static inline void icc_mail_check_tag(iRCCE_MAIL_HEADER* mail) { char* recv_buffer; @@ -231,36 +224,62 @@ int icc_mail_ping( void ) { uint32_t flags; uint64_t timer = 0; - int rem_rank = (my_ue+1)%2; int i; + int res; iRCCE_MAIL_HEADER* recv_header = NULL; + /* leave function if not participating in pingpong */ + if( (my_ue != CORE_A) && (my_ue != CORE_B) ) return -1; + + kprintf( "my_ue = %d\n", my_ue ); kprintf( "Hello from mail_ping ... \n" ); - + kprintf( "rounds = %d\n", ROUNDS ); + + + /* wait 10 sec */ + timer = rdtsc(); + while( (rdtsc() - timer) < 533e8 ) { + kprintf( "waiting ...\n" ); + } + + kprintf( "waited ..\n" ); + // disable interrupts flags = irq_nested_disable(); for( i=0; isource == CORE_B ) + break; + iRCCE_mail_release(&recv_header); + } + } while( 1 ); /* release mail */ iRCCE_mail_release(&recv_header); } + /* receivers part */ else { /* wait for request */ do { - iRCCE_mail_recv(&recv_header); + res = iRCCE_mail_recv(&recv_header); + if( res == iRCCE_SUCCESS ) { + if( recv_header->tag == PING_REQ ) + break; + iRCCE_mail_release(&recv_header); + } } while( (!recv_header)); /* send response */ - iRCCE_mail_send(0, PING_RESP, 0, NULL, rem_rank); + iRCCE_mail_send(0, PING_RESP, 0, NULL, recv_header->source); /* release mail */ iRCCE_mail_release(&recv_header); @@ -275,10 +294,10 @@ int icc_mail_ping( void ) timer = rdtsc() - timer; - kprintf( "timer = %d\n", timer ); - if( my_ue == 0 ) { - kprintf( "mail_pingpong needs in average %f µsec (%d ticks)!\n", - timer/(2.0*ROUNDS*533), timer/(2*ROUNDS) ); + if( my_ue == CORE_A ) { + kprintf( "timer = %ld\n", timer ); + kprintf( "mail_pingpong needs in average %d msec (%d ticks)!\n", + timer/(2*ROUNDS*533), timer/(2*ROUNDS) ); } irq_nested_enable(flags); @@ -287,8 +306,6 @@ int icc_mail_ping( void ) } -#define CORE_A 0 // sender -#define CORE_B 1 // receiver int icc_mail_ping_irq( void ) { /* return if not core 0 */ @@ -304,6 +321,7 @@ int icc_mail_ping_irq( void ) kprintf( "Hello from mail_ping_irq ... \n" ); kprintf( "my_rank = %d\n", my_ue ); kprintf( "rem_rank = %d\n", rem_rank ); + kprintf( "rounds = %d\n", ROUNDS ); // disable interrupts flags = irq_nested_disable(); @@ -337,7 +355,7 @@ int icc_mail_ping_irq( void ) timer = rdtsc() - timer; kprintf( "timer = %ld\n", timer ); - kprintf( "mail_pingpong needs in average %d µsec (%d ticks)!\n", + kprintf( "mail_pingpong needs in average %d msec (%d ticks)!\n", timer/(2*ROUNDS*533), timer/(2*ROUNDS) ); @@ -357,22 +375,26 @@ int icc_mail_noise() { int num_ranks = RCCE_num_ues(); iRCCE_MAIL_HEADER* recv_mail = NULL; - kprintf( "Hello from icc_mail_noise: my_ue = %d\n", my_ue ); - // leave function if not participating - if( (my_ue == CORE_A) /*|| (my_ue == CORE_B)*/) { + if( (my_ue == CORE_A)/* || (my_ue == CORE_B)*/ ) { return -1; } + kprintf( "Hello from icc_mail_noise: my_ue = %d\n", my_ue ); + for( ;; ) { /* send a mail to each UE */ for( j=0; j