* [Qemu-devel] [PATCH v3 1/2] arch_init: make is_zero_page accept size
@ 2013-09-20 16:23 Isaku Yamahata
2013-09-20 16:23 ` [Qemu-devel] [PATCH v3 2/2] migration: ram_handle_compressed Isaku Yamahata
2013-09-24 8:28 ` [Qemu-devel] [PATCH v3 1/2] arch_init: make is_zero_page accept size Juan Quintela
0 siblings, 2 replies; 4+ messages in thread
From: Isaku Yamahata @ 2013-09-20 16:23 UTC (permalink / raw)
To: qemu-devel; +Cc: owasserm, pbonzini, mrhines, quintela
Later is_zero_page will be used for non TARGET_PAGE_SIZE
range.
And rename it to is_zero_range as it isn't page size any more.
Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
---
arch_init.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index e47e139..83b165b 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -150,10 +150,9 @@ int qemu_read_default_config_files(bool userconfig)
return 0;
}
-static inline bool is_zero_page(uint8_t *p)
+static inline bool is_zero_range(uint8_t *p, uint64_t size)
{
- return buffer_find_nonzero_offset(p, TARGET_PAGE_SIZE) ==
- TARGET_PAGE_SIZE;
+ return buffer_find_nonzero_offset(p, size) == size;
}
/* struct contains XBZRLE cache and a static page
@@ -497,7 +496,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage)
acct_info.dup_pages++;
}
}
- } else if (is_zero_page(p)) {
+ } else if (is_zero_range(p, TARGET_PAGE_SIZE)) {
acct_info.dup_pages++;
bytes_sent = save_block_hdr(f, block, offset, cont,
RAM_SAVE_FLAG_COMPRESS);
@@ -844,7 +843,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
*/
void ram_handle_compressed(void *host, uint8_t ch, uint64_t size)
{
- if (ch != 0 || !is_zero_page(host)) {
+ if (ch != 0 || !is_zero_range(host, TARGET_PAGE_SIZE)) {
memset(host, ch, size);
#ifndef _WIN32
if (ch == 0 &&
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH v3 2/2] migration: ram_handle_compressed
2013-09-20 16:23 [Qemu-devel] [PATCH v3 1/2] arch_init: make is_zero_page accept size Isaku Yamahata
@ 2013-09-20 16:23 ` Isaku Yamahata
2013-09-24 8:29 ` Juan Quintela
2013-09-24 8:28 ` [Qemu-devel] [PATCH v3 1/2] arch_init: make is_zero_page accept size Juan Quintela
1 sibling, 1 reply; 4+ messages in thread
From: Isaku Yamahata @ 2013-09-20 16:23 UTC (permalink / raw)
To: qemu-devel; +Cc: owasserm, pbonzini, mrhines, quintela
ram_handle_compressed() should be aware of size > TARGET_PAGE_SIZE.
migration-rdma can call it with larger size.
Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
---
Changes v2 -> v3:
- use is_zero_range()
changes v1 -> v2:
- don't loop
---
arch_init.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 83b165b..1a444f5 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -843,13 +843,14 @@ static inline void *host_from_stream_offset(QEMUFile *f,
*/
void ram_handle_compressed(void *host, uint8_t ch, uint64_t size)
{
- if (ch != 0 || !is_zero_range(host, TARGET_PAGE_SIZE)) {
+ if (ch != 0 || !is_zero_range(host, size)) {
memset(host, ch, size);
#ifndef _WIN32
- if (ch == 0 &&
- (!kvm_enabled() || kvm_has_sync_mmu()) &&
- getpagesize() <= TARGET_PAGE_SIZE) {
- qemu_madvise(host, TARGET_PAGE_SIZE, QEMU_MADV_DONTNEED);
+ if (ch == 0 && (!kvm_enabled() || kvm_has_sync_mmu())) {
+ size = size & ~(getpagesize() - 1);
+ if (size > 0) {
+ qemu_madvise(host, size, QEMU_MADV_DONTNEED);
+ }
}
#endif
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v3 1/2] arch_init: make is_zero_page accept size
2013-09-20 16:23 [Qemu-devel] [PATCH v3 1/2] arch_init: make is_zero_page accept size Isaku Yamahata
2013-09-20 16:23 ` [Qemu-devel] [PATCH v3 2/2] migration: ram_handle_compressed Isaku Yamahata
@ 2013-09-24 8:28 ` Juan Quintela
1 sibling, 0 replies; 4+ messages in thread
From: Juan Quintela @ 2013-09-24 8:28 UTC (permalink / raw)
To: Isaku Yamahata; +Cc: owasserm, mrhines, qemu-devel, pbonzini
Isaku Yamahata <yamahata@private.email.ne.jp> wrote:
> Later is_zero_page will be used for non TARGET_PAGE_SIZE
> range.
> And rename it to is_zero_range as it isn't page size any more.
>
> Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
Reviewed-by: Juan Quintela <quintela@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/2] migration: ram_handle_compressed
2013-09-20 16:23 ` [Qemu-devel] [PATCH v3 2/2] migration: ram_handle_compressed Isaku Yamahata
@ 2013-09-24 8:29 ` Juan Quintela
0 siblings, 0 replies; 4+ messages in thread
From: Juan Quintela @ 2013-09-24 8:29 UTC (permalink / raw)
To: Isaku Yamahata; +Cc: owasserm, mrhines, qemu-devel, pbonzini
Isaku Yamahata <yamahata@private.email.ne.jp> wrote:
> ram_handle_compressed() should be aware of size > TARGET_PAGE_SIZE.
> migration-rdma can call it with larger size.
>
> Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
Reviewed-by: Juan Quintela <quintela@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-24 8:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-20 16:23 [Qemu-devel] [PATCH v3 1/2] arch_init: make is_zero_page accept size Isaku Yamahata
2013-09-20 16:23 ` [Qemu-devel] [PATCH v3 2/2] migration: ram_handle_compressed Isaku Yamahata
2013-09-24 8:29 ` Juan Quintela
2013-09-24 8:28 ` [Qemu-devel] [PATCH v3 1/2] arch_init: make is_zero_page accept size Juan Quintela
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).