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 <>

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 <>
Acked-by: Naoya Horiguchi <>
Signed-off-by: Andi Kleen <>
1 file changed