From: Mike Kravetz <mike.kravetz@oracle.com>
To: Liu Zixian <liuzixian4@huawei.com>,
linux-mm@kvack.org, akpm@linux-foundation.org
Cc: naoya.horiguchi@nec.com, stable@vger.kernel.org, wuxu.wu@huawei.com
Subject: Re: [PATCH v2] mm/hugetlb: initialize hugetlb_usage in mm_init
Date: Thu, 26 Aug 2021 09:19:14 -0700 [thread overview]
Message-ID: <80f1b2e4-9aa3-931a-7470-fd129639ea7b@oracle.com> (raw)
In-Reply-To: <20210826071742.877-1-liuzixian4@huawei.com>
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@huawei.com>
> ---
> 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@oracle.com>
Andrew, can you add a CC stable?
--
Mike Kravetz
prev parent reply other threads:[~2021-08-26 16:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-26 7:17 [PATCH v2] mm/hugetlb: initialize hugetlb_usage in mm_init Liu Zixian
2021-08-26 7:29 ` HORIGUCHI NAOYA(堀口 直也)
2021-08-26 16:19 ` Mike Kravetz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=80f1b2e4-9aa3-931a-7470-fd129639ea7b@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=liuzixian4@huawei.com \
--cc=naoya.horiguchi@nec.com \
--cc=stable@vger.kernel.org \
--cc=wuxu.wu@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).