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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/vm/seg_spt.c
          +++ new/usr/src/uts/common/vm/seg_spt.c
↓ open down ↓ 1080 lines elided ↑ open up ↑
1081 1081                          sptd->spt_ppa = NULL;
1082 1082                  }
1083 1083                  ret = ENOTSUP;
1084 1084                  goto insert_fail;
1085 1085          }
1086 1086  
1087 1087          /*
1088 1088           * In either case, we increment softlockcnt on the 'real' segment.
1089 1089           */
1090 1090          sptd->spt_pcachecnt++;
1091      -        atomic_add_long((ulong_t *)(&(shmd->shm_softlockcnt)), 1);
     1091 +        atomic_inc_ulong((ulong_t *)(&(shmd->shm_softlockcnt)));
1092 1092  
1093 1093          ppa = sptd->spt_ppa;
1094 1094          for (an_idx = pg_idx; an_idx < pg_idx + npages; ) {
1095 1095                  if (ppa[an_idx] == NULL) {
1096 1096                          mutex_exit(&sptd->spt_lock);
1097 1097                          seg_pinactive(seg, NULL, seg->s_base,
1098 1098                              sptd->spt_amp->size,
1099 1099                              pl, S_WRITE, SEGP_FORCE_WIRED, segspt_reclaim);
1100 1100                          *ppp = NULL;
1101 1101                          return (ENOTSUP);
↓ open down ↓ 258 lines elided ↑ open up ↑
1360 1360                          sptd->spt_ppa = NULL;
1361 1361                  }
1362 1362                  ret = ENOTSUP;
1363 1363                  goto insert_fail;
1364 1364          }
1365 1365  
1366 1366          /*
1367 1367           * In either case, we increment softlockcnt on the 'real' segment.
1368 1368           */
1369 1369          sptd->spt_pcachecnt++;
1370      -        atomic_add_long((ulong_t *)(&(shmd->shm_softlockcnt)), 1);
     1370 +        atomic_inc_ulong((ulong_t *)(&(shmd->shm_softlockcnt)));
1371 1371  
1372 1372          /*
1373 1373           * We can now drop the sptd->spt_lock since the ppa[]
1374 1374           * exists and he have incremented pacachecnt.
1375 1375           */
1376 1376          mutex_exit(&sptd->spt_lock);
1377 1377  
1378 1378          /*
1379 1379           * Since we cache the entire segment, we want to
1380 1380           * set ppp to point to the first slot that corresponds
↓ open down ↓ 131 lines elided ↑ open up ↑
1512 1512           * to 0 if async is not 0.  unmapwait thread
1513 1513           * will not block if this flag is set.
1514 1514           */
1515 1515          if (async)
1516 1516                  mutex_enter(&shmd->shm_segfree_syncmtx);
1517 1517  
1518 1518          /*
1519 1519           * Now decrement softlockcnt.
1520 1520           */
1521 1521          ASSERT(shmd->shm_softlockcnt > 0);
1522      -        atomic_add_long((ulong_t *)(&(shmd->shm_softlockcnt)), -1);
     1522 +        atomic_dec_ulong((ulong_t *)(&(shmd->shm_softlockcnt)));
1523 1523  
1524 1524          if (shmd->shm_softlockcnt <= 0) {
1525 1525                  if (async || AS_ISUNMAPWAIT(seg->s_as)) {
1526 1526                          mutex_enter(&seg->s_as->a_contents);
1527 1527                          if (async)
1528 1528                                  AS_SETNOUNMAPWAIT(seg->s_as);
1529 1529                          if (AS_ISUNMAPWAIT(seg->s_as)) {
1530 1530                                  AS_CLRUNMAPWAIT(seg->s_as);
1531 1531                                  cv_broadcast(&seg->s_as->a_cv);
1532 1532                          }
↓ open down ↓ 1371 lines elided ↑ open up ↑
2904 2904                   */
2905 2905                  seg_ppurge_wiredpp(ppa);
2906 2906  
2907 2907                  /*
2908 2908                   * Drop the AS_LOCK so that other threads can grab it
2909 2909                   * in the as_pageunlock path and hopefully get the segment
2910 2910                   * kicked out of the seg_pcache.  We bump the shm_softlockcnt
2911 2911                   * to keep this segment resident.
2912 2912                   */
2913 2913                  writer = AS_WRITE_HELD(seg->s_as, &seg->s_as->a_lock);
2914      -                atomic_add_long((ulong_t *)(&(shmd->shm_softlockcnt)), 1);
     2914 +                atomic_inc_ulong((ulong_t *)(&(shmd->shm_softlockcnt)));
2915 2915                  AS_LOCK_EXIT(seg->s_as, &seg->s_as->a_lock);
2916 2916  
2917 2917                  mutex_enter(&sptd->spt_lock);
2918 2918  
2919 2919                  end_lbolt = ddi_get_lbolt() + (hz * spt_pcache_wait);
2920 2920  
2921 2921                  /*
2922 2922                   * Try to wait for pages to get kicked out of the seg_pcache.
2923 2923                   */
2924 2924                  while (sptd->spt_gen == gen &&
↓ open down ↓ 3 lines elided ↑ open up ↑
2928 2928                              &sptd->spt_lock, end_lbolt)) {
2929 2929                                  break;
2930 2930                          }
2931 2931                  }
2932 2932  
2933 2933                  mutex_exit(&sptd->spt_lock);
2934 2934  
2935 2935                  /* Regrab the AS_LOCK and release our hold on the segment */
2936 2936                  AS_LOCK_ENTER(seg->s_as, &seg->s_as->a_lock,
2937 2937                      writer ? RW_WRITER : RW_READER);
2938      -                atomic_add_long((ulong_t *)(&(shmd->shm_softlockcnt)), -1);
     2938 +                atomic_dec_ulong((ulong_t *)(&(shmd->shm_softlockcnt)));
2939 2939                  if (shmd->shm_softlockcnt <= 0) {
2940 2940                          if (AS_ISUNMAPWAIT(seg->s_as)) {
2941 2941                                  mutex_enter(&seg->s_as->a_contents);
2942 2942                                  if (AS_ISUNMAPWAIT(seg->s_as)) {
2943 2943                                          AS_CLRUNMAPWAIT(seg->s_as);
2944 2944                                          cv_broadcast(&seg->s_as->a_cv);
2945 2945                                  }
2946 2946                                  mutex_exit(&seg->s_as->a_contents);
2947 2947                          }
2948 2948                  }
↓ open down ↓ 167 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX