| 2306 | } |
| 2307 | |
| 2308 | static int |
| 2309 | arena_i_decay_ms_ctl_impl(tsd_t *tsd, const size_t *mib, size_t miblen, |
| 2310 | void *oldp, size_t *oldlenp, void *newp, size_t newlen, bool dirty) { |
| 2311 | int ret; |
| 2312 | unsigned arena_ind; |
| 2313 | arena_t *arena; |
| 2314 | |
| 2315 | MIB_UNSIGNED(arena_ind, 1); |
| 2316 | arena = arena_get(tsd_tsdn(tsd), arena_ind, false); |
| 2317 | if (arena == NULL) { |
| 2318 | ret = EFAULT; |
| 2319 | goto label_return; |
| 2320 | } |
| 2321 | |
| 2322 | if (oldp != NULL && oldlenp != NULL) { |
| 2323 | size_t oldval = dirty ? arena_dirty_decay_ms_get(arena) : |
| 2324 | arena_muzzy_decay_ms_get(arena); |
| 2325 | READ(oldval, ssize_t); |
| 2326 | } |
| 2327 | if (newp != NULL) { |
| 2328 | if (newlen != sizeof(ssize_t)) { |
| 2329 | ret = EINVAL; |
| 2330 | goto label_return; |
| 2331 | } |
| 2332 | if (arena_is_huge(arena_ind) && *(ssize_t *)newp > 0) { |
| 2333 | /* |
| 2334 | * By default the huge arena purges eagerly. If it is |
| 2335 | * set to non-zero decay time afterwards, background |
| 2336 | * thread might be needed. |
| 2337 | */ |
| 2338 | if (background_thread_create(tsd, arena_ind)) { |
| 2339 | ret = EFAULT; |
| 2340 | goto label_return; |
| 2341 | } |
| 2342 | } |
| 2343 | if (dirty ? arena_dirty_decay_ms_set(tsd_tsdn(tsd), arena, |
| 2344 | *(ssize_t *)newp) : arena_muzzy_decay_ms_set(tsd_tsdn(tsd), |
| 2345 | arena, *(ssize_t *)newp)) { |
| 2346 | ret = EFAULT; |
| 2347 | goto label_return; |
| 2348 | } |
| 2349 | } |
| 2350 | |
| 2351 | ret = 0; |
| 2352 | label_return: |
| 2353 | return ret; |
| 2354 | } |
| 2355 | |
| 2356 | static int |
| 2357 | arena_i_dirty_decay_ms_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, |
no test coverage detected