diff options
| author | Mohit Agrawal <moagrawal@redhat.com> | 2019-05-09 10:08:25 +0530 | 
|---|---|---|
| committer | Amar Tumballi <amarts@redhat.com> | 2019-05-11 11:10:02 +0000 | 
| commit | 8e1d53f14730ac1b1ca0ce9d9a0ccb32578fd4fb (patch) | |
| tree | 08971dc58a4bb05f14539fb9ad17bcf09f7c0149 /libglusterfs/src | |
| parent | af4d9131c8d09907853ee2f6e30b2a9bd80f3c84 (diff) | |
core: Capture process memory usage at the time of call gf_msg_nomem
Problem: All gluster processes call gf_mgm_nomem while calloc/malloc/realloc
         throw an error but the message does not capture current memory usage of
         gluster process
Solution: Call getrusage to capture current memory usage of gluster
          process
Change-Id: I2e0319da1f33b177fa042fdc9e7268068576c9c3
fixes: bz#1708051
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
Diffstat (limited to 'libglusterfs/src')
| -rw-r--r-- | libglusterfs/src/logging.c | 22 | 
1 files changed, 13 insertions, 9 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index c9d733db99d..f0fb9a097da 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -17,6 +17,7 @@  #include <string.h>  #include <stdlib.h>  #include <syslog.h> +#include <sys/resource.h>  #ifdef HAVE_BACKTRACE  #include <execinfo.h> @@ -1112,6 +1113,7 @@ _gf_msg_nomem(const char *domain, const char *file, const char *function,      glusterfs_ctx_t *ctx = NULL;      int wlen = 0;      int priority; +    struct rusage r_usage;      this = THIS;      ctx = this->ctx; @@ -1137,15 +1139,17 @@ _gf_msg_nomem(const char *domain, const char *file, const char *function,      /* TODO: Currently we print in the enhanced format, with a message ID       * of 0. Need to enhance this to support format as configured */ -    wlen = snprintf(msg, sizeof msg, -                    "[%s.%" GF_PRI_SUSECONDS "] %s [MSGID: %" PRIu64 -                    "]" -                    " [%s:%d:%s] %s: no memory " -                    "available for size (%" GF_PRI_SIZET -                    ")" -                    " [call stack follows]\n", -                    timestr, tv.tv_usec, gf_level_strings[level], (uint64_t)0, -                    basename, line, function, domain, size); +    wlen = snprintf( +        msg, sizeof msg, +        "[%s.%" GF_PRI_SUSECONDS "] %s [MSGID: %" PRIu64 +        "]" +        " [%s:%d:%s] %s: no memory " +        "available for size (%" GF_PRI_SIZET +        ") current memory usage in kilobytes %ld" +        " [call stack follows]\n", +        timestr, tv.tv_usec, gf_level_strings[level], (uint64_t)0, basename, +        line, function, domain, size, +        (!getrusage(RUSAGE_SELF, &r_usage) ? r_usage.ru_maxrss : 0));      if (-1 == wlen) {          ret = -1;          goto out;  | 
