From: Xiao Guangrong <guangrong.xiao@gmail.com>
To: Peter Xu <peterx@redhat.com>
Cc: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com,
qemu-devel@nongnu.org, kvm@vger.kernel.org, dgilbert@redhat.com,
jiang.biao2@zte.com.cn, wei.w.wang@intel.com,
Xiao Guangrong <xiaoguangrong@tencent.com>
Subject: Re: [Qemu-devel] [PATCH v2 02/10] migration: stop compression to allocate and free memory frequently
Date: Thu, 29 Mar 2018 11:41:58 +0800 [thread overview]
Message-ID: <5ce3a930-dc29-5aeb-58d4-b4b47bd2b14e@gmail.com> (raw)
In-Reply-To: <20180328092544.GE29554@xz-mi>
On 03/28/2018 05:25 PM, Peter Xu wrote:
> On Tue, Mar 27, 2018 at 05:10:35PM +0800, guangrong.xiao@gmail.com wrote:
>
> [...]
>
>> @@ -357,10 +358,20 @@ static void compress_threads_save_cleanup(void)
>> terminate_compression_threads();
>> thread_count = migrate_compress_threads();
>> for (i = 0; i < thread_count; i++) {
>> + /*
>> + * stream.opaque can be used to store private data, we use it
>> + * as a indicator which shows if the thread is properly init'd
>> + * or not
>> + */
>> + if (!comp_param[i].stream.opaque) {
>> + break;
>> + }
>
> How about using comp_param[i].file? The opaque seems to be hiding
> deeper, and...
>
Yes, indeed, good suggestion.
>> qemu_thread_join(compress_threads + i);
>> qemu_fclose(comp_param[i].file);
>> qemu_mutex_destroy(&comp_param[i].mutex);
>> qemu_cond_destroy(&comp_param[i].cond);
>> + deflateEnd(&comp_param[i].stream);
>> + comp_param[i].stream.opaque = NULL;
>> }
>> qemu_mutex_destroy(&comp_done_lock);
>> qemu_cond_destroy(&comp_done_cond);
>> @@ -370,12 +381,12 @@ static void compress_threads_save_cleanup(void)
>> comp_param = NULL;
>> }
>>
>> -static void compress_threads_save_setup(void)
>> +static int compress_threads_save_setup(void)
>> {
>> int i, thread_count;
>>
>> if (!migrate_use_compression()) {
>> - return;
>> + return 0;
>> }
>> thread_count = migrate_compress_threads();
>> compress_threads = g_new0(QemuThread, thread_count);
>> @@ -383,6 +394,12 @@ static void compress_threads_save_setup(void)
>> qemu_cond_init(&comp_done_cond);
>> qemu_mutex_init(&comp_done_lock);
>> for (i = 0; i < thread_count; i++) {
>> + if (deflateInit(&comp_param[i].stream,
>> + migrate_compress_level()) != Z_OK) {
>
> (indent issue)
>
Will fix.
>> + goto exit;
>> + }
>> + comp_param[i].stream.opaque = &comp_param[i];
>
> ...here from document:
>
> ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
>
> Initializes the internal stream state for compression. The
> fields zalloc, zfree and opaque must be initialized before by
> the caller. If zalloc and zfree are set to Z_NULL, deflateInit
> updates them to use default allocation functions.
>
> So shall we init opaque first? Otherwise looks good to me.
No, opaque need to be init-ed only if zalloc and zfree are specified, it
is not the case in this patch.
next prev parent reply other threads:[~2018-03-29 3:41 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-27 9:10 [Qemu-devel] [PATCH v2 00/10] migration: improve and cleanup compression guangrong.xiao
2018-03-27 9:10 ` [Qemu-devel] [PATCH v2 01/10] migration: stop compressing page in migration thread guangrong.xiao
2018-03-27 9:10 ` [Qemu-devel] [PATCH v2 02/10] migration: stop compression to allocate and free memory frequently guangrong.xiao
2018-03-28 9:25 ` Peter Xu
2018-03-29 3:41 ` Xiao Guangrong [this message]
2018-03-27 9:10 ` [Qemu-devel] [PATCH v2 03/10] migration: stop decompression " guangrong.xiao
2018-03-28 9:42 ` Peter Xu
2018-03-29 3:43 ` Xiao Guangrong
2018-03-29 4:14 ` Peter Xu
2018-03-27 9:10 ` [Qemu-devel] [PATCH v2 04/10] migration: detect compression and decompression errors guangrong.xiao
2018-03-28 9:59 ` Peter Xu
2018-03-29 3:51 ` Xiao Guangrong
2018-03-29 4:25 ` Peter Xu
2018-03-30 3:11 ` Xiao Guangrong
2018-04-02 4:26 ` Peter Xu
2018-03-27 9:10 ` [Qemu-devel] [PATCH v2 05/10] migration: introduce control_save_page() guangrong.xiao
2018-03-27 9:10 ` [Qemu-devel] [PATCH v2 06/10] migration: move some code ram_save_host_page guangrong.xiao
2018-03-28 10:05 ` Peter Xu
2018-03-27 9:10 ` [Qemu-devel] [PATCH v2 07/10] migration: move calling control_save_page to the common place guangrong.xiao
2018-03-27 9:10 ` [Qemu-devel] [PATCH v2 08/10] migration: move calling save_zero_page " guangrong.xiao
2018-03-27 9:10 ` [Qemu-devel] [PATCH v2 09/10] migration: introduce save_normal_page() guangrong.xiao
2018-03-27 9:10 ` [Qemu-devel] [PATCH v2 10/10] migration: remove ram_save_compressed_page() guangrong.xiao
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=5ce3a930-dc29-5aeb-58d4-b4b47bd2b14e@gmail.com \
--to=guangrong.xiao@gmail.com \
--cc=dgilbert@redhat.com \
--cc=jiang.biao2@zte.com.cn \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wei.w.wang@intel.com \
--cc=xiaoguangrong@tencent.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).