The branch, master has been updated
       via  15afc4fb18f s3-messages: add mallinfo() information to pool-usage 
report
       via  b4d4778dd2c s3-messages: modify msg_pool_usage() to allow enhanced 
memory reports
      from  00874b61444 python join: Set index transaction cache size.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 15afc4fb18f937bf4f7008b161a29256cd8660ea
Author: Ralph Wuerthner <[email protected]>
Date:   Fri Mar 29 12:44:50 2019 +0100

    s3-messages: add mallinfo() information to pool-usage report
    
    Signed-off-by: Ralph Wuerthner <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>
    
    Autobuild-User(master): Christof Schmitt <[email protected]>
    Autobuild-Date(master): Thu Apr  4 23:39:25 UTC 2019 on sn-devel-144

commit b4d4778dd2c5831204fb484a6c6872ab3cbebf01
Author: Ralph Wuerthner <[email protected]>
Date:   Fri Mar 29 12:30:45 2019 +0100

    s3-messages: modify msg_pool_usage() to allow enhanced memory reports
    
    Signed-off-by: Ralph Wuerthner <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/tallocmsg.c | 71 ++++++++++++++++++++++++++++++++++++++++++++-----
 source3/wscript         | 12 +++++++++
 2 files changed, 77 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/tallocmsg.c b/source3/lib/tallocmsg.c
index 18b16edfc8f..9be1bf58a3c 100644
--- a/source3/lib/tallocmsg.c
+++ b/source3/lib/tallocmsg.c
@@ -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.
@@ -30,21 +69,41 @@ static void msg_pool_usage(struct messaging_context 
*msg_ctx,
                           struct server_id src,
                           DATA_BLOB *data)
 {
-       char *report;
+       char *report = NULL;
+       char *mreport = NULL;
+       int iov_size = 0;
+       struct iovec iov[2];
 
        SMB_ASSERT(msg_type == MSG_REQ_POOL_USAGE);
 
        DEBUG(2,("Got POOL_USAGE\n"));
 
        report = talloc_report_str(msg_ctx, NULL);
-
        if (report != NULL) {
-               messaging_send_buf(msg_ctx, src, MSG_POOL_USAGE,
-                                  (uint8_t *)report,
-                                  talloc_get_size(report)-1);
+               iov[iov_size].iov_base = report;
+               iov[iov_size].iov_len = talloc_get_size(report) - 1;
+               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,
+                                  MSG_POOL_USAGE,
+                                  iov,
+                                  iov_size,
+                                  NULL,
+                                  0);
        }
 
-       talloc_free(report);
+       TALLOC_FREE(report);
+       TALLOC_FREE(mreport);
 }
 
 /**
diff --git a/source3/wscript b/source3/wscript
index c93b6056f29..97b51bb1a3e 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -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)
     #


-- 
Samba Shared Repository

Reply via email to