Skip to content
Snippets Groups Projects
Commit b444df8c authored by Piotr Balcer's avatar Piotr Balcer
Browse files

obj: fix run allocated recalculation

parent 90aff044
No related branches found
No related tags found
No related merge requests found
......@@ -616,7 +616,7 @@ heap_reclaim_run(struct palloc_heap *heap, struct memory_block *m, int startup)
STATS_INC(heap->stats, transient, heap_run_active,
m->size_idx * CHUNKSIZE);
STATS_INC(heap->stats, transient, heap_run_allocated,
c->run.nallocs - e.free_space);
(c->run.nallocs - e.free_space) * run->hdr.block_size);
}
if (recycler_put(heap->rt->recyclers[c->id], m, e) < 0)
......
/*
* Copyright 2017-2019, Intel Corporation
* Copyright 2017-2020, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -122,6 +122,29 @@ main(int argc, char *argv[])
UT_ASSERTeq(ret, 0);
UT_ASSERTeq(tmp, run_allocated); /* shouldn't change */
/* the deallocated object shouldn't be reflected in rebuilt stats */
pmemobj_free(&oid);
pmemobj_close(pop);
pop = pmemobj_open(path, "ctl");
UT_ASSERTne(pop, NULL);
/* stats are rebuilt lazily, so initially this should be 0 */
tmp = 0;
ret = pmemobj_ctl_get(pop, "stats.heap.run_allocated", &tmp);
UT_ASSERTeq(ret, 0);
UT_ASSERTeq(tmp, 0);
ret = pmemobj_alloc(pop, NULL, 1, 0, NULL, NULL);
UT_ASSERTeq(ret, 0);
/* after first alloc, the previously allocated object will be found */
tmp = 0;
ret = pmemobj_ctl_get(pop, "stats.heap.run_allocated", &tmp);
UT_ASSERTeq(ret, 0);
UT_ASSERTeq(tmp, run_allocated + oid_size);
pmemobj_close(pop);
DONE(NULL);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment