rfc: A new tool to implement memory stress #25
rfc: A new tool to implement memory stress #25FingerLeader wants to merge 3 commits intochaos-mesh:mainfrom
Conversation
Signed-off-by: FingerLeader <wanxfinger@gmail.com>
Signed-off-by: FingerLeader <wanxfinger@gmail.com>
|
There is my implementation, PTAL at memStress. |
|
|
||
| Using `syscall.Mmap()` to allocate memory space directly, so that uncertain footprint can be avoided. And write 1 byte on every virtual memory page of the space we allocated can achieve our goal. | ||
|
|
||
| ```data, err := syscall.Mmap(-1, 0, length, syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_PRIVATE|syscall.MAP_ANONYMOUS)``` |
There was a problem hiding this comment.
data, err := syscall.Mmap(-1, 0, length, syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_PRIVATE|syscall.MAP_ANONYMOUS)
There was a problem hiding this comment.
Can you add more introduction about syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_PRIVATE|syscall.MAP_ANONYMOUS
There was a problem hiding this comment.
The parameter syscall.PROT_READ|syscall.PROT_WRITE let us read and write the array data, so we can write some bytes in it to occupy memory page.
And the parameter syscall.MAP_PRIVATE makes the mapping not visible to other processes and are not carried through to the underlying file, syscall.MAP_ANONYMOUS makes the mapping won't be backed by any file. Therefore, the allocated memory will not leave any mark or be accessed.
You can get more information at https://man7.org/linux/man-pages/man2/mmap.2.html.
There was a problem hiding this comment.
You need to add this introduction on RFC
Signed-off-by: FingerLeader wanxfinger@gmail.com