Changeset aeb31b1 for libcfa/src


Ignore:
Timestamp:
Dec 3, 2020, 3:33:18 PM (5 years ago)
Author:
Colby Alexander Parsons <caparsons@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
9082e0f1, cad1df1
Parents:
a78c3ff (diff), 0f88a225 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
libcfa/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/io.cfa

    ra78c3ff raeb31b1  
    160160        static inline void process(struct io_uring_cqe & cqe ) {
    161161                struct io_future_t * future = (struct io_future_t *)(uintptr_t)cqe.user_data;
    162                 __cfadbg_print_safe( io, "Kernel I/O : Syscall completed : cqe %p, result %d for %p\n", future, cqe.res, data->thrd );
     162                __cfadbg_print_safe( io, "Kernel I/O : Syscall completed : cqe %p, result %d for %p\n", &cqe, cqe.res, future );
    163163
    164164                fulfil( *future, cqe.res );
     
    298298                __u32 mask = *ring.submit_q.mask;
    299299
    300                 disable_interrupts();
    301                         __u32 off = __tls_rand();
    302                 enable_interrupts( __cfaabi_dbg_ctx );
     300                __u32 off = thread_rand();
    303301
    304302                // Loop around looking for an available spot
     
    344342                __u32 ready_mask = ring.submit_q.ready_cnt - 1;
    345343
    346                 disable_interrupts();
    347                         __u32 off = __tls_rand();
    348                 enable_interrupts( __cfaabi_dbg_ctx );
     344                __u32 off = thread_rand();
    349345
    350346                __u32 picked;
  • libcfa/src/concurrency/io/call.cfa.in

    ra78c3ff raeb31b1  
    8484
    8585                /* paranoid */ verifyf( cltr->io.ctxs, "default io contexts for cluster %p are missing\\n", cltr);
    86                 return &cltr->io.ctxs[ __tls_rand() % cltr->io.cnt ];
     86                return &cltr->io.ctxs[ thread_rand() % cltr->io.cnt ];
    8787        }
    8888#endif
  • libcfa/src/concurrency/kernel.cfa

    ra78c3ff raeb31b1  
    619619        lock( kernel_abort_lock __cfaabi_dbg_ctx2 );
    620620
     621        // disable interrupts, it no longer makes sense to try to interrupt this processor
     622        disable_interrupts();
     623
    621624        // first task to abort ?
    622625        if ( kernel_abort_called ) {                    // not first task to abort ?
  • libcfa/src/concurrency/kernel/fwd.hfa

    ra78c3ff raeb31b1  
    132132                }
    133133
     134                extern uint64_t thread_rand();
     135
    134136                //-----------------------------------------------------------------------
    135137                // Statics call at the end of each thread to register statistics
  • libcfa/src/concurrency/thread.cfa

    ra78c3ff raeb31b1  
    162162}
    163163
     164uint64_t thread_rand() {
     165        disable_interrupts();
     166        uint64_t ret = __tls_rand();
     167        enable_interrupts( __cfaabi_dbg_ctx );
     168        return ret;
     169}
     170
    164171// Local Variables: //
    165172// mode: c //
  • libcfa/src/interpose.cfa

    ra78c3ff raeb31b1  
    220220}
    221221
     222static volatile int __abort_stage = 0;
     223
    222224// Cannot forward va_list.
    223225void __abort( bool signalAbort, const char fmt[], va_list args ) {
    224         void * kernel_data = kernel_abort();                            // must be done here to lock down kernel
    225         int len;
    226 
    227         signal( SIGABRT, SIG_DFL );                                                     // prevent final "real" abort from recursing to handler
    228 
    229         len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
    230         __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    231 
    232         assert( fmt );
    233         len = vsnprintf( abort_text, abort_text_size, fmt, args );
    234         __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    235 
    236         if ( fmt[strlen( fmt ) - 1] != '\n' ) {                         // add optional newline if missing at the end of the format text
    237                 __cfaabi_bits_write( STDERR_FILENO, "\n", 1 );
    238         } // if
    239         kernel_abort_msg( kernel_data, abort_text, abort_text_size );
    240 
    241         __cfaabi_backtrace( signalAbort ? 4 : 2 );
    242 
    243         __cabi_libc.abort();                                                            // print stack trace in handler
     226        int stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
     227
     228        // First stage: stop the cforall kernel and print
     229        if(stage == 1) {
     230                // increment stage
     231                stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
     232
     233                // must be done here to lock down kernel
     234                void * kernel_data = kernel_abort();
     235                int len;
     236
     237                signal( SIGABRT, SIG_DFL );                                                     // prevent final "real" abort from recursing to handler
     238
     239                len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
     240                __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     241
     242                assert( fmt );
     243                len = vsnprintf( abort_text, abort_text_size, fmt, args );
     244                __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     245
     246                // add optional newline if missing at the end of the format text
     247                if ( fmt[strlen( fmt ) - 1] != '\n' ) {
     248                        __cfaabi_bits_write( STDERR_FILENO, "\n", 1 );
     249                } // if
     250                kernel_abort_msg( kernel_data, abort_text, abort_text_size );
     251        }
     252
     253        // Second stage: print the backtrace
     254        if(stage == 2) {
     255                // increment stage
     256                stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
     257
     258                // print stack trace in handler
     259                __cfaabi_backtrace( signalAbort ? 4 : 2 );
     260        }
     261
     262        do {
     263                // Finally call abort
     264                __cabi_libc.abort();
     265
     266                // Loop so that we never return
     267        } while(true);
    244268}
    245269
Note: See TracChangeset for help on using the changeset viewer.