-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crit: add method to retrieve shared memory size of process #146
crit: add method to retrieve shared memory size of process #146
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #146 +/- ##
==========================================
+ Coverage 49.49% 50.50% +1.01%
==========================================
Files 24 24
Lines 2760 2865 +105
==========================================
+ Hits 1366 1447 +81
- Misses 1203 1220 +17
- Partials 191 198 +7
☔ View full report in Codecov by Sentry. |
In Linux we have two types of shared memory: POSIX and System V shared memory.
We can identify shared memory in sudo crit show mm-46373.img
...
{
"start": "0x7fb90ef70000",
"end": "0x7fb90ef73000",
"pgoff": 0,
"shmid": 3,
"prot": "PROT_READ | PROT_WRITE",
"flags": "MAP_SHARED",
"status": "VMA_AREA_REGULAR | VMA_FILE_SHARED",
"fd": -1,
"fdflags": "0x2"
}, sudo crit show mm-56.img
...
{
"start": "0x7f6132b7c000",
"end": "0x7f6132b7d000",
"pgoff": 81920,
"shmid": 3,
"prot": "PROT_READ | PROT_WRITE",
"flags": "MAP_SHARED",
"status": "VMA_AREA_REGULAR | VMA_FILE_SHARED | 0x4000",
"fd": -1,
"fdflags": "0x2"
}, |
9b20ebf
to
0e62418
Compare
This commit adds a method on MemoryReader to retrieve the size of process's shared memory. The function iterates over the virtual memory areas (VMAs) associated with the process, summing up the sizes of VMAs that have `MAP_SHARED` flag set. Signed-off-by: Kouame Behouba Manasse <behouba@gmail.com>
0e62418
to
bd5203d
Compare
a5496b4
to
e1aa06a
Compare
e1aa06a
to
6ec0ba3
Compare
This commit introduces a new test program called `mmapper`. `mmapper` is a simple C program that accepts three arguments: the memory size, mmap flags (a combinaison of `s` for `MAP_SHARED`, `p` for `MAP_PRIVATE`, and optionally `a` for `MAP_ANONYMOUS`). It then creates a child process with the corresponding memory mapping of the specified size. This program is used for testing the accuracy of the `GetShmemSize()` method of `MemoryReader`struct. Signed-off-by: Kouame Behouba Manasse <behouba@gmail.com>
6ec0ba3
to
02d11ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR aims to add a method for retrieving the size of shared memory of processes. The function iterates over the virtual memory areas (VMAs) associated with the process, summing up the sizes of VMAs with the
MAP_SHARED
flag.@rst0git PTAL, is this approach accurate ?