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