mirror of
https://github.com/schoebel/mars
synced 2025-03-11 07:47:41 +00:00
infra: better statistics on object/aspect allocations
This commit is contained in:
parent
23c4a1cc57
commit
d1469b5b83
8
brick.c
8
brick.c
@ -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;
|
||||
|
2
brick.h
2
brick.h
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user