Print this page
5042 stop using deprecated atomic functions


 881  * in simulation and practice for different workloads on varying cache sizes.
 882  */
 883 uint32_t color_start_current = 0;
 884 uint32_t color_start_stride = 337;
 885 int color_start_random = 0;
 886 
 887 /* ARGSUSED */
 888 uint_t
 889 get_color_start(struct as *as)
 890 {
 891         uint32_t old, new;
 892 
 893         if (consistent_coloring == 2 || color_start_random) {
 894                 return ((uint_t)(((gettick()) << (vac_shift - MMU_PAGESHIFT)) &
 895                     (hw_page_array[0].hp_colors - 1)));
 896         }
 897 
 898         do {
 899                 old = color_start_current;
 900                 new = old + (color_start_stride << (vac_shift - MMU_PAGESHIFT));
 901         } while (cas32(&color_start_current, old, new) != old);
 902 
 903         return ((uint_t)(new));
 904 }
 905 
 906 /*
 907  * Called once at startup from kphysm_init() -- before memialloc()
 908  * is invoked to do the 1st page_free()/page_freelist_add().
 909  *
 910  * initializes page_colors and page_colors_mask based on ecache_setsize.
 911  *
 912  * Also initializes the counter locks.
 913  */
 914 void
 915 page_coloring_init()
 916 {
 917         int     a, i;
 918         uint_t colors;
 919 
 920         if (do_pg_coloring == 0) {
 921                 page_colors = 1;




 881  * in simulation and practice for different workloads on varying cache sizes.
 882  */
 883 uint32_t color_start_current = 0;
 884 uint32_t color_start_stride = 337;
 885 int color_start_random = 0;
 886 
 887 /* ARGSUSED */
 888 uint_t
 889 get_color_start(struct as *as)
 890 {
 891         uint32_t old, new;
 892 
 893         if (consistent_coloring == 2 || color_start_random) {
 894                 return ((uint_t)(((gettick()) << (vac_shift - MMU_PAGESHIFT)) &
 895                     (hw_page_array[0].hp_colors - 1)));
 896         }
 897 
 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));
 904 }
 905 
 906 /*
 907  * Called once at startup from kphysm_init() -- before memialloc()
 908  * is invoked to do the 1st page_free()/page_freelist_add().
 909  *
 910  * initializes page_colors and page_colors_mask based on ecache_setsize.
 911  *
 912  * Also initializes the counter locks.
 913  */
 914 void
 915 page_coloring_init()
 916 {
 917         int     a, i;
 918         uint_t colors;
 919 
 920         if (do_pg_coloring == 0) {
 921                 page_colors = 1;