Thread (3 messages) 3 messages, 3 authors, 2021-08-26

Re: [PATCH v2] mm/hugetlb: initialize hugetlb_usage in mm_init

From: Mike Kravetz <hidden>
Date: 2021-08-26 16:19:33
Also in: linux-mm

On 8/26/21 12:17 AM, Liu Zixian wrote:
After fork, the child process will get incorrect (2x) hugetlb_usage.
If a process uses 5 2MB hugetlb pages in an anonymous mapping,
	HugetlbPages:	   10240 kB
and then forks, the child will show,
	HugetlbPages:	   20480 kB
The reason for double the amount is because hugetlb_usage will be
copied from the parent and then increased when we copy page tables
from parent to child. Child will have 2x actual usage.

Fix this by adding hugetlb_count_init in mm_init.

Fixes: 5d317b2b6536 ("mm: hugetlb: proc: add HugetlbPages field to
/proc/PID/status")
Signed-off-by: Liu Zixian <redacted>
---
v2:
1. Create two hugetlb_count_init in hugetlb.h instead of using #ifdef
  in fork.c
2. Add an example to clearify this issue.
---
 include/linux/hugetlb.h | 9 +++++++++
 kernel/fork.c           | 1 +
 2 files changed, 10 insertions(+)
Thanks,

Reviewed-by: Mike Kravetz <redacted>

Andrew, can you add a CC stable?
-- 
Mike Kravetz
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help