|
|
74b1de |
From 55d47524c0c8a88204129c3a94d71779aae00beb Mon Sep 17 00:00:00 2001
|
|
|
74b1de |
From: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
74b1de |
Date: Tue, 28 May 2019 08:18:12 +0530
|
|
|
74b1de |
Subject: [PATCH 145/169] core: Capture process memory usage at the time of
|
|
|
74b1de |
call gf_msg_nomem
|
|
|
74b1de |
|
|
|
74b1de |
Problem: All gluster processes call gf_mgm_nomem while calloc/malloc/realloc
|
|
|
74b1de |
throw an error but the message does not capture current memory usage of
|
|
|
74b1de |
gluster process
|
|
|
74b1de |
|
|
|
74b1de |
Solution: Call getrusage to capture current memory usage of gluster
|
|
|
74b1de |
process
|
|
|
74b1de |
|
|
|
74b1de |
> Change-Id: I2e0319da1f33b177fa042fdc9e7268068576c9c3
|
|
|
74b1de |
> fixes: bz#1708051
|
|
|
74b1de |
> Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/22688/
|
|
|
74b1de |
> Cherry pick from commit 8e1d53f14730ac1b1ca0ce9d9a0ccb32578fd4fb
|
|
|
74b1de |
|
|
|
74b1de |
BUG: 1709087
|
|
|
74b1de |
Change-Id: I2e0319da1f33b177fa042fdc9e7268068576c9c3
|
|
|
74b1de |
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
74b1de |
Reviewed-on: https://code.engineering.redhat.com/gerrit/171587
|
|
|
74b1de |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
74b1de |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
74b1de |
---
|
|
|
74b1de |
libglusterfs/src/logging.c | 7 +++++--
|
|
|
74b1de |
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
74b1de |
|
|
|
74b1de |
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
|
|
|
74b1de |
index 5d46916..7f0eff6 100644
|
|
|
74b1de |
--- a/libglusterfs/src/logging.c
|
|
|
74b1de |
+++ b/libglusterfs/src/logging.c
|
|
|
74b1de |
@@ -17,6 +17,7 @@
|
|
|
74b1de |
#include <string.h>
|
|
|
74b1de |
#include <stdlib.h>
|
|
|
74b1de |
#include <syslog.h>
|
|
|
74b1de |
+#include <sys/resource.h>
|
|
|
74b1de |
|
|
|
74b1de |
#ifdef HAVE_BACKTRACE
|
|
|
74b1de |
#include <execinfo.h>
|
|
|
74b1de |
@@ -1196,6 +1197,7 @@ _gf_msg_nomem(const char *domain, const char *file, const char *function,
|
|
|
74b1de |
glusterfs_ctx_t *ctx = NULL;
|
|
|
74b1de |
int wlen = 0;
|
|
|
74b1de |
int priority;
|
|
|
74b1de |
+ struct rusage r_usage;
|
|
|
74b1de |
|
|
|
74b1de |
this = THIS;
|
|
|
74b1de |
ctx = this->ctx;
|
|
|
74b1de |
@@ -1231,10 +1233,11 @@ _gf_msg_nomem(const char *domain, const char *file, const char *function,
|
|
|
74b1de |
"]"
|
|
|
74b1de |
" [%s:%d:%s] %s: no memory "
|
|
|
74b1de |
"available for size (%" GF_PRI_SIZET
|
|
|
74b1de |
- ")"
|
|
|
74b1de |
+ ") current memory usage in kilobytes %ld"
|
|
|
74b1de |
" [call stack follows]\n",
|
|
|
74b1de |
timestr, gf_level_strings[level], (uint64_t)0, basename,
|
|
|
74b1de |
- line, function, domain, size);
|
|
|
74b1de |
+ line, function, domain, size,
|
|
|
74b1de |
+ (!getrusage(RUSAGE_SELF, &r_usage) ? r_usage.ru_maxrss : 0));
|
|
|
74b1de |
if (-1 == ret) {
|
|
|
74b1de |
goto out;
|
|
|
74b1de |
}
|
|
|
74b1de |
--
|
|
|
74b1de |
1.8.3.1
|
|
|
74b1de |
|