infra: better statistics on object/aspect allocations

This commit is contained in:
Thomas Schoebel-Theuer 2012-12-03 14:21:12 +01:00 committed by Thomas Schoebel-Theuer
parent 23c4a1cc57
commit d1469b5b83
3 changed files with 25 additions and 4 deletions

View File

@ -498,6 +498,7 @@ void generic_free(struct generic_object *object)
if (aspect->shortcut)
continue;
brick_mem_free(aspect);
atomic_dec(&object_layout->aspect_count);
}
if (object_type->exit_fn) {
object_type->exit_fn(object);
@ -534,16 +535,15 @@ struct generic_aspect *_new_aspect(struct generic_brick *brick, struct generic_o
obj->free_offset += size;
res->shortcut = true;
} else {
struct generic_object_layout *object_layout = obj->object_layout;
CHECK_PTR(object_layout, done);
/* Maintain the size hint.
* In future, only small aspects should be integrated into
* the same memory block, and the hint should not grow larger
* than PAGE_SIZE if it was smaller before.
*/
if (size < PAGE_SIZE / 2) {
struct generic_object_layout *object_layout = obj->object_layout;
int max;
CHECK_PTR(object_layout, done);
max = obj->free_offset + size;
/* This is racy, but races won't do any harm because
* it is just a hint, not essential.
@ -557,6 +557,8 @@ struct generic_aspect *_new_aspect(struct generic_brick *brick, struct generic_o
if (unlikely(!res)) {
goto done;
}
atomic_inc(&object_layout->aspect_count);
atomic_inc(&object_layout->total_aspect_count);
}
res->object = obj;
res->aspect_type = aspect_type;

View File

@ -84,7 +84,9 @@ struct generic_object_type {
#define GENERIC_OBJECT_LAYOUT(OBJTYPE) \
int size_hint; \
atomic_t alloc_count; \
atomic_t aspect_count; \
atomic_t total_alloc_count; \
atomic_t total_aspect_count; \
struct generic_object_layout {
GENERIC_OBJECT_LAYOUT(generic);

View File

@ -3756,7 +3756,24 @@ void _show_one(struct mars_brick *test, int *brick_count)
if (*brick_count) {
MARS_STAT("---------\n");
}
MARS_STAT("BRICK type = %s path = '%s' name = '%s' button = %d off = %d on = %d\n", SAFE_STR(test->type->type_name), SAFE_STR(test->brick_path), SAFE_STR(test->brick_name), test->power.button, test->power.led_off, test->power.led_on);
MARS_STAT("BRICK type = %s path = '%s' name = '%s' "
"size_hint=%d "
"mrefs_alloc = %d "
"mrefs_apsect_alloc = %d "
"total_mrefs_alloc = %d "
"total_mrefs_aspects = %d "
"button = %d off = %d on = %d\n",
SAFE_STR(test->type->type_name),
SAFE_STR(test->brick_path),
SAFE_STR(test->brick_name),
test->mref_object_layout.size_hint,
atomic_read(&test->mref_object_layout.alloc_count),
atomic_read(&test->mref_object_layout.aspect_count),
atomic_read(&test->mref_object_layout.total_alloc_count),
atomic_read(&test->mref_object_layout.total_aspect_count),
test->power.button,
test->power.led_off,
test->power.led_on);
(*brick_count)++;
if (test->ops && test->ops->brick_statistics) {
char *info = test->ops->brick_statistics(test, 0);