Changeset 21d3542 for memlog.cpp
- Timestamp:
- 06/02/15 16:50:48 (9 years ago)
- Branches:
- master
- Children:
- 6444e03
- Parents:
- 192a260
- git-author:
- Hal Finkel <hfinkel@…> (06/02/15 16:50:48)
- git-committer:
- Hal Finkel <hfinkel@…> (06/02/15 16:50:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
memlog.cpp
r22f928f r21d3542 6 6 #include <cstdio> 7 7 #include <cstring> 8 #include <cstdint> 8 9 9 10 // NOTE: This source makes very minimal use of C++11 features. It can still be … … 29 30 #ifdef __bgq__ 30 31 #include <spi/include/kernel/location.h> 32 #include <spi/include/kernel/memory.h> 31 33 #endif 32 34 … … 45 47 static char self_path[PATH_MAX+1] = { '\0' }; 46 48 49 #ifdef __bgq__ 50 int on_bgq = 0; 51 #endif 52 53 void *initial_brk = 0; 54 47 55 __attribute__((__constructor__)) 48 56 static void record_init() { … … 54 62 // If we're really running on a BG/Q compute node, use the job rank instead 55 63 // of the pid because the node name might not really be globally unique. 56 if (!strcmp(u.sysname, "CNK") && !strcmp(u.machine, "BGQ")) 64 if (!strcmp(u.sysname, "CNK") && !strcmp(u.machine, "BGQ")) { 57 65 id = (int) Kernel_GetRank(); 66 on_bgq = 1; 67 } 58 68 #endif 59 69 … … 81 91 const char *link_name = "/proc/self/exe"; 82 92 readlink(link_name, self_path, PATH_MAX); 93 94 initial_brk = sbrk(0); 83 95 } 84 96 … … 128 140 fprintf(log_file, "\t%ld.%06ld %ld %ld", usage.ru_utime.tv_sec, 129 141 usage.ru_utime.tv_usec, usage.ru_maxrss, syscall(SYS_gettid)); 142 143 // Some other memory stats (like with maxrss, report these in KB). 144 size_t arena_size = ((size_t) sbrk(0)) - (size_t) initial_brk; 145 146 uint64_t mmap_size = 0; 147 #ifdef __bgq__ 148 if (on_bgq) 149 (void) Kernel_GetMemorySize(KERNEL_MEMSIZE_MMAP, &mmap_size); 150 #endif 151 152 fprintf(log_file, " %ld %ld", arena_size >> 10, mmap_size >> 10); 130 153 131 154 if (!show_backtrace)
Note: See TracChangeset
for help on using the changeset viewer.