From: Marcelo Tosatti <mtosatti@redhat.com>
To: izik eidus <izik@qumranet.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] unalias rework
Date: Thu, 25 Sep 2008 21:15:43 -0300 [thread overview]
Message-ID: <20080926001543.GA29572@dmt.cnet> (raw)
In-Reply-To: <48BFED00.80006@qumranet.com>
Hi Izik,
On Thu, Sep 04, 2008 at 05:13:20PM +0300, izik eidus wrote:
>
> + struct kvm_memory_slot *alias_slot = &kvm->memslots[i];
> +
> + if (alias_slot->base_gfn == slot->base_gfn)
> + return 1;
> + }
> + return 0;
> +}
> +
> +static void update_alias_slots(struct kvm *kvm, struct kvm_memory_slot *free)
> +{
> + int i;
> +
> + if (is_aliased_slot(kvm, free))
> + return;
> +
> + for (i = KVM_MEMORY_SLOTS; i < KVM_MEMORY_SLOTS + KVM_ALIAS_SLOTS;
> + ++i) {
> + struct kvm_memory_slot *alias_memslot = &kvm->memslots[i];
> + unsigned long size = free->npages << PAGE_SHIFT;
> +
> + if (alias_memslot->userspace_addr >= free->userspace_addr &&
> + alias_memslot->userspace_addr < free->userspace_addr +
> + size) {
> + alias_memslot->flags = free->flags;
> + if (free->dirty_bitmap) {
> + unsigned long offset =
> + alias_memslot->userspace_addr -
> + free->userspace_addr;
> + unsigned dirty_offset;
> + unsigned long bitmap_addr;
> +
> + offset = offset >> PAGE_SHIFT;
> + dirty_offset = ALIGN(offset, BITS_PER_LONG) / 8;
> + bitmap_addr = (unsigned long) free->dirty_bitmap;
> + bitmap_addr += dirty_offset;
> + alias_memslot->dirty_bitmap = (unsigned long *) bitmap_addr;
> + } else
> + alias_memslot->dirty_bitmap = NULL;
> + }
> + }
> +}
> +
> /*
> * Free any memory in @free but not in @dont.
> */
> -static void kvm_free_physmem_slot(struct kvm_memory_slot *free,
> +static void kvm_free_physmem_slot(struct kvm *kvm,
> + struct kvm_memory_slot *free,
> struct kvm_memory_slot *dont)
> {
> if (!dont || free->rmap != dont->rmap)
> @@ -385,10 +433,16 @@ static void kvm_free_physmem_slot(struct kvm_memory_slot *free,
> if (!dont || free->lpage_info != dont->lpage_info)
> vfree(free->lpage_info);
>
> - free->npages = 0;
> free->dirty_bitmap = NULL;
> free->rmap = NULL;
> free->lpage_info = NULL;
> +
> +#ifdef CONFIG_X86
> + update_alias_slots(kvm, free);
> + if (dont)
> + update_alias_slots(kvm, dont);
> +#endif
> + free->npages = 0;
Why is this needed? I don't understand when would you free a memslot
without freeing any aliases that map it first?
next prev parent reply other threads:[~2008-09-26 0:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-04 14:13 [PATCH] unalias rework izik eidus
2008-09-26 0:15 ` Marcelo Tosatti [this message]
2008-09-26 19:09 ` Izik Eidus
2008-10-02 14:21 ` Izik Eidus
-- strict thread matches above, loose matches on Subject: below --
2008-10-02 15:31 Izik Eidus
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=20080926001543.GA29572@dmt.cnet \
--to=mtosatti@redhat.com \
--cc=izik@qumranet.com \
--cc=kvm@vger.kernel.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 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).