mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
generate per-type memory block statistics
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1293 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
16ff83f5c0
commit
57f0b08cc1
2 changed files with 22 additions and 1 deletions
|
|
@ -121,6 +121,9 @@ static void stat_add(pa_memblock*b) {
|
||||||
b->pool->stat.n_imported++;
|
b->pool->stat.n_imported++;
|
||||||
b->pool->stat.imported_size += b->length;
|
b->pool->stat.imported_size += b->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b->pool->stat.n_allocated_by_type[b->type]++;
|
||||||
|
b->pool->stat.n_accumulated_by_type[b->type]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stat_remove(pa_memblock *b) {
|
static void stat_remove(pa_memblock *b) {
|
||||||
|
|
@ -140,6 +143,8 @@ static void stat_remove(pa_memblock *b) {
|
||||||
b->pool->stat.n_imported --;
|
b->pool->stat.n_imported --;
|
||||||
b->pool->stat.imported_size -= b->length;
|
b->pool->stat.imported_size -= b->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b->pool->stat.n_allocated_by_type[b->type]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pa_memblock *memblock_new_appended(pa_mempool *p, size_t length);
|
static pa_memblock *memblock_new_appended(pa_mempool *p, size_t length);
|
||||||
|
|
@ -353,13 +358,21 @@ void pa_memblock_unref(pa_memblock*b) {
|
||||||
|
|
||||||
if (b->type == PA_MEMBLOCK_POOL_EXTERNAL)
|
if (b->type == PA_MEMBLOCK_POOL_EXTERNAL)
|
||||||
pa_xfree(b);
|
pa_xfree(b);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case PA_MEMBLOCK_TYPE_MAX:
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void memblock_make_local(pa_memblock *b) {
|
static void memblock_make_local(pa_memblock *b) {
|
||||||
assert(b);
|
assert(b);
|
||||||
|
|
||||||
|
b->pool->stat.n_allocated_by_type[b->type]--;
|
||||||
|
|
||||||
if (b->length <= b->pool->block_size - sizeof(struct mempool_slot)) {
|
if (b->length <= b->pool->block_size - sizeof(struct mempool_slot)) {
|
||||||
struct mempool_slot *slot;
|
struct mempool_slot *slot;
|
||||||
|
|
||||||
|
|
@ -373,7 +386,7 @@ static void memblock_make_local(pa_memblock *b) {
|
||||||
new_data = mempool_slot_data(slot);
|
new_data = mempool_slot_data(slot);
|
||||||
memcpy(new_data, b->data, b->length);
|
memcpy(new_data, b->data, b->length);
|
||||||
b->data = new_data;
|
b->data = new_data;
|
||||||
return;
|
goto finish;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -382,6 +395,10 @@ static void memblock_make_local(pa_memblock *b) {
|
||||||
b->per_type.user.free_cb = pa_xfree;
|
b->per_type.user.free_cb = pa_xfree;
|
||||||
b->read_only = 0;
|
b->read_only = 0;
|
||||||
b->data = pa_xmemdup(b->data, b->length);
|
b->data = pa_xmemdup(b->data, b->length);
|
||||||
|
|
||||||
|
finish:
|
||||||
|
b->pool->stat.n_allocated_by_type[b->type]++;
|
||||||
|
b->pool->stat.n_accumulated_by_type[b->type]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa_memblock_unref_fixed(pa_memblock *b) {
|
void pa_memblock_unref_fixed(pa_memblock *b) {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ typedef enum pa_memblock_type {
|
||||||
PA_MEMBLOCK_USER, /* User supplied memory, to be freed with free_cb */
|
PA_MEMBLOCK_USER, /* User supplied memory, to be freed with free_cb */
|
||||||
PA_MEMBLOCK_FIXED, /* data is a pointer to fixed memory that needs not to be freed */
|
PA_MEMBLOCK_FIXED, /* data is a pointer to fixed memory that needs not to be freed */
|
||||||
PA_MEMBLOCK_IMPORTED, /* Memory is imported from another process via shm */
|
PA_MEMBLOCK_IMPORTED, /* Memory is imported from another process via shm */
|
||||||
|
PA_MEMBLOCK_TYPE_MAX
|
||||||
} pa_memblock_type_t;
|
} pa_memblock_type_t;
|
||||||
|
|
||||||
typedef struct pa_memblock pa_memblock;
|
typedef struct pa_memblock pa_memblock;
|
||||||
|
|
@ -84,6 +85,9 @@ struct pa_mempool_stat {
|
||||||
|
|
||||||
unsigned n_too_large_for_pool;
|
unsigned n_too_large_for_pool;
|
||||||
unsigned n_pool_full;
|
unsigned n_pool_full;
|
||||||
|
|
||||||
|
unsigned n_allocated_by_type[PA_MEMBLOCK_TYPE_MAX];
|
||||||
|
unsigned n_accumulated_by_type[PA_MEMBLOCK_TYPE_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Allocate a new memory block of type PA_MEMBLOCK_MEMPOOL or PA_MEMBLOCK_APPENDED, depending on the size */
|
/* Allocate a new memory block of type PA_MEMBLOCK_MEMPOOL or PA_MEMBLOCK_APPENDED, depending on the size */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue