Changeset 54cc2bf


Ignore:
Timestamp:
Jan 14, 2021, 7:42:53 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
f756a7f
Parents:
7836dad (diff), 7222630 (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/concurrency
Files:
2 edited

Legend:

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

    r7836dad r54cc2bf  
    314314        }
    315315
     316        extern void __disable_interrupts_hard();
     317        extern void __enable_interrupts_hard();
     318
    316319        static void __io_create( __io_data & this, const io_context_params & params_in ) {
    317320                // Step 1 : call to setup
     
    429432
    430433                // Step 4 : eventfd
    431                 int efd;
    432                 for() {
    433                         efd = eventfd(0, 0);
    434                         if (efd < 0) {
    435                                 if (errno == EINTR) continue;
    436                                 abort("KERNEL ERROR: IO_URING EVENTFD - %s\n", strerror(errno));
    437                         }
    438                         break;
    439                 }
    440 
    441                 int ret;
    442                 for() {
    443                         ret = syscall( __NR_io_uring_register, fd, IORING_REGISTER_EVENTFD, &efd, 1);
    444                         if (ret < 0) {
    445                                 if (errno == EINTR) continue;
    446                                 abort("KERNEL ERROR: IO_URING EVENTFD REGISTER - %s\n", strerror(errno));
    447                         }
    448                         break;
    449                 }
     434                // io_uring_register is so f*cking slow on some machine that it
     435                // will never succeed if preemption isn't hard blocked
     436                __disable_interrupts_hard();
     437
     438                int efd = eventfd(0, 0);
     439                if (efd < 0) {
     440                        abort("KERNEL ERROR: IO_URING EVENTFD - %s\n", strerror(errno));
     441                }
     442
     443                int ret = syscall( __NR_io_uring_register, fd, IORING_REGISTER_EVENTFD, &efd, 1);
     444                if (ret < 0) {
     445                        abort("KERNEL ERROR: IO_URING EVENTFD REGISTER - %s\n", strerror(errno));
     446                }
     447
     448                __enable_interrupts_hard();
    450449
    451450                // some paranoid checks
  • libcfa/src/concurrency/preemption.cfa

    r7836dad r54cc2bf  
    424424static void timeout( $thread * this ) {
    425425        unpark( this );
     426}
     427
     428void __disable_interrupts_hard() {
     429        sigset_t oldset;
     430        int ret;
     431        ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset);  // workaround trac#208: cast should be unnecessary
     432        if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }
     433
     434        ret = sigismember(&oldset, SIGUSR1);
     435        if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
     436        if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); }
     437
     438        ret = sigismember(&oldset, SIGALRM);
     439        if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
     440        if(ret == 0) { abort("ERROR SIGALRM is enabled"); }
     441
     442        signal_block( SIGUSR1 );
     443}
     444
     445void __enable_interrupts_hard() {
     446        signal_unblock( SIGUSR1 );
     447
     448        sigset_t oldset;
     449        int ret;
     450        ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset);  // workaround trac#208: cast should be unnecessary
     451        if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }
     452
     453        ret = sigismember(&oldset, SIGUSR1);
     454        if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
     455        if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); }
     456
     457        ret = sigismember(&oldset, SIGALRM);
     458        if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
     459        if(ret == 0) { abort("ERROR SIGALRM is enabled"); }
    426460}
    427461
Note: See TracChangeset for help on using the changeset viewer.