From: Alex Williamson <alex.williamson@redhat.com>
To: mtosatti@redhat.com, kvm@vger.kernel.org, gleb@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: [RFC PATCH 3/6] kvm: Merge id_to_index into memslots
Date: Mon, 03 Dec 2012 16:39:24 -0700 [thread overview]
Message-ID: <20121203233924.3661.81373.stgit@bling.home> (raw)
In-Reply-To: <20121203231912.3661.57179.stgit@bling.home>
This allows us to resize this structure and therefore the number of
memslots as part of the RCU update.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
include/linux/kvm_host.h | 5 ++---
virt/kvm/kvm_main.c | 4 ++--
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index bf8380f..7b3d5c4 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -257,6 +257,7 @@ struct kvm_memory_slot {
unsigned long userspace_addr;
int user_alloc;
int id;
+ int id_to_index;
};
static inline unsigned long kvm_dirty_bitmap_bytes(struct kvm_memory_slot *memslot)
@@ -314,8 +315,6 @@ struct kvm_irq_routing_table {};
struct kvm_memslots {
u64 generation;
struct kvm_memory_slot memslots[KVM_MEM_SLOTS_NUM];
- /* The mapping table from slot id to the index in memslots[]. */
- int id_to_index[KVM_MEM_SLOTS_NUM];
};
struct kvm {
@@ -425,7 +424,7 @@ static inline struct kvm_memslots *kvm_memslots(struct kvm *kvm)
static inline struct kvm_memory_slot *
id_to_memslot(struct kvm_memslots *slots, int id)
{
- int index = slots->id_to_index[id];
+ int index = slots->memslots[id].id_to_index;
struct kvm_memory_slot *slot;
slot = &slots->memslots[index];
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 48d3ede..4f8ae4b 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -445,7 +445,7 @@ static void kvm_init_memslots_id(struct kvm *kvm)
struct kvm_memslots *slots = kvm->memslots;
for (i = 0; i < KVM_MEM_SLOTS_NUM; i++)
- slots->id_to_index[i] = slots->memslots[i].id = i;
+ slots->memslots[i].id_to_index = slots->memslots[i].id = i;
}
static struct kvm *kvm_create_vm(unsigned long type)
@@ -662,7 +662,7 @@ static void sort_memslots(struct kvm_memslots *slots)
sizeof(struct kvm_memory_slot), cmp_memslot, NULL);
for (i = 0; i < KVM_MEM_SLOTS_NUM; i++)
- slots->id_to_index[slots->memslots[i].id] = i;
+ slots->memslots[slots->memslots[i].id].id_to_index = i;
}
void update_memslots(struct kvm_memslots *slots, struct kvm_memory_slot *new)
next prev parent reply other threads:[~2012-12-03 23:39 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-03 23:39 [RFC PATCH 0/6] kvm: Growable memory slot array Alex Williamson
2012-12-03 23:39 ` [RFC PATCH 1/6] kvm: Rename KVM_MEMORY_SLOTS -> KVM_USER_MEM_SLOTS Alex Williamson
2012-12-03 23:39 ` [RFC PATCH 2/6] kvm: Make KVM_PRIVATE_MEM_SLOTS optional Alex Williamson
2012-12-03 23:39 ` Alex Williamson [this message]
2012-12-05 21:22 ` [RFC PATCH 3/6] kvm: Merge id_to_index into memslots Marcelo Tosatti
2012-12-05 22:58 ` Alex Williamson
2012-12-03 23:39 ` [RFC PATCH 4/6] kvm: Move private memory slots to start of memslots array Alex Williamson
2012-12-05 21:24 ` Marcelo Tosatti
2012-12-05 22:58 ` Alex Williamson
2012-12-03 23:39 ` [RFC PATCH 5/6] kvm: Re-introduce memslots->nmemslots Alex Williamson
2012-12-05 21:26 ` Marcelo Tosatti
2012-12-05 23:02 ` Alex Williamson
2012-12-06 1:45 ` Marcelo Tosatti
2012-12-06 3:51 ` Alex Williamson
2012-12-06 23:58 ` Marcelo Tosatti
2012-12-06 23:59 ` Marcelo Tosatti
2012-12-07 0:07 ` Alex Williamson
2012-12-03 23:39 ` [RFC PATCH 6/6] kvm: Allow memory slots to grow Alex Williamson
2012-12-04 11:48 ` [RFC PATCH 0/6] kvm: Growable memory slot array Gleb Natapov
2012-12-04 15:21 ` Alex Williamson
2012-12-04 15:30 ` Gleb Natapov
2012-12-04 15:39 ` Alex Williamson
2012-12-04 16:42 ` Gleb Natapov
2012-12-04 17:56 ` Alex Williamson
2012-12-04 14:48 ` Takuya Yoshikawa
2012-12-04 15:26 ` Alex Williamson
2012-12-05 21:32 ` Marcelo Tosatti
2012-12-05 22:57 ` Alex Williamson
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=20121203233924.3661.81373.stgit@bling.home \
--to=alex.williamson@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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).