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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/tcp/tcp_input.c
          +++ new/usr/src/uts/common/inet/tcp/tcp_input.c
↓ open down ↓ 1418 lines elided ↑ open up ↑
1419 1419  
1420 1420          /*
1421 1421           * Enforce the limit set on the number of connections per listener.
1422 1422           * Note that tlc_cnt starts with 1.  So need to add 1 to tlc_max
1423 1423           * for comparison.
1424 1424           */
1425 1425          if (listener->tcp_listen_cnt != NULL) {
1426 1426                  tcp_listen_cnt_t *tlc = listener->tcp_listen_cnt;
1427 1427                  int64_t now;
1428 1428  
1429      -                if (atomic_add_32_nv(&tlc->tlc_cnt, 1) > tlc->tlc_max + 1) {
     1429 +                if (atomic_inc_32_nv(&tlc->tlc_cnt) > tlc->tlc_max + 1) {
1430 1430                          mutex_exit(&listener->tcp_eager_lock);
1431 1431                          now = ddi_get_lbolt64();
1432      -                        atomic_add_32(&tlc->tlc_cnt, -1);
     1432 +                        atomic_dec_32(&tlc->tlc_cnt);
1433 1433                          TCP_STAT(tcps, tcp_listen_cnt_drop);
1434 1434                          tlc->tlc_drop++;
1435 1435                          if (now - tlc->tlc_report_time >
1436 1436                              MSEC_TO_TICK(TCP_TLC_REPORT_INTERVAL)) {
1437 1437                                  zcmn_err(lconnp->conn_zoneid, CE_WARN,
1438 1438                                      "Listener (port %d) connection max (%u) "
1439 1439                                      "reached: %u attempts dropped total\n",
1440 1440                                      ntohs(listener->tcp_connp->conn_lport),
1441 1441                                      tlc->tlc_max, tlc->tlc_drop);
1442 1442                                  tlc->tlc_report_time = now;
↓ open down ↓ 421 lines elided ↑ open up ↑
1864 1864          } else {
1865 1865                  /* Nobody wants this packet */
1866 1866                  freemsg(mp);
1867 1867          }
1868 1868          return;
1869 1869  error3:
1870 1870          CONN_DEC_REF(econnp);
1871 1871  error2:
1872 1872          freemsg(mp);
1873 1873          if (tlc_set)
1874      -                atomic_add_32(&listener->tcp_listen_cnt->tlc_cnt, -1);
     1874 +                atomic_dec_32(&listener->tcp_listen_cnt->tlc_cnt);
1875 1875  }
1876 1876  
1877 1877  /*
1878 1878   * In an ideal case of vertical partition in NUMA architecture, its
1879 1879   * beneficial to have the listener and all the incoming connections
1880 1880   * tied to the same squeue. The other constraint is that incoming
1881 1881   * connections should be tied to the squeue attached to interrupted
1882 1882   * CPU for obvious locality reason so this leaves the listener to
1883 1883   * be tied to the same squeue. Our only problem is that when listener
1884 1884   * is binding, the CPU that will get interrupted by the NIC whose
↓ open down ↓ 3938 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX