mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
s3-messages: add mallinfo() information to pool-usage report
Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Autobuild-User(master): Christof Schmitt <cs@samba.org> Autobuild-Date(master): Thu Apr 4 23:39:25 UTC 2019 on sn-devel-144
This commit is contained in:
parent
b4d4778dd2
commit
15afc4fb18
@ -19,7 +19,46 @@
|
||||
#include "includes.h"
|
||||
#include "messages.h"
|
||||
#include "lib/util/talloc_report.h"
|
||||
#ifdef HAVE_MALLINFO
|
||||
#include <malloc.h>
|
||||
#endif /* HAVE_MALLINFO */
|
||||
|
||||
/**
|
||||
* Prepare memory allocation report based on mallinfo()
|
||||
**/
|
||||
static char *get_mallinfo_report(void *mem_ctx)
|
||||
{
|
||||
char *report = NULL;
|
||||
#ifdef HAVE_MALLINFO
|
||||
struct mallinfo mi;
|
||||
|
||||
mi = mallinfo();
|
||||
report = talloc_asprintf(mem_ctx,
|
||||
"mallinfo:\n"
|
||||
" arena: %d\n"
|
||||
" ordblks: %d\n"
|
||||
" smblks: %d\n"
|
||||
" hblks: %d\n"
|
||||
" hblkhd: %d\n"
|
||||
" usmblks: %d\n"
|
||||
" fsmblks: %d\n"
|
||||
" uordblks: %d\n"
|
||||
" fordblks: %d\n"
|
||||
" keepcost: %d\n",
|
||||
mi.arena,
|
||||
mi.ordblks,
|
||||
mi.smblks,
|
||||
mi.hblks,
|
||||
mi.hblkhd,
|
||||
mi.usmblks,
|
||||
mi.fsmblks,
|
||||
mi.uordblks,
|
||||
mi.fordblks,
|
||||
mi.keepcost);
|
||||
#endif /* HAVE_MALLINFO */
|
||||
|
||||
return report;
|
||||
}
|
||||
/**
|
||||
* Respond to a POOL_USAGE message by sending back string form of memory
|
||||
* usage stats.
|
||||
@ -31,8 +70,9 @@ static void msg_pool_usage(struct messaging_context *msg_ctx,
|
||||
DATA_BLOB *data)
|
||||
{
|
||||
char *report = NULL;
|
||||
char *mreport = NULL;
|
||||
int iov_size = 0;
|
||||
struct iovec iov[1];
|
||||
struct iovec iov[2];
|
||||
|
||||
SMB_ASSERT(msg_type == MSG_REQ_POOL_USAGE);
|
||||
|
||||
@ -45,6 +85,13 @@ static void msg_pool_usage(struct messaging_context *msg_ctx,
|
||||
iov_size++;
|
||||
}
|
||||
|
||||
mreport = get_mallinfo_report(msg_ctx);
|
||||
if (mreport != NULL) {
|
||||
iov[iov_size].iov_base = mreport;
|
||||
iov[iov_size].iov_len = talloc_get_size(mreport) - 1;
|
||||
iov_size++;
|
||||
}
|
||||
|
||||
if (iov_size) {
|
||||
messaging_send_iov(msg_ctx,
|
||||
src,
|
||||
@ -56,6 +103,7 @@ static void msg_pool_usage(struct messaging_context *msg_ctx,
|
||||
}
|
||||
|
||||
TALLOC_FREE(report);
|
||||
TALLOC_FREE(mreport);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1517,6 +1517,18 @@ main() {
|
||||
define='HAVE_UNSHARE_CLONE_FS',
|
||||
msg='for Linux unshare(CLONE_FS)')
|
||||
|
||||
# Check for mallinfo
|
||||
conf.CHECK_CODE('''
|
||||
struct mallinfo mi;
|
||||
int tmp;
|
||||
|
||||
mi = mallinfo();
|
||||
tmp = mi.arena + mi.ordblks + mi.smblks + mi.hblks +
|
||||
mi.hblkhd + mi.usmblks + mi.fsmblks + mi.uordblks +
|
||||
mi.fordblks + mi.keepcost;
|
||||
return tmp;
|
||||
''', 'HAVE_MALLINFO', msg="Checking for mallinfo()", headers='malloc.h')
|
||||
|
||||
#
|
||||
# cluster support (CTDB)
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user