mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-23 07:08:06 -04:00
BUG/MINOR: pool/cli: use ullong to report total pool usage in bytes
As noticed by Gabriel Tzagkarakis in issue #1903, the total pool size in bytes is historically still in 32 bits, but at least we should report the product of the number of objects and their size in 64 bits so that the value doesn't wrap around 4G. This may be backported to all versions.
This commit is contained in:
parent
35402852bd
commit
0c5e9896c7
1 changed files with 9 additions and 9 deletions
18
src/pool.c
18
src/pool.c
|
|
@ -872,9 +872,9 @@ void pool_destroy_all()
|
|||
void dump_pools_to_trash()
|
||||
{
|
||||
struct pool_head *entry;
|
||||
unsigned long allocated, used;
|
||||
unsigned long long allocated, used;
|
||||
int nbpools;
|
||||
unsigned long cached_bytes = 0;
|
||||
unsigned long long cached_bytes = 0;
|
||||
uint cached = 0;
|
||||
|
||||
allocated = used = nbpools = 0;
|
||||
|
|
@ -884,24 +884,24 @@ void dump_pools_to_trash()
|
|||
int i;
|
||||
for (cached = i = 0; i < global.nbthread; i++)
|
||||
cached += entry->cache[i].count;
|
||||
cached_bytes += cached * entry->size;
|
||||
cached_bytes += cached * (ullong)entry->size;
|
||||
}
|
||||
chunk_appendf(&trash, " - Pool %s (%u bytes) : %u allocated (%u bytes), %u used"
|
||||
chunk_appendf(&trash, " - Pool %s (%u bytes) : %u allocated (%llu bytes), %u used"
|
||||
" (~%u by thread caches)"
|
||||
", needed_avg %u, %u failures, %u users, @%p%s\n",
|
||||
entry->name, entry->size, entry->allocated,
|
||||
entry->size * entry->allocated, entry->used,
|
||||
(ullong)entry->size * entry->allocated, entry->used,
|
||||
cached,
|
||||
swrate_avg(entry->needed_avg, POOL_AVG_SAMPLES), entry->failed,
|
||||
entry->users, entry,
|
||||
(entry->flags & MEM_F_SHARED) ? " [SHARED]" : "");
|
||||
|
||||
allocated += entry->allocated * entry->size;
|
||||
used += entry->used * entry->size;
|
||||
allocated += entry->allocated * (ullong)entry->size;
|
||||
used += entry->used * (ullong)entry->size;
|
||||
nbpools++;
|
||||
}
|
||||
chunk_appendf(&trash, "Total: %d pools, %lu bytes allocated, %lu used"
|
||||
" (~%lu by thread caches)"
|
||||
chunk_appendf(&trash, "Total: %d pools, %llu bytes allocated, %llu used"
|
||||
" (~%llu by thread caches)"
|
||||
".\n",
|
||||
nbpools, allocated, used, cached_bytes
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue