From: Mike Kravetz <mike.kravetz@oracle.com>
To: Yufen Yu <yuyufen@huawei.com>, linux-mm@kvack.org
Subject: Re: [PATCH v2] hugetlbfs: fix memory leak for resv_map
Date: Wed, 6 Mar 2019 15:52:37 -0800 [thread overview]
Message-ID: <ac030f5b-3d9c-9a71-bd39-1c1f707bc931@oracle.com> (raw)
In-Reply-To: <20190306061007.61645-1-yuyufen@huawei.com>
On 3/5/19 10:10 PM, Yufen Yu wrote:
> When .mknod create a block device file in hugetlbfs, it will
> allocate an inode, and kmalloc a 'struct resv_map' in resv_map_alloc().
> For now, inode->i_mapping->private_data is used to point the resv_map.
> However, when open the device, bd_acquire() will set i_mapping as
> bd_inode->imapping, result in resv_map memory leak.
>
> We fix it by waiting until a call to hugetlb_reserve_pages() to allocate
> the inode specific resv_map. We could then remove the resv_map allocation
> at inode creation time.
>
> Programs to reproduce:
> mount -t hugetlbfs nodev hugetlbfs
> mknod hugetlbfs/dev b 0 0
> exec 30<> hugetlbfs/dev
> umount hugetlbfs/
>
> Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Thank you. That is the approach I had in mind.
Unfortunately, this patch causes several regressions in the libhugetlbfs
test suite. I have not debugged to determine exact cause.
I was unsure about one thing with this approach. We set
inode->i_mapping->private_data while holding the inode lock, so there
should be no problem there. However, we access inode_resv_map() in the
page fault path without the inode lock. The page fault path should get
NULL or a resv_map. I just wonder if there may be some races where the
fault path may still be seeing NULL.
I can do more debug, but it will take a couple days as I am busy with
other things right now.
--
Mike Kravetz
next prev parent reply other threads:[~2019-03-06 23:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-06 6:10 Yufen Yu
2019-03-06 23:52 ` Mike Kravetz [this message]
2019-03-07 23:50 ` Mike Kravetz
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=ac030f5b-3d9c-9a71-bd39-1c1f707bc931@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=linux-mm@kvack.org \
--cc=yuyufen@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