* [Qemu-devel] [PATCH 6/7] migraion: optimiztion xbzrle by reducing data copy
@ 2014-02-28 4:11 Gonglei (Arei)
2014-02-28 10:30 ` Dr. David Alan Gilbert
0 siblings, 1 reply; 3+ messages in thread
From: Gonglei (Arei) @ 2014-02-28 4:11 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Juan Quintela, pl, owasserm, aliguori,
chenliang (T),
pbonzini
Reducing data copy can reduce cpu overheah.
Signed-off-by: ChenLiang <chenliang88@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
arch_init.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 2211e0b..cc88875 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -344,11 +344,8 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
prev_cached_page = get_cached_data(XBZRLE.cache, current_addr);
- /* save current buffer into memory */
- memcpy(XBZRLE.current_buf, *current_data, TARGET_PAGE_SIZE);
-
/* XBZRLE encoding (if there is no overflow) */
- encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf,
+ encoded_len = xbzrle_encode_buffer(prev_cached_page, *current_data,
TARGET_PAGE_SIZE, XBZRLE.encoded_buf,
TARGET_PAGE_SIZE);
if (encoded_len == 0) {
@@ -367,7 +364,8 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
/* we need to update the data in the cache, in order to get the same data */
if (!last_stage) {
- memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE);
+ xbzrle_decode_buffer(XBZRLE.encoded_buf, encoded_len, prev_cached_page,
+ TARGET_PAGE_SIZE);
}
/* Send XBZRLE based compressed page */
--
1.7.12.4
Best regards,
-Gonglei
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 6/7] migraion: optimiztion xbzrle by reducing data copy
2014-02-28 4:11 [Qemu-devel] [PATCH 6/7] migraion: optimiztion xbzrle by reducing data copy Gonglei (Arei)
@ 2014-02-28 10:30 ` Dr. David Alan Gilbert
2014-02-28 11:06 ` Gonglei
0 siblings, 1 reply; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2014-02-28 10:30 UTC (permalink / raw)
To: Gonglei (Arei)
Cc: chenliang (T),
Peter Maydell, Juan Quintela, pl, qemu-devel, aliguori, pbonzini
* Gonglei (Arei) (arei.gonglei@huawei.com) wrote:
> Reducing data copy can reduce cpu overheah.
(Note a few typos in subject/title)
> Signed-off-by: ChenLiang <chenliang88@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> arch_init.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/arch_init.c b/arch_init.c
> index 2211e0b..cc88875 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -344,11 +344,8 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
>
> prev_cached_page = get_cached_data(XBZRLE.cache, current_addr);
>
> - /* save current buffer into memory */
> - memcpy(XBZRLE.current_buf, *current_data, TARGET_PAGE_SIZE);
> -
> /* XBZRLE encoding (if there is no overflow) */
> - encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf,
> + encoded_len = xbzrle_encode_buffer(prev_cached_page, *current_data,
> TARGET_PAGE_SIZE, XBZRLE.encoded_buf,
> TARGET_PAGE_SIZE);
Is xbzrle_encode_buffer safe if the main memory is still being changed while
it is run? Even with multiple CPUs changing it? Even on CPUs with looser
memory ordering semantics?
> if (encoded_len == 0) {
> @@ -367,7 +364,8 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
>
> /* we need to update the data in the cache, in order to get the same data */
> if (!last_stage) {
> - memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE);
> + xbzrle_decode_buffer(XBZRLE.encoded_buf, encoded_len, prev_cached_page,
> + TARGET_PAGE_SIZE);
> }
>
> /* Send XBZRLE based compressed page */
> --
> 1.7.12.4
>
>
> Best regards,
> -Gonglei
>
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 6/7] migraion: optimiztion xbzrle by reducing data copy
2014-02-28 10:30 ` Dr. David Alan Gilbert
@ 2014-02-28 11:06 ` Gonglei
0 siblings, 0 replies; 3+ messages in thread
From: Gonglei @ 2014-02-28 11:06 UTC (permalink / raw)
To: Dr. David Alan Gilbert
Cc: chenliang (T),
Peter Maydell, Juan Quintela, pl, qemu-devel, aliguori, pbonzini
On 2014/2/28 18:30, Dr. David Alan Gilbert wrote:
> * Gonglei (Arei) (arei.gonglei@huawei.com) wrote:
>> Reducing data copy can reduce cpu overheah.
>
> (Note a few typos in subject/title)
>
>> Signed-off-by: ChenLiang <chenliang88@huawei.com>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> ---
>> arch_init.c | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch_init.c b/arch_init.c
>> index 2211e0b..cc88875 100644
>> --- a/arch_init.c
>> +++ b/arch_init.c
>> @@ -344,11 +344,8 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
>>
>> prev_cached_page = get_cached_data(XBZRLE.cache, current_addr);
>>
>> - /* save current buffer into memory */
>> - memcpy(XBZRLE.current_buf, *current_data, TARGET_PAGE_SIZE);
>> -
>> /* XBZRLE encoding (if there is no overflow) */
>> - encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf,
>> + encoded_len = xbzrle_encode_buffer(prev_cached_page, *current_data,
>> TARGET_PAGE_SIZE, XBZRLE.encoded_buf,
>> TARGET_PAGE_SIZE);
>
> Is xbzrle_encode_buffer safe if the main memory is still being changed while
> it is run? Even with multiple CPUs changing it? Even on CPUs with looser
> memory ordering semantics?
>
It's OK. We just need to assure the pages of cache and the pages which be sent coherence.
>> if (encoded_len == 0) {
>> @@ -367,7 +364,8 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
>>
>> /* we need to update the data in the cache, in order to get the same data */
>> if (!last_stage) {
>> - memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE);
>> + xbzrle_decode_buffer(XBZRLE.encoded_buf, encoded_len, prev_cached_page,
>> + TARGET_PAGE_SIZE);
>> }
>>
>> /* Send XBZRLE based compressed page */
>> --
>> 1.7.12.4
>>
>>
>> Best regards,
>> -Gonglei
>>
>>
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Best regards,
-Gonglei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-28 11:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-28 4:11 [Qemu-devel] [PATCH 6/7] migraion: optimiztion xbzrle by reducing data copy Gonglei (Arei)
2014-02-28 10:30 ` Dr. David Alan Gilbert
2014-02-28 11:06 ` Gonglei
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.