Skip to content

Commit

Permalink
stress-mmaptorture: increase size default to 256MB, add random ftruncate
Browse files Browse the repository at this point in the history
on file

Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
ColinIanKing committed Feb 19, 2025
1 parent 8dd49e0 commit e3dc713
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions stress-mmaptorture.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef struct {

#define MIN_MMAPTORTURE_BYTES (16 * MB)
#define MAX_MMAPTORTURE_BYTES (MAX_MEM_LIMIT)
#define DEFAULT_MMAPTORTURE_BYTES (1024 * 4096)
#define DEFAULT_MMAPTORTURE_BYTES (256 * MB)

typedef struct {
uint64_t mmap_pages;
Expand Down Expand Up @@ -266,7 +266,7 @@ static void stress_mmaptorture_init(const uint32_t num_instances)
}
(void)unlink(path);

VOID_RET(int, ftruncate(mmap_fd, mmap_bytes));
VOID_RET(int, ftruncate(mmap_fd, (off_t)mmap_bytes));
mmap_data = mmap(NULL, mmap_bytes, PROT_READ | PROT_WRITE, MAP_SHARED, mmap_fd, 0);
}

Expand Down Expand Up @@ -367,7 +367,8 @@ static int stress_mmaptorture_child(stress_args_t *args, void *context)
if (sigsetjmp(jmp_env, 1))
goto mappings_unmap;

VOID_RET(int, ftruncate(mmap_fd, 0));
VOID_RET(int, ftruncate(mmap_fd, (off_t)stress_mwc64modn((uint64_t)mmap_bytes)));
VOID_RET(int, ftruncate(mmap_fd, (off_t)mmap_bytes));

offset = stress_mwc64modn((uint64_t)mmap_bytes) & page_mask;
if (lseek(mmap_fd, offset, SEEK_SET) == offset) {
Expand Down
2 changes: 1 addition & 1 deletion stress-ng.1
Original file line number Diff line number Diff line change
Expand Up @@ -5271,7 +5271,7 @@ CPUs.
.TP
.B \-\-mmaptorture\-bytes N
allocate N bytes in total for all the mmaptorture stressor instances, the default is
16 MB. One can specify the size as % of total available memory or in units of
256 MB. One can specify the size as % of total available memory or in units of
Bytes, KBytes, MBytes and GBytes using the suffix b, k, m or g.
.TP
.B \-\-mmaptorture\-msync N
Expand Down

0 comments on commit e3dc713

Please sign in to comment.