Print this page
5042 stop using deprecated atomic functions


1628         if (rss > PTOU(pp)->u_mem_max)
1629                 PTOU(pp)->u_mem_max = rss;
1630 
1631         /*
1632          * Notify the CPU the thread is running on.
1633          */
1634         if (poke && t->t_cpu != CPU)
1635                 poke_cpu(t->t_cpu->cpu_id);
1636 }
1637 
1638 void
1639 profil_tick(uintptr_t upc)
1640 {
1641         int ticks;
1642         proc_t *p = ttoproc(curthread);
1643         klwp_t *lwp = ttolwp(curthread);
1644         struct prof *pr = &p->p_prof;
1645 
1646         do {
1647                 ticks = lwp->lwp_oweupc;
1648         } while (cas32(&lwp->lwp_oweupc, ticks, 0) != ticks);
1649 
1650         mutex_enter(&p->p_pflock);
1651         if (pr->pr_scale >= 2 && upc >= pr->pr_off) {
1652                 /*
1653                  * Old-style profiling
1654                  */
1655                 uint16_t *slot = pr->pr_base;
1656                 uint16_t old, new;
1657                 if (pr->pr_scale != 2) {
1658                         uintptr_t delta = upc - pr->pr_off;
1659                         uintptr_t byteoff = ((delta >> 16) * pr->pr_scale) +
1660                             (((delta & 0xffff) * pr->pr_scale) >> 16);
1661                         if (byteoff >= (uintptr_t)pr->pr_size) {
1662                                 mutex_exit(&p->p_pflock);
1663                                 return;
1664                         }
1665                         slot += byteoff / sizeof (uint16_t);
1666                 }
1667                 if (fuword16(slot, &old) < 0 ||
1668                     (new = old + ticks) > SHRT_MAX ||




1628         if (rss > PTOU(pp)->u_mem_max)
1629                 PTOU(pp)->u_mem_max = rss;
1630 
1631         /*
1632          * Notify the CPU the thread is running on.
1633          */
1634         if (poke && t->t_cpu != CPU)
1635                 poke_cpu(t->t_cpu->cpu_id);
1636 }
1637 
1638 void
1639 profil_tick(uintptr_t upc)
1640 {
1641         int ticks;
1642         proc_t *p = ttoproc(curthread);
1643         klwp_t *lwp = ttolwp(curthread);
1644         struct prof *pr = &p->p_prof;
1645 
1646         do {
1647                 ticks = lwp->lwp_oweupc;
1648         } while (atomic_cas_32(&lwp->lwp_oweupc, ticks, 0) != ticks);
1649 
1650         mutex_enter(&p->p_pflock);
1651         if (pr->pr_scale >= 2 && upc >= pr->pr_off) {
1652                 /*
1653                  * Old-style profiling
1654                  */
1655                 uint16_t *slot = pr->pr_base;
1656                 uint16_t old, new;
1657                 if (pr->pr_scale != 2) {
1658                         uintptr_t delta = upc - pr->pr_off;
1659                         uintptr_t byteoff = ((delta >> 16) * pr->pr_scale) +
1660                             (((delta & 0xffff) * pr->pr_scale) >> 16);
1661                         if (byteoff >= (uintptr_t)pr->pr_size) {
1662                                 mutex_exit(&p->p_pflock);
1663                                 return;
1664                         }
1665                         slot += byteoff / sizeof (uint16_t);
1666                 }
1667                 if (fuword16(slot, &old) < 0 ||
1668                     (new = old + ticks) > SHRT_MAX ||