Skip to content

Commit

Permalink
posix::securerunner: Change VSS memory limit to RSS memory limit
Browse files Browse the repository at this point in the history
  • Loading branch information
HarmlessEvil committed Jul 16, 2018
1 parent 58140a9 commit 3b78b11
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libspawner/inc/posix/linux_procfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct procfs_class {
size_t read_bytes, write_bytes; // io file: i/o from block-backed storages
size_t stat_utime, stat_stime;
size_t stat_vsize, stat_rss;
size_t vss_max = 0;
size_t vss_max = 0, rss_max = 0;

std::string io_path, stat_path;

Expand Down
6 changes: 5 additions & 1 deletion libspawner/src/posix/linux_procfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,17 @@ bool procfs_class::fill_stat() {
}
} while ((strsep(&token, " ") != nullptr) || (index <= STAT_LAST));

static const int memory_page_size = sysconf(_SC_PAGESIZE);

stat_utime = utime;
stat_stime = stime;
stat_vsize = vsize;
stat_rss = rss;
stat_rss = rss * memory_page_size;

if (vsize > vss_max)
vss_max = vsize;
if (rss > rss_max)
rss_max = rss;
//printf("%lu %lu %lu %lu\n", utime, stime, vsize, rss);

return true;
Expand Down
4 changes: 2 additions & 2 deletions libspawner/src/posix/securerunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ report_class secure_runner::get_report() {
// non linux OSes will get ru_maxrss from getrusage
#if defined(__linux__)
report.write_transfer_count = proc.discovered ? proc.write_bytes : 0;
report.peak_memory_used = proc.discovered ? proc.vss_max : 0;
report.peak_memory_used = proc.discovered ? proc.rss_max : 0;
#endif
return runner::get_report();
}
Expand Down Expand Up @@ -258,7 +258,7 @@ void secure_runner::check_limits_proc() {
}

if (check_restriction(restriction_memory_limit) &&
proc.vss_max > get_restriction(restriction_memory_limit)
proc.rss_max > get_restriction(restriction_memory_limit)
) {
terminate_reason = terminate_reason_memory_limit;
process_status = process_finished_terminated;
Expand Down

0 comments on commit 3b78b11

Please sign in to comment.