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


1260         ASSERT(sizep != NULL);
1261 
1262         size = *sizep;
1263 
1264         if (lpcb->lp_uselp && !(t->t_flag & T_PANIC) &&
1265             !(vmflag & SEGKMEM_SHARELOCKED)) {
1266 
1267                 size_t kmemlp_qnt = segkmem_kmemlp_quantum;
1268                 size_t asize = P2ROUNDUP(size, kmemlp_qnt);
1269                 void  *addr = NULL;
1270                 ulong_t *lpthrtp = &lpcb->lp_throttle;
1271                 ulong_t lpthrt = *lpthrtp;
1272                 int     dowakeup = 0;
1273                 int     doalloc = 1;
1274 
1275                 ASSERT(kmem_lp_arena != NULL);
1276                 ASSERT(asize >= size);
1277 
1278                 if (lpthrt != 0) {
1279                         /* try to update the throttle value */
1280                         lpthrt = atomic_add_long_nv(lpthrtp, 1);
1281                         if (lpthrt >= segkmem_lpthrottle_max) {
1282                                 lpthrt = atomic_cas_ulong(lpthrtp, lpthrt,
1283                                     segkmem_lpthrottle_max / 4);
1284                         }
1285 
1286                         /*
1287                          * when we get above throttle start do an exponential
1288                          * backoff at trying large pages and reaping
1289                          */
1290                         if (lpthrt > segkmem_lpthrottle_start &&
1291                             (lpthrt & (lpthrt - 1))) {
1292                                 lpcb->allocs_throttled++;
1293                                 lpthrt--;
1294                                 if ((lpthrt & (lpthrt - 1)) == 0)
1295                                         kmem_reap();
1296                                 return (segkmem_alloc(vmp, size, vmflag));
1297                         }
1298                 }
1299 
1300                 if (!(vmflag & VM_NOSLEEP) &&




1260         ASSERT(sizep != NULL);
1261 
1262         size = *sizep;
1263 
1264         if (lpcb->lp_uselp && !(t->t_flag & T_PANIC) &&
1265             !(vmflag & SEGKMEM_SHARELOCKED)) {
1266 
1267                 size_t kmemlp_qnt = segkmem_kmemlp_quantum;
1268                 size_t asize = P2ROUNDUP(size, kmemlp_qnt);
1269                 void  *addr = NULL;
1270                 ulong_t *lpthrtp = &lpcb->lp_throttle;
1271                 ulong_t lpthrt = *lpthrtp;
1272                 int     dowakeup = 0;
1273                 int     doalloc = 1;
1274 
1275                 ASSERT(kmem_lp_arena != NULL);
1276                 ASSERT(asize >= size);
1277 
1278                 if (lpthrt != 0) {
1279                         /* try to update the throttle value */
1280                         lpthrt = atomic_inc_ulong_nv(lpthrtp);
1281                         if (lpthrt >= segkmem_lpthrottle_max) {
1282                                 lpthrt = atomic_cas_ulong(lpthrtp, lpthrt,
1283                                     segkmem_lpthrottle_max / 4);
1284                         }
1285 
1286                         /*
1287                          * when we get above throttle start do an exponential
1288                          * backoff at trying large pages and reaping
1289                          */
1290                         if (lpthrt > segkmem_lpthrottle_start &&
1291                             (lpthrt & (lpthrt - 1))) {
1292                                 lpcb->allocs_throttled++;
1293                                 lpthrt--;
1294                                 if ((lpthrt & (lpthrt - 1)) == 0)
1295                                         kmem_reap();
1296                                 return (segkmem_alloc(vmp, size, vmflag));
1297                         }
1298                 }
1299 
1300                 if (!(vmflag & VM_NOSLEEP) &&