qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Linhaifeng <haifeng.lin@huawei.com>
To: zhanghailiang <zhang.zhanghailiang@huawei.com>, qemu-devel@nongnu.org
Cc: jerry.lilijun@huawei.com, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH] fix the memory leak for share hugepage
Date: Sat, 18 Oct 2014 11:22:17 +0800	[thread overview]
Message-ID: <5441DCE9.6000202@huawei.com> (raw)
In-Reply-To: <5440D6BA.2040801@huawei.com>



On 2014/10/17 16:43, zhanghailiang wrote:
> On 2014/10/17 16:27, haifeng.lin@huawei.com wrote:
>> From: linhaifeng <haifeng.lin@huawei.com>
>>
>> The VM start with share hugepage should close the hugefile fd
>> when exit.Because the hugepage fd may be send to other process
>> e.g vhost-user If qemu not close the fd the other process can
>> not free the hugepage otherwise exit process,this is ugly,so
>> qemu should close all shared fd when exit.
>>
>> Signed-off-by: linhaifeng <haifeng.lin@huawei.com>
>> ---
>>   exec.c | 12 ++++++++++++
>>   vl.c   |  7 +++++++
>>   2 files changed, 19 insertions(+)
>>
>> diff --git a/exec.c b/exec.c
>> index 759055d..d120b73 100644
>> --- a/exec.c
>> +++ b/exec.c
>> @@ -1535,6 +1535,18 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)
>>           }
>>       }
>>   }
>> +
>> +void qemu_close_all_ram_fd(void)
>> +{
>> +    RAMBlock *block;
>> +
>> +    qemu_mutex_lock_ramlist();
>> +    QTAILQ_FOREACH(block, &ram_list.blocks, next) {
>> +        close(block->fd);
>> +    }
>> +    qemu_mutex_unlock_ramlist();
>> +}
>> +
>>   #endif /* !_WIN32 */
>>
>>   int qemu_get_ram_fd(ram_addr_t addr)
>> diff --git a/vl.c b/vl.c
>> index aee73e1..0b78f3f 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -1658,6 +1658,7 @@ static int qemu_shutdown_requested(void)
>>       return r;
>>   }
>>
>> +extern void qemu_close_all_ram_fd(void);
>>   static void qemu_kill_report(void)
>>   {
>>       if (!qtest_driver() && shutdown_signal != -1) {
>> @@ -1671,6 +1672,12 @@ static void qemu_kill_report(void)
>>               fprintf(stderr, " from pid " FMT_pid "\n", shutdown_pid);
>>           }
>>           shutdown_signal = -1;
>> +
>> +        /* Close all ram fd when exit. If the ram is shared by othter process
> 
> s/othter/other/
> 

OK.thank you.

>> +         * e.g vhost-user, it can free the hugepage by close fd after qemu exit,
>> +         * otherwise the process have to exit to free hugepage.
>> +         */
>> +        qemu_close_all_ram_fd();
>>       }
>>   }
>>
>>
> 
> 
> 
> .
> 

-- 
Regards,
Haifeng

      reply	other threads:[~2014-10-18  3:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-17  8:27 [Qemu-devel] [PATCH] fix the memory leak for share hugepage haifeng.lin
2014-10-17  8:33 ` Daniel P. Berrange
2014-10-17  8:56   ` Gonglei
2014-10-17  9:13     ` Linhaifeng
2014-10-17  8:57   ` Linhaifeng
2014-10-17  9:21     ` Linhaifeng
2014-10-17 13:26     ` Daniel P. Berrange
2014-10-18  3:20       ` Linhaifeng
2014-10-20  2:12         ` Wen Congyang
2014-10-20  4:48           ` Linhaifeng
2014-10-20  5:32             ` Wen Congyang
2014-10-20  6:17               ` Linhaifeng
2014-10-20  6:26                 ` Wen Congyang
2014-10-20  7:50                   ` Linhaifeng
2014-10-20  7:54         ` Daniel P. Berrange
2014-10-17  8:43 ` zhanghailiang
2014-10-18  3:22   ` Linhaifeng [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=5441DCE9.6000202@huawei.com \
    --to=haifeng.lin@huawei.com \
    --cc=jerry.lilijun@huawei.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhang.zhanghailiang@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).