From: Miaohe Lin <linmiaohe@huawei.com>
To: Mike Kravetz <mike.kravetz@oracle.com>, <akpm@linux-foundation.org>
Cc: <n-horiguchi@ah.jp.nec.com>, <hillf.zj@alibaba-inc.com>,
<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>
Subject: Re: [PATCH 4/4] mm/hugeltb: handle the error case in hugetlb_fix_reserve_counts()
Date: Fri, 9 Apr 2021 11:17:49 +0800 [thread overview]
Message-ID: <fe37dcbd-5604-8b43-c184-b7d991b16de8@huawei.com> (raw)
In-Reply-To: <a61335c2-c6ab-6169-012c-5b5d2d9499da@oracle.com>
On 2021/4/9 7:25, Mike Kravetz wrote:
> On 4/2/21 2:32 AM, Miaohe Lin wrote:
>> A rare out of memory error would prevent removal of the reserve map region
>> for a page. hugetlb_fix_reserve_counts() handles this rare case to avoid
>> dangling with incorrect counts. Unfortunately, hugepage_subpool_get_pages
>> and hugetlb_acct_memory could possibly fail too. We should correctly handle
>> these cases.
>
> Yes, this is a potential issue.
>
> The 'good news' is that hugetlb_fix_reserve_counts() is unlikely to ever
> be called. To do so would imply we could not allocate a region entry
> which is only 6 words in size. We also keep a 'cache' of entries so we
> may not even need to allocate.
>
> But, as mentioned it is a potential issue.
Yes, a potential *theoretical* issue.
>
>> Fixes: b5cec28d36f5 ("hugetlbfs: truncate_hugepages() takes a range of pages")
>
> This is likely going to make this get picked by by stable releases.
> That is unfortunate as mentioned above this is mostly theoretical.
>
I will drop this. This does not worth backport.
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>> mm/hugetlb.c | 11 +++++++++--
>> 1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>> index bdff8d23803f..ca5464ed04b7 100644
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -745,13 +745,20 @@ void hugetlb_fix_reserve_counts(struct inode *inode)
>> {
>> struct hugepage_subpool *spool = subpool_inode(inode);
>> long rsv_adjust;
>> + bool reserved = false;
>>
>> rsv_adjust = hugepage_subpool_get_pages(spool, 1);
>> - if (rsv_adjust) {
>> + if (rsv_adjust > 0) {
>> struct hstate *h = hstate_inode(inode);
>>
>> - hugetlb_acct_memory(h, 1);
>> + if (!hugetlb_acct_memory(h, 1))
>> + reserved = true;
>> + } else if (!rsv_adjust) {
>> + reserved = true;
>> }
>> +
>> + if (!reserved)
>> + pr_warn("hugetlb: fix reserve count failed\n");
>
> We should expand this warning message a bit to indicate what this may
> mean to the user. Add something like"
> "Huge Page Reserved count may go negative".
>
Will add it in v2. Many thanks for review and nice suggestion ! :)
next prev parent reply other threads:[~2021-04-09 3:17 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-02 9:32 [PATCH 0/4] Cleanup and fixup for hugetlb Miaohe Lin
2021-04-02 9:32 ` [PATCH 1/4] mm/hugeltb: remove redundant VM_BUG_ON() in region_add() Miaohe Lin
2021-04-07 0:16 ` Mike Kravetz
2021-04-02 9:32 ` [PATCH 2/4] mm/hugeltb: simplify the return code of __vma_reservation_common() Miaohe Lin
2021-04-07 0:53 ` Mike Kravetz
2021-04-07 2:05 ` Miaohe Lin
2021-04-07 2:37 ` Mike Kravetz
2021-04-07 3:09 ` Miaohe Lin
2021-04-07 21:23 ` Mike Kravetz
2021-04-08 2:44 ` Miaohe Lin
2021-04-08 22:40 ` Mike Kravetz
2021-04-09 2:52 ` Miaohe Lin
2021-04-02 9:32 ` [PATCH 3/4] mm/hugeltb: fix potential wrong gbl_reserve value for hugetlb_acct_memory() Miaohe Lin
2021-04-07 2:49 ` Mike Kravetz
2021-04-07 7:24 ` Miaohe Lin
2021-04-07 20:53 ` Mike Kravetz
2021-04-08 3:24 ` Miaohe Lin
2021-04-08 3:26 ` Miaohe Lin
2021-04-08 22:53 ` Mike Kravetz
2021-04-09 3:01 ` Miaohe Lin
2021-04-09 4:37 ` Mike Kravetz
2021-04-09 6:36 ` Miaohe Lin
2021-04-02 9:32 ` [PATCH 4/4] mm/hugeltb: handle the error case in hugetlb_fix_reserve_counts() Miaohe Lin
2021-04-08 23:25 ` Mike Kravetz
2021-04-09 3:17 ` Miaohe Lin [this message]
2021-04-09 5:04 ` Andrew Morton
2021-04-09 7:07 ` Miaohe Lin
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=fe37dcbd-5604-8b43-c184-b7d991b16de8@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=hillf.zj@alibaba-inc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=n-horiguchi@ah.jp.nec.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