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 <liuzixian4@xxxxxxxxxx> > --- > 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 <mike.kravetz@xxxxxxxxxx> Andrew, can you add a CC stable? -- Mike Kravetz