MCPcopy Create free account
hub / github.com/F-Stack/f-stack / arena_tdata_get_hard

Function arena_tdata_get_hard

app/redis-6.2.6/deps/jemalloc/src/jemalloc.c:407–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405}
406
407arena_tdata_t *
408arena_tdata_get_hard(tsd_t *tsd, unsigned ind) {
409 arena_tdata_t *tdata, *arenas_tdata_old;
410 arena_tdata_t *arenas_tdata = tsd_arenas_tdata_get(tsd);
411 unsigned narenas_tdata_old, i;
412 unsigned narenas_tdata = tsd_narenas_tdata_get(tsd);
413 unsigned narenas_actual = narenas_total_get();
414
415 /*
416 * Dissociate old tdata array (and set up for deallocation upon return)
417 * if it's too small.
418 */
419 if (arenas_tdata != NULL && narenas_tdata < narenas_actual) {
420 arenas_tdata_old = arenas_tdata;
421 narenas_tdata_old = narenas_tdata;
422 arenas_tdata = NULL;
423 narenas_tdata = 0;
424 tsd_arenas_tdata_set(tsd, arenas_tdata);
425 tsd_narenas_tdata_set(tsd, narenas_tdata);
426 } else {
427 arenas_tdata_old = NULL;
428 narenas_tdata_old = 0;
429 }
430
431 /* Allocate tdata array if it's missing. */
432 if (arenas_tdata == NULL) {
433 bool *arenas_tdata_bypassp = tsd_arenas_tdata_bypassp_get(tsd);
434 narenas_tdata = (ind < narenas_actual) ? narenas_actual : ind+1;
435
436 if (tsd_nominal(tsd) && !*arenas_tdata_bypassp) {
437 *arenas_tdata_bypassp = true;
438 arenas_tdata = (arena_tdata_t *)a0malloc(
439 sizeof(arena_tdata_t) * narenas_tdata);
440 *arenas_tdata_bypassp = false;
441 }
442 if (arenas_tdata == NULL) {
443 tdata = NULL;
444 goto label_return;
445 }
446 assert(tsd_nominal(tsd) && !*arenas_tdata_bypassp);
447 tsd_arenas_tdata_set(tsd, arenas_tdata);
448 tsd_narenas_tdata_set(tsd, narenas_tdata);
449 }
450
451 /*
452 * Copy to tdata array. It's possible that the actual number of arenas
453 * has increased since narenas_total_get() was called above, but that
454 * causes no correctness issues unless two threads concurrently execute
455 * the arenas.create mallctl, which we trust mallctl synchronization to
456 * prevent.
457 */
458
459 /* Copy/initialize tickers. */
460 for (i = 0; i < narenas_actual; i++) {
461 if (i < narenas_tdata_old) {
462 ticker_copy(&arenas_tdata[i].decay_ticker,
463 &arenas_tdata_old[i].decay_ticker);
464 } else {

Callers 1

arena_tdata_getFunction · 0.85

Calls 7

narenas_total_getFunction · 0.85
tsd_nominalFunction · 0.85
a0mallocFunction · 0.85
ticker_copyFunction · 0.85
ticker_initFunction · 0.85
memsetFunction · 0.85
a0dallocFunction · 0.85

Tested by

no test coverage detected