Print this page
6138 don't abuse atomic_cas_*

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/sun4/vm/vm_dep.c
          +++ new/usr/src/uts/sun4/vm/vm_dep.c
↓ open down ↓ 880 lines elided ↑ open up ↑
 881  881   * in simulation and practice for different workloads on varying cache sizes.
 882  882   */
 883  883  uint32_t color_start_current = 0;
 884  884  uint32_t color_start_stride = 337;
 885  885  int color_start_random = 0;
 886  886  
 887  887  /* ARGSUSED */
 888  888  uint_t
 889  889  get_color_start(struct as *as)
 890  890  {
 891      -        uint32_t old, new;
 892      -
 893  891          if (consistent_coloring == 2 || color_start_random) {
 894  892                  return ((uint_t)(((gettick()) << (vac_shift - MMU_PAGESHIFT)) &
 895  893                      (hw_page_array[0].hp_colors - 1)));
 896  894          }
 897  895  
 898      -        do {
 899      -                old = color_start_current;
 900      -                new = old + (color_start_stride << (vac_shift - MMU_PAGESHIFT));
 901      -        } while (atomic_cas_32(&color_start_current, old, new) != old);
 902      -
 903      -        return ((uint_t)(new));
      896 +        return ((uint_t)atomic_add_32_nv(&color_start_current,
      897 +            color_start_stride << (vac_shift - MMU_PAGESHIFT)));
 904  898  }
 905  899  
 906  900  /*
 907  901   * Called once at startup from kphysm_init() -- before memialloc()
 908  902   * is invoked to do the 1st page_free()/page_freelist_add().
 909  903   *
 910  904   * initializes page_colors and page_colors_mask based on ecache_setsize.
 911  905   *
 912  906   * Also initializes the counter locks.
 913  907   */
↓ open down ↓ 165 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX