summaryrefslogtreecommitdiff
path: root/src/zmalloc.c
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2021-01-08 23:35:30 +0200
committerGitHub <noreply@github.com>2021-01-08 23:35:30 +0200
commit8dd16caec833aebde3a12c7d7f9b6456554c8616 (patch)
tree858520e83b712d5c39097e8a046e127ccad83286 /src/zmalloc.c
parentea5350c5ecb08d8915bd59b2dc98982454adc9f7 (diff)
downloadredis-8dd16caec833aebde3a12c7d7f9b6456554c8616.tar.gz
Fix last COW INFO report, Skip test on non-linux platforms (#8301)
- the last COW report wasn't always read from the pipe (receiveLastChildInfo wasn't used) - but in fact, there's no reason we won't always try to drain that pipe so i'm unifying receiveLastChildInfo with receiveChildInfo - adjust threshold of the COW test when run in accurate mode - add some prints in case this test fails again - fix indentation, page size, and PID! in MacOS proc info p.s. it seems that pri_pages_dirtied is always 0
Diffstat (limited to 'src/zmalloc.c')
-rw-r--r--src/zmalloc.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/zmalloc.c b/src/zmalloc.c
index 86b15b0ee..eacce67bd 100644
--- a/src/zmalloc.c
+++ b/src/zmalloc.c
@@ -580,15 +580,18 @@ size_t zmalloc_get_smap_bytes_by_field(char *field, long pid) {
size_t zmalloc_get_smap_bytes_by_field(char *field, long pid) {
#if defined(__APPLE__)
struct proc_regioninfo pri;
- if (proc_pidinfo(pid, PROC_PIDREGIONINFO, 0, &pri, PROC_PIDREGIONINFO_SIZE) ==
- PROC_PIDREGIONINFO_SIZE) {
- if (!strcmp(field, "Private_Dirty:")) {
- return (size_t)pri.pri_pages_dirtied * 4096;
- } else if (!strcmp(field, "Rss:")) {
- return (size_t)pri.pri_pages_resident * 4096;
- } else if (!strcmp(field, "AnonHugePages:")) {
+ if (pid == -1) pid = getpid();
+ if (proc_pidinfo(pid, PROC_PIDREGIONINFO, 0, &pri,
+ PROC_PIDREGIONINFO_SIZE) == PROC_PIDREGIONINFO_SIZE)
+ {
+ int pagesize = getpagesize();
+ if (!strcmp(field, "Private_Dirty:")) {
+ return (size_t)pri.pri_pages_dirtied * pagesize;
+ } else if (!strcmp(field, "Rss:")) {
+ return (size_t)pri.pri_pages_resident * pagesize;
+ } else if (!strcmp(field, "AnonHugePages:")) {
return 0;
- }
+ }
}
return 0;
#endif