-
Notifications
You must be signed in to change notification settings - Fork 23
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
rfc: A new tool to implement memory stress #25
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: FingerLeader <[email protected]>
Signed-off-by: FingerLeader <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add this introduction on RFC
Signed-off-by: FingerLeader [email protected]