Skip to content

Commit

Permalink
current_process_memory_usage: Better document what happens with inacc…
Browse files Browse the repository at this point in the history
…urate commit charge calculation on older Linux kernels.
  • Loading branch information
ned14 committed Aug 30, 2021
1 parent 8cec4ff commit bcc600d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 3 additions & 3 deletions include/llfio/revision.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
#define LLFIO_PREVIOUS_COMMIT_REF 46f0760e7ed2b80c46acd91bacc130049620bee6
#define LLFIO_PREVIOUS_COMMIT_DATE "2021-08-21 13:31:38 +00:00"
#define LLFIO_PREVIOUS_COMMIT_UNIQUE 46f0760e
#define LLFIO_PREVIOUS_COMMIT_REF 8cec4ff8fcd601b774c0ed882fe869e73d23d136
#define LLFIO_PREVIOUS_COMMIT_DATE "2021-08-30 14:53:35 +00:00"
#define LLFIO_PREVIOUS_COMMIT_UNIQUE 8cec4ff8
13 changes: 11 additions & 2 deletions include/llfio/v2.0/detail/impl/posix/utils.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ namespace utils
(values are in pages)
/proc/[pid]/smaps_rollup:
/proc/[pid]/smaps_rollup (Linux 3.16 onwards only):
total_address_space_in_use = ??? MISSING
total_address_space_paged_in = ??? MISSING
Expand Down Expand Up @@ -363,7 +363,16 @@ namespace utils
if(want & process_memory_usage::want::private_committed)
{
std::vector<char> smaps_rollup(256), maps(65536);
OUTCOME_TRY(fill_buffer(smaps_rollup, "/proc/self/smaps_rollup"));
auto r = fill_buffer(smaps_rollup, "/proc/self/smaps_rollup");
if(!r)
{
if(r.error() == errc::no_such_file_or_directory)
{
// Linux kernel is too old
return errc::operation_not_supported;
}
return std::move(r).error();
}
OUTCOME_TRY(fill_buffer(maps, "/proc/self/maps"));
uint64_t lazyfree = 0;
{
Expand Down
8 changes: 8 additions & 0 deletions include/llfio/v2.0/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ namespace utils
cannot distinguish between regions with the accounted
flag enabled or disabled. By default, this fast path is enabled.
\note `/proc/pid/smaps_rollup` was added in Linux kernel 3.16, so the default specifying
`process_memory_usage::want::private_committed_inaccurate` will always fail on Linux
kernels preceding that with an error code comparing equal to `errc::operation_not_supported`.
As one would assume users would prefer this operation to fail on older kernels rather than
silently go slowly in complex memory spaces, it is left opt-in to request
the accurate implementation which works on older Linux kernels. Or, just don't request
`private_committed` at all, and pretend `private_paged_in` means the same thing.
\note Mac OS provides no way of reading how much memory a process has committed.
We therefore supply as `private_committed` the same value as `private_paged_in`.
*/
Expand Down

0 comments on commit bcc600d

Please sign in to comment.