diff options
author | Hui Zhu <teawaterz@linux.alibaba.com> | 2020-12-18 21:18:48 +0800 |
---|---|---|
committer | Wu Fengguang <wfg@mail.ustc.edu.cn> | 2020-12-18 21:18:48 +0800 |
commit | 8c931f0fe125d5d71f92cc38d764ba37044da857 (patch) | |
tree | f84803e3f5ff5cd8aca3645f44352fadd928c095 | |
parent | 98e1853270ec204e21cf64c61af16866d9a67fd4 (diff) | |
download | vm-scalability-8c931f0fe125d5d71f92cc38d764ba37044da857.tar.gz |
usemem: Add option touch-alloc
Some environment will not fault in memory even if MAP_POPULATE is set.
So add option touch-alloc to read memory after allocate it to make
sure the pages is fault in.
Signed-off-by: Hui Zhu <teawaterz@linux.alibaba.com>
-rw-r--r-- | usemem.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -97,6 +97,7 @@ unsigned long opt_delay = 0; int opt_read_again = 0; int opt_punch_holes = 0; int opt_init_time = 0; +int opt_touch_alloc = 0; int nr_task; int nr_thread; int nr_cpu; @@ -157,6 +158,7 @@ void usage(int ok) " -Z|--read-again read memory again after access the memory\n" " --punch-holes free every other page after allocation\n" " --init-time account/show initialization time separately from run time\n" + " --touch-alloc read memory after allocate it\n" " -h|--help show this message\n" , ourname); @@ -197,6 +199,7 @@ static const struct option opts[] = { { "read-again" , 0, NULL, 'Z' }, { "punch-holes" , 0, NULL, 0 }, { "init-time" , 0, NULL, 0 }, + { "touch-alloc" , 0, NULL, 0 }, { "help" , 0, NULL, 'h' }, { NULL , 0, NULL, 0 } }; @@ -326,6 +329,18 @@ void detach(void) } } +unsigned long do_access(unsigned long *p, unsigned long idx, int read) +{ + volatile unsigned long *vp = p; + + if (read) + return vp[idx]; /* read data */ + else { + vp[idx] = idx; /* write data */ + return 0; + } +} + unsigned long * allocate(unsigned long bytes) { unsigned long *p; |