* [Qemu-devel] [RESEND][PATCH] migration: drop MADVISE_DONT_NEED for incoming zero pages
@ 2013-10-24 7:21 Peter Lieven
2013-10-24 9:14 ` [Qemu-devel] [RESEND][PATCH 1.7] " Paolo Bonzini
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Peter Lieven @ 2013-10-24 7:21 UTC (permalink / raw)
To: qemu-devel
Cc: quintela, haoyu.zhang, Peter Lieven, xiaoguangrong, pbonzini,
afaerber
The madvise for zeroed out pages was introduced when every transferred
zero page was memset to zero and thus allocated. Since commit
211ea740 we check for zeroness of a target page before we memset
it to zero. Additionally we memmap target memory so it is essentially
zero initialized (except for e.g. option roms and bios which are loaded
into target memory although they shouldn't).
It was reported recently that this madvise causes a performance degradation
in some situations. As the madvise should only be called rarely and if it's called
it is likely on a busy page (it was non-zero and changed to zero during migration)
drop it completely.
Reported-By: Zhang Haoyu <haoyu.zhang@huawei.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
---
arch_init.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 7545d96..e0acbc5 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -850,14 +850,6 @@ void ram_handle_compressed(void *host, uint8_t ch, uint64_t size)
{
if (ch != 0 || !is_zero_range(host, size)) {
memset(host, ch, size);
-#ifndef _WIN32
- 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.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 1.7] migration: drop MADVISE_DONT_NEED for incoming zero pages
2013-10-24 7:21 [Qemu-devel] [RESEND][PATCH] migration: drop MADVISE_DONT_NEED for incoming zero pages Peter Lieven
@ 2013-10-24 9:14 ` Paolo Bonzini
2013-11-18 12:48 ` Peter Lieven
2013-10-24 10:07 ` [Qemu-devel] [RESEND][PATCH] " Juan Quintela
2013-10-30 3:08 ` Zhanghaoyu (A)
2 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2013-10-24 9:14 UTC (permalink / raw)
To: Peter Lieven; +Cc: haoyu.zhang, xiaoguangrong, qemu-devel, afaerber, quintela
Il 24/10/2013 08:21, Peter Lieven ha scritto:
> Additionally we memmap target memory so it is essentially
> zero initialized (except for e.g. option roms and bios which are loaded
> into target memory although they shouldn't).
>
> It was reported recently that this madvise causes a performance degradation
> in some situations. As the madvise should only be called rarely and if it's called
> it is likely on a busy page (it was non-zero and changed to zero during migration)
> drop it completely.
Tagging this patch for 1.7.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH] migration: drop MADVISE_DONT_NEED for incoming zero pages
2013-10-24 7:21 [Qemu-devel] [RESEND][PATCH] migration: drop MADVISE_DONT_NEED for incoming zero pages Peter Lieven
2013-10-24 9:14 ` [Qemu-devel] [RESEND][PATCH 1.7] " Paolo Bonzini
@ 2013-10-24 10:07 ` Juan Quintela
2013-11-04 9:29 ` Peter Lieven
2013-10-30 3:08 ` Zhanghaoyu (A)
2 siblings, 1 reply; 7+ messages in thread
From: Juan Quintela @ 2013-10-24 10:07 UTC (permalink / raw)
To: Peter Lieven; +Cc: pbonzini, haoyu.zhang, qemu-devel, afaerber, xiaoguangrong
Peter Lieven <pl@kamp.de> wrote:
> The madvise for zeroed out pages was introduced when every transferred
> zero page was memset to zero and thus allocated. Since commit
> 211ea740 we check for zeroness of a target page before we memset
> it to zero. Additionally we memmap target memory so it is essentially
> zero initialized (except for e.g. option roms and bios which are loaded
> into target memory although they shouldn't).
>
> It was reported recently that this madvise causes a performance degradation
> in some situations. As the madvise should only be called rarely and if it's called
> it is likely on a busy page (it was non-zero and changed to zero during migration)
> drop it completely.
Reviewed-by: Juan Quintela <quintela@redhat.com>
I take it. I am on KVM Forum/LinuxCon this week. Will send when back
at home.
Thanks.
>
> Reported-By: Zhang Haoyu <haoyu.zhang@huawei.com>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
> arch_init.c | 8 --------
> 1 file changed, 8 deletions(-)
>
> diff --git a/arch_init.c b/arch_init.c
> index 7545d96..e0acbc5 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -850,14 +850,6 @@ void ram_handle_compressed(void *host, uint8_t ch, uint64_t size)
> {
> if (ch != 0 || !is_zero_range(host, size)) {
> memset(host, ch, size);
> -#ifndef _WIN32
> - if (ch == 0 && (!kvm_enabled() || kvm_has_sync_mmu())) {
> - size = size & ~(getpagesize() - 1);
> - if (size > 0) {
> - qemu_madvise(host, size, QEMU_MADV_DONTNEED);
> - }
> - }
> -#endif
> }
> }
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH] migration: drop MADVISE_DONT_NEED for incoming zero pages
2013-10-24 7:21 [Qemu-devel] [RESEND][PATCH] migration: drop MADVISE_DONT_NEED for incoming zero pages Peter Lieven
2013-10-24 9:14 ` [Qemu-devel] [RESEND][PATCH 1.7] " Paolo Bonzini
2013-10-24 10:07 ` [Qemu-devel] [RESEND][PATCH] " Juan Quintela
@ 2013-10-30 3:08 ` Zhanghaoyu (A)
2 siblings, 0 replies; 7+ messages in thread
From: Zhanghaoyu (A) @ 2013-10-30 3:08 UTC (permalink / raw)
To: Peter Lieven, qemu-devel@nongnu.org
Cc: Huangweidong (C), quintela@redhat.com, Luonengjun,
xiaoguangrong@linux.vnet.ibm.com, pbonzini@redhat.com,
afaerber@suse.de
The comments of ram_handle_compressed needs to be changed accordingly,
"Do not memset pages to zero if they already read as zero to avoid allocating zero pages and consuming memory unnecessarily."
Thanks,
Zhang Haoyu
> The madvise for zeroed out pages was introduced when every transferred
> zero page was memset to zero and thus allocated. Since commit
> 211ea740 we check for zeroness of a target page before we memset
> it to zero. Additionally we memmap target memory so it is essentially
> zero initialized (except for e.g. option roms and bios which are loaded
> into target memory although they shouldn't).
>
> It was reported recently that this madvise causes a performance
> degradation
> in some situations. As the madvise should only be called rarely and if
> it's called
> it is likely on a busy page (it was non-zero and changed to zero during
> migration)
> drop it completely.
>
> Reported-By: Zhang Haoyu <haoyu.zhang@huawei.com>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
> arch_init.c | 8 --------
> 1 file changed, 8 deletions(-)
>
> diff --git a/arch_init.c b/arch_init.c
> index 7545d96..e0acbc5 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -850,14 +850,6 @@ void ram_handle_compressed(void *host, uint8_t ch,
> uint64_t size)
> {
> if (ch != 0 || !is_zero_range(host, size)) {
> memset(host, ch, size);
> -#ifndef _WIN32
> - 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.9.5
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH] migration: drop MADVISE_DONT_NEED for incoming zero pages
2013-10-24 10:07 ` [Qemu-devel] [RESEND][PATCH] " Juan Quintela
@ 2013-11-04 9:29 ` Peter Lieven
0 siblings, 0 replies; 7+ messages in thread
From: Peter Lieven @ 2013-11-04 9:29 UTC (permalink / raw)
To: quintela; +Cc: pbonzini, haoyu.zhang, qemu-devel, afaerber, xiaoguangrong
On 24.10.2013 12:07, Juan Quintela wrote:
> Peter Lieven <pl@kamp.de> wrote:
>> The madvise for zeroed out pages was introduced when every transferred
>> zero page was memset to zero and thus allocated. Since commit
>> 211ea740 we check for zeroness of a target page before we memset
>> it to zero. Additionally we memmap target memory so it is essentially
>> zero initialized (except for e.g. option roms and bios which are loaded
>> into target memory although they shouldn't).
>>
>> It was reported recently that this madvise causes a performance degradation
>> in some situations. As the madvise should only be called rarely and if it's called
>> it is likely on a busy page (it was non-zero and changed to zero during migration)
>> drop it completely.
> Reviewed-by: Juan Quintela <quintela@redhat.com>
>
> I take it. I am on KVM Forum/LinuxCon this week. Will send when back
> at home.
Ping
Peter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 1.7] migration: drop MADVISE_DONT_NEED for incoming zero pages
2013-10-24 9:14 ` [Qemu-devel] [RESEND][PATCH 1.7] " Paolo Bonzini
@ 2013-11-18 12:48 ` Peter Lieven
2013-11-18 16:10 ` Paolo Bonzini
0 siblings, 1 reply; 7+ messages in thread
From: Peter Lieven @ 2013-11-18 12:48 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: haoyu.zhang, xiaoguangrong, qemu-devel, afaerber, quintela
On 24.10.2013 11:14, Paolo Bonzini wrote:
> Il 24/10/2013 08:21, Peter Lieven ha scritto:
>> Additionally we memmap target memory so it is essentially
>> zero initialized (except for e.g. option roms and bios which are loaded
>> into target memory although they shouldn't).
>>
>> It was reported recently that this madvise causes a performance degradation
>> in some situations. As the madvise should only be called rarely and if it's called
>> it is likely on a busy page (it was non-zero and changed to zero during migration)
>> drop it completely.
> Tagging this patch for 1.7.
has this been merged?
Peter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 1.7] migration: drop MADVISE_DONT_NEED for incoming zero pages
2013-11-18 12:48 ` Peter Lieven
@ 2013-11-18 16:10 ` Paolo Bonzini
0 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2013-11-18 16:10 UTC (permalink / raw)
To: Peter Lieven, quintela; +Cc: haoyu.zhang, qemu-devel, afaerber, xiaoguangrong
Il 18/11/2013 13:48, Peter Lieven ha scritto:
> On 24.10.2013 11:14, Paolo Bonzini wrote:
>> Il 24/10/2013 08:21, Peter Lieven ha scritto:
>>> Additionally we memmap target memory so it is essentially
>>> zero initialized (except for e.g. option roms and bios which are loaded
>>> into target memory although they shouldn't).
>>>
>>> It was reported recently that this madvise causes a performance
>>> degradation
>>> in some situations. As the madvise should only be called rarely and
>>> if it's called
>>> it is likely on a busy page (it was non-zero and changed to zero
>>> during migration)
>>> drop it completely.
>> Tagging this patch for 1.7.
> has this been merged?
No. Juan, can you prepare a quick pull request?
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-11-18 16:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-24 7:21 [Qemu-devel] [RESEND][PATCH] migration: drop MADVISE_DONT_NEED for incoming zero pages Peter Lieven
2013-10-24 9:14 ` [Qemu-devel] [RESEND][PATCH 1.7] " Paolo Bonzini
2013-11-18 12:48 ` Peter Lieven
2013-11-18 16:10 ` Paolo Bonzini
2013-10-24 10:07 ` [Qemu-devel] [RESEND][PATCH] " Juan Quintela
2013-11-04 9:29 ` Peter Lieven
2013-10-30 3:08 ` Zhanghaoyu (A)
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).