From: Anthony PERARD <anthony.perard@citrix.com>
To: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Cc: Xen Devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] qemu-xen-traditionnal, Fix dirty logging during migration.
Date: Mon, 23 Jul 2012 11:53:49 +0100 [thread overview]
Message-ID: <500D2D3D.2060008@citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1207231138250.26163@kaball.uk.xensource.com>
On 23/07/12 11:42, Stefano Stabellini wrote:
> On Fri, 20 Jul 2012, Anthony PERARD wrote:
>> This moves the xen_modified_memory call from cpu_physical_memory_map to
>> cpu_physical_memory_unmap because the memory could be migrated before the
>> device model have written to it.
>>
>> The xen_ram_addr_from_mapcache function is imported from QEMU.
>>
>> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
>>
>> ---
>> hw/xen_machine_fv.c | 39 +++++++++++++++++++++++++++++++++++++++
>> i386-dm/exec-dm.c | 10 ++++++----
>> qemu-xen.h | 1 +
>> 3 files changed, 46 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
>> index fdad42a..c358944 100644
>> --- a/hw/xen_machine_fv.c
>> +++ b/hw/xen_machine_fv.c
>> @@ -223,6 +223,45 @@ void qemu_invalidate_entry(uint8_t *buffer)
>> qemu_free(entry);
>> }
>>
>> +target_phys_addr_t xen_ram_addr_from_mapcache(void *ptr)
>> +{
>> + struct map_cache *entry = NULL;
>> + struct map_cache_rev *reventry;
>> + target_phys_addr_t paddr_index;
>> + int found = 0;
>> +
>> + TAILQ_FOREACH(reventry, &locked_entries, next) {
>> + if (reventry->vaddr_req == ptr) {
>> + paddr_index = reventry->paddr_index;
>> + found = 1;
>> + break;
>> + }
>> + }
>> + if (!found) {
>> + fprintf(stderr, "%s, could not find %p\n", __func__, ptr);
>> + TAILQ_FOREACH(reventry, &locked_entries, next) {
>> + fprintf(stderr, " %#10lx -> %p is present\n",
>> + reventry->paddr_index,
>> + reventry->vaddr_req);
>> + }
>> + abort();
>> + return 0;
>> + }
>> +
>> + entry = &mapcache_entry[paddr_index % nr_buckets];
>> + while (entry && (entry->paddr_index != paddr_index)) {
>> + entry = entry->next;
>> + }
>> + if (!entry) {
>> + fprintf(stderr,
>> + "Trying to find address %p that is not in the mapcache!\n",
>> + ptr);
>> + return 0;
>> + }
>> + return (reventry->paddr_index << MCACHE_BUCKET_SHIFT) +
>> + ((unsigned long) ptr - (unsigned long) entry->vaddr_base);
>> +}
>> +
>> void qemu_invalidate_map_cache(void)
>> {
>> unsigned long i;
>> diff --git a/i386-dm/exec-dm.c b/i386-dm/exec-dm.c
>> index 96274d9..bf27a6a 100644
>> --- a/i386-dm/exec-dm.c
>> +++ b/i386-dm/exec-dm.c
>> @@ -820,10 +820,6 @@ void *cpu_physical_memory_map(target_phys_addr_t addr,
>> if ((*plen) > l)
>> *plen = l;
>> #endif
>> - if (xen_logdirty_enable)
>> - xc_hvm_modified_memory(xc_handle, domid, addr >> TARGET_PAGE_BITS,
>> - ((addr + l + TARGET_PAGE_SIZE - 1) >> TARGET_PAGE_BITS)
>> - - (addr >> TARGET_PAGE_BITS));
>>
>> return qemu_map_cache(addr, 1);
>> }
>> @@ -835,6 +831,12 @@ void *cpu_physical_memory_map(target_phys_addr_t addr,
>> void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
>> int is_write, target_phys_addr_t access_len)
>> {
>> + if (xen_logdirty_enable && is_write) {
>> + target_phys_addr_t addr = xen_ram_addr_from_mapcache(buffer);
>> + xc_hvm_modified_memory(xc_handle, domid, addr >> TARGET_PAGE_BITS,
>> + ((addr + access_len + TARGET_PAGE_SIZE - 1) >> TARGET_PAGE_BITS)
>> + - (addr >> TARGET_PAGE_BITS));
>> + }
>> qemu_invalidate_entry(buffer);
>> cpu_notify_map_clients();
>> }
>
> Considering that on qemu-xen-traditional there is just one caller of
> qemu_invalidate_entry, that is cpu_physical_memory_unmap, we can just
> add the xc_hvm_modified_memory call there and avoid introducing
> xen_ram_addr_from_mapcache.
>
OK, that would simplifies things.
--
Anthony PERARD
next prev parent reply other threads:[~2012-07-23 10:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-20 18:29 [PATCH] qemu-xen-traditionnal, Fix dirty logging during migration Anthony PERARD
2012-07-23 10:42 ` Stefano Stabellini
2012-07-23 10:53 ` Anthony PERARD [this message]
2012-07-23 11:10 ` Anthony PERARD
2012-07-23 11:22 ` Stefano Stabellini
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=500D2D3D.2060008@citrix.com \
--to=anthony.perard@citrix.com \
--cc=Stefano.Stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/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 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.