Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/sctp/sctp.c
          +++ new/usr/src/uts/common/inet/sctp/sctp.c
↓ open down ↓ 1748 lines elided ↑ open up ↑
1749 1749          tq = taskq_create(tq_name, thrs, minclsyspri, sctp_recvq_tq_task_min,
1750 1750              max_tasks, TASKQ_PREPOPULATE);
1751 1751          if (tq == NULL) {
1752 1752                  mutex_exit(&sctps->sctps_rq_tq_lock);
1753 1753                  cmn_err(CE_NOTE, "SCTP recvq taskq creation failed");
1754 1754                  return;
1755 1755          }
1756 1756          ASSERT(sctps->sctps_recvq_tq_list[
1757 1757              sctps->sctps_recvq_tq_list_cur_sz] == NULL);
1758 1758          sctps->sctps_recvq_tq_list[sctps->sctps_recvq_tq_list_cur_sz] = tq;
1759      -        atomic_add_32(&sctps->sctps_recvq_tq_list_cur_sz, 1);
     1759 +        atomic_inc_32(&sctps->sctps_recvq_tq_list_cur_sz);
1760 1760          mutex_exit(&sctps->sctps_rq_tq_lock);
1761 1761  }
1762 1762  
1763 1763  #ifdef DEBUG
1764 1764  uint32_t recvq_loop_cnt = 0;
1765 1765  uint32_t recvq_call = 0;
1766 1766  #endif
1767 1767  
1768 1768  /*
1769 1769   * Find the next recvq_tq to use.  This routine will go thru all the
↓ open down ↓ 6 lines elided ↑ open up ↑
1776 1776          int next_tq, try;
1777 1777          taskq_t *tq;
1778 1778          sctp_stack_t    *sctps = sctp->sctp_sctps;
1779 1779  
1780 1780          /*
1781 1781           * Note that since we don't hold a lock on sctp_rq_tq_lock for
1782 1782           * performance reason, recvq_ta_list_cur_sz can be changed during
1783 1783           * this loop.  The problem this will create is that the loop may
1784 1784           * not have tried all the recvq_tq.  This should be OK.
1785 1785           */
1786      -        next_tq = atomic_add_32_nv(&sctps->sctps_recvq_tq_list_cur, 1) %
     1786 +        next_tq = atomic_inc_32_nv(&sctps->sctps_recvq_tq_list_cur) %
1787 1787              sctps->sctps_recvq_tq_list_cur_sz;
1788 1788          for (try = 0; try < sctps->sctps_recvq_tq_list_cur_sz; try++) {
1789 1789                  tq = sctps->sctps_recvq_tq_list[next_tq];
1790 1790                  if (taskq_dispatch(tq, sctp_process_recvq, sctp,
1791 1791                      TQ_NOSLEEP) != NULL) {
1792 1792                          sctp->sctp_recvq_tq = tq;
1793 1793                          return (B_TRUE);
1794 1794                  }
1795 1795                  next_tq = (next_tq + 1) % sctps->sctps_recvq_tq_list_cur_sz;
1796 1796          }
↓ open down ↓ 353 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX