aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiaolong Ye <xiaolong.ye@intel.com>2016-02-04 10:49:01 +0800
committerFengguang Wu <fengguang.wu@intel.com>2016-02-04 10:49:01 +0800
commita5006817a51a093ba88c44449215c51b461c852d (patch)
tree4f4af75531250a3918852d2db2e671d283e96d73
parent828f30884a5f875b8b029983b1b1e1042dc6a5b6 (diff)
downloadvm-scalability-a5006817a51a093ba88c44449215c51b461c852d.tar.gz
usemem_remap.c: fix remap failed issue when size is pagesize aligned
2015-11-09 09:56:42 truncate /tmp/vm-scalability-tmp/vm-scalability/sparse-remap-1 -s 514191360 2015-11-09 09:56:42 truncate /tmp/vm-scalability-tmp/vm-scalability/sparse-remap-2 -s 514191360 2015-11-09 09:56:42 truncate /tmp/vm-scalability-tmp/vm-scalability/sparse-remap-3 -s 514191360 2015-11-09 09:56:43 truncate /tmp/vm-scalability-tmp/vm-scalability/sparse-remap-4 -s 514191360 ==> /tmp/stderr <== remap failed with error Invalid argument remap failed with error Invalid argument remap failed with error Invalid argument remap failed with error Invalid argument Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
-rw-r--r--usemem_remap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usemem_remap.c b/usemem_remap.c
index bffb52a..1f900fd 100644
--- a/usemem_remap.c
+++ b/usemem_remap.c
@@ -34,7 +34,7 @@ int main (int argc, char *argv[])
}
size = atol(argv[2]);
- no_of_pages = size / pagesize;
+ no_of_pages = (size + pagesize - 1) / pagesize;
if ((fd = open(argv[1], O_RDWR | O_CREAT, 0666)) == -1) {
fprintf(stderr, "error opening file\n");
@@ -49,7 +49,7 @@ int main (int argc, char *argv[])
exit(1);
}
- end = (unsigned char *) (start + size);
+ end = (unsigned char *) (start + (no_of_pages - 1) * pagesize);
/* make mapping non-contiguous (reverse the page mapping order) */
for (i = 0; i < no_of_pages / 2; i++) {