Fix write/read_hugepage() for copy-on-write.
When the cowflag is valid, child process should copy all the hugepage of
its parent. But now no matter what cowflag is, the child process will not do
copy-on-write operation. It is because the parameter(size==0) of
write_hugepage() make write_hugepage() do nothing.
This problem is introduced by
commit c6a4c3d950385063db705e520bc9b6cda9587f57
Author: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
With this patch, the state of parent and child processes will be like following:
Before this patch After this patch
NO-COW Parent and child processes are killed. Same as before.
COW Parent and child processes are killed. Only parent process is killed.
(Here process is killed by memory-failure.)
Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
Acked-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
diff --git a/tsrc/thugetlb.c b/tsrc/thugetlb.c
index 28a1f10..0f07a6a 100644
--- a/tsrc/thugetlb.c
+++ b/tsrc/thugetlb.c
@@ -259,8 +259,8 @@
if (!pid) {
/* Semaphore is already held */
if (cowflag) {
- write_hugepage(addr, 0, expected_addr);
- read_hugepage(addr, 0, expected_addr);
+ write_hugepage(addr, file_size, 0);
+ read_hugepage(addr, file_size, 0);
}
if (put_semaphore(semid, &sembuffer))
err("put_semaphore");