/* * huge_vg_init -- initalizes chunk metadata in memcheck state */ static void huge_vg_init(const struct memory_block *m, int objects, object_callback cb, void *arg) { struct zone *z = ZID_TO_ZONE(m->heap->layout, m->zone_id); struct chunk_header *hdr = heap_get_chunk_hdr(m->heap, m); struct chunk *chunk = heap_get_chunk(m->heap, m); VALGRIND_DO_MAKE_MEM_DEFINED(hdr, sizeof(*hdr)); /* * Mark unused chunk headers as not accessible. */ VALGRIND_DO_MAKE_MEM_NOACCESS( &z->chunk_headers[m->chunk_id + 1], (m->size_idx - 1) * sizeof(struct chunk_header)); size_t size = block_get_real_size(m); VALGRIND_DO_MAKE_MEM_NOACCESS(chunk, size); if (objects && huge_get_state(m) == MEMBLOCK_ALLOCATED) { if (cb(m, arg) != 0) FATAL("failed to initialize valgrind state"); } }
/* * heap_get_adjacent_free_block -- locates adjacent free memory block in heap */ int heap_get_adjacent_free_block(PMEMobjpool *pop, struct memory_block *m, struct memory_block cnt, int prev) { struct zone *z = &pop->heap->layout->zones[cnt.zone_id]; struct chunk_header *hdr = &z->chunk_headers[cnt.chunk_id]; m->zone_id = cnt.zone_id; if (hdr->type == CHUNK_TYPE_RUN) { m->chunk_id = cnt.chunk_id; struct chunk_run *r = (struct chunk_run *)&z->chunks[cnt.chunk_id]; return heap_run_get_block(pop, r, m, cnt.size_idx, cnt.block_off, prev); } else { return heap_get_chunk(pop, z, hdr, m, cnt.chunk_id, prev); } }
/* * huge_get_real_data -- returns pointer to the beginning data of a huge block */ static void * huge_get_real_data(const struct memory_block *m) { return heap_get_chunk(m->heap, m)->data; }