- Timestamp:
- Jul 1, 2020, 3:06:46 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 4ec028d
- Parents:
- c33ed65
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/io.cfa
rc33ed65 rdf40a56 580 580 int count; 581 581 bool again; 582 [count, again] = __drain_io( ring, &mask, 1, true );582 [count, again] = __drain_io( ring, &mask, 0, true ); 583 583 584 584 // Update statistics … … 593 593 594 594 unregister( &ring.poller.slow.id ); 595 596 #if !defined(__CFA_NO_STATISTICS__) 597 __tally_stats(cltr->stats, &local_stats); 598 #endif 595 599 596 600 return 0p; … … 681 685 // 682 686 687 // [* struct io_uring_sqe, uint32_t] __submit_alloc( struct __io_data & ring, uint64_t data ) __attribute__((noinline)); 683 688 static inline [* struct io_uring_sqe, uint32_t] __submit_alloc( struct __io_data & ring, uint64_t data ) { 684 689 verify( data != 0 ); … … 730 735 } 731 736 737 static inline uint32_t __submit_to_ready_array( struct __io_data & ring, uint32_t idx, const uint32_t mask ) { 738 /* paranoid */ verify( idx <= mask ); 739 /* paranoid */ verify( idx != -1ul32 ); 740 741 // We need to find a spot in the ready array 742 __attribute((unused)) int len = 0; 743 __attribute((unused)) int block = 0; 744 uint32_t ready_mask = ring.submit_q.ready_cnt - 1; 745 746 disable_interrupts(); 747 uint32_t off = __tls_rand(); 748 enable_interrupts( __cfaabi_dbg_ctx ); 749 750 uint32_t picked; 751 LOOKING: for() { 752 for(i; ring.submit_q.ready_cnt) { 753 picked = (i + off) & ready_mask; 754 uint32_t expected = -1ul32; 755 if( __atomic_compare_exchange_n( &ring.submit_q.ready[picked], &expected, idx, true, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED ) ) { 756 break LOOKING; 757 } 758 verify(expected != idx); 759 760 len ++; 761 } 762 763 block++; 764 yield(); 765 } 766 767 // update statistics 768 #if !defined(__CFA_NO_STATISTICS__) 769 disable_interrupts(); 770 __tls_stats()->io.submit_q.look_avg.val += len; 771 __tls_stats()->io.submit_q.look_avg.block += block; 772 __tls_stats()->io.submit_q.look_avg.cnt += 1; 773 enable_interrupts( __cfaabi_dbg_ctx ); 774 #endif 775 776 return picked; 777 } 778 779 // void __submit( struct __io_data & ring, uint32_t idx ) __attribute__((noinline)); 732 780 static inline void __submit( struct __io_data & ring, uint32_t idx ) { 733 781 // Get now the data we definetely need … … 735 783 const uint32_t mask = *ring.submit_q.mask; 736 784 737 disable_interrupts();738 739 785 // There are 2 submission schemes, check which one we are using 740 786 if( ring.cltr_flags & CFA_CLUSTER_IO_POLLER_THREAD_SUBMITS ) { 741 787 // If the poller thread submits, then we just need to add this to the ready array 742 788 743 /* paranoid */ verify( idx <= mask ); 744 /* paranoid */ verify( idx != -1ul32 ); 745 746 // We need to find a spot in the ready array 747 __attribute((unused)) int len = 0; 748 __attribute((unused)) int block = 0; 749 uint32_t ready_mask = ring.submit_q.ready_cnt - 1; 750 uint32_t off = __tls_rand(); 751 LOOKING: for() { 752 for(i; ring.submit_q.ready_cnt) { 753 uint32_t ii = (i + off) & ready_mask; 754 uint32_t expected = -1ul32; 755 if( __atomic_compare_exchange_n( &ring.submit_q.ready[ii], &expected, idx, true, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED ) ) { 756 break LOOKING; 757 } 758 verify(expected != idx); 759 760 len ++; 761 } 762 763 block++; 764 yield(); 765 } 789 __submit_to_ready_array( ring, idx, mask ); 766 790 767 791 __wake_poller( ring ); 768 769 // update statistics770 #if !defined(__CFA_NO_STATISTICS__)771 __tls_stats()->io.submit_q.look_avg.val += len;772 __tls_stats()->io.submit_q.look_avg.block += block;773 __tls_stats()->io.submit_q.look_avg.cnt += 1;774 #endif775 792 776 793 __cfadbg_print_safe( io, "Kernel I/O : Added %u to ready for %p\n", idx, active_thread() ); … … 808 825 __cfadbg_print_safe( io, "Kernel I/O : Performed io_submit for %p, returned %d\n", active_thread(), ret ); 809 826 } 810 811 enable_interrupts( __cfaabi_dbg_ctx );812 827 } 813 828
Note: See TracChangeset
for help on using the changeset viewer.