From: Avi Kivity <avi@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 18/20] memory: change phys_page_set() to set multiple pages
Date: Tue, 14 Feb 2012 11:27:48 +0200 [thread overview]
Message-ID: <1329211670-11548-19-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1329211670-11548-1-git-send-email-avi@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
exec.c | 41 +++++++++++++++++++++++------------------
1 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/exec.c b/exec.c
index f4cd867..98c0056 100644
--- a/exec.c
+++ b/exec.c
@@ -436,8 +436,9 @@ static void phys_map_nodes_reset(void)
}
-static void phys_page_set_level(PhysPageEntry *lp, target_phys_addr_t index,
- uint16_t leaf, int level)
+static void phys_page_set_level(PhysPageEntry *lp, target_phys_addr_t *index,
+ target_phys_addr_t *nb, uint16_t leaf,
+ int level)
{
PhysPageEntry *p;
int i;
@@ -453,20 +454,27 @@ static void phys_page_set_level(PhysPageEntry *lp, target_phys_addr_t index,
} else {
p = phys_map_nodes[lp->u.node];
}
- lp = &p[(index >> (level * L2_BITS)) & (L2_SIZE - 1)];
+ lp = &p[(*index >> (level * L2_BITS)) & (L2_SIZE - 1)];
- if (level == 0) {
- lp->u.leaf = leaf;
- } else {
- phys_page_set_level(lp, index, leaf, level - 1);
+ while (*nb && lp < &p[L2_SIZE]) {
+ if (level == 0) {
+ lp->u.leaf = leaf;
+ ++*index;
+ --*nb;
+ } else {
+ phys_page_set_level(lp, index, nb, leaf, level - 1);
+ }
+ ++lp;
}
}
-static void phys_page_set(target_phys_addr_t index, uint16_t leaf)
+static void phys_page_set(target_phys_addr_t index, target_phys_addr_t nb,
+ uint16_t leaf)
{
- phys_map_node_reserve(P_L2_LEVELS);
+ /* Wildly overreserve - it doesn't matter much. */
+ phys_map_node_reserve((nb + L2_SIZE - 1) / L2_SIZE * P_L2_LEVELS);
- phys_page_set_level(&phys_map, index, leaf, P_L2_LEVELS - 1);
+ phys_page_set_level(&phys_map, &index, &nb, leaf, P_L2_LEVELS - 1);
}
static MemoryRegionSection phys_page_find(target_phys_addr_t index)
@@ -2630,7 +2638,8 @@ static void register_subpage(MemoryRegionSection *section)
if (!(existing.mr->subpage)) {
subpage = subpage_init(base);
subsection.mr = &subpage->iomem;
- phys_page_set(base >> TARGET_PAGE_BITS, phys_section_add(&subsection));
+ phys_page_set(base >> TARGET_PAGE_BITS, 1,
+ phys_section_add(&subsection));
} else {
subpage = container_of(existing.mr, subpage_t, iomem);
}
@@ -2644,18 +2653,14 @@ static void register_multipage(MemoryRegionSection *section)
{
target_phys_addr_t start_addr = section->offset_within_address_space;
ram_addr_t size = section->size;
- target_phys_addr_t addr, end_addr;
+ target_phys_addr_t addr;
uint16_t section_index = phys_section_add(section);
assert(size);
- end_addr = start_addr + (target_phys_addr_t)size;
-
addr = start_addr;
- do {
- phys_page_set(addr >> TARGET_PAGE_BITS, section_index);
- addr += TARGET_PAGE_SIZE;
- } while (addr != end_addr);
+ phys_page_set(addr >> TARGET_PAGE_BITS, size >> TARGET_PAGE_BITS,
+ section_index);
}
void cpu_register_physical_memory_log(MemoryRegionSection *section,
--
1.7.9
next prev parent reply other threads:[~2012-02-14 9:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-14 9:27 [Qemu-devel] [PATCH 00/20] Reduce storage overhead of memory core Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 01/20] memory: allow MemoryListeners to observe a specific address space Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 02/20] xen: ignore I/O memory regions Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 03/20] memory: split memory listener for the two address spaces Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 04/20] memory: support stateless memory listeners Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 05/20] memory: change memory registration to rebuild the memory map on each change Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 06/20] memory: remove first level of l1_phys_map Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 07/20] memory: unify phys_map last level with intermediate levels Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 08/20] memory: store MemoryRegionSection pointers in phys_map Avi Kivity
2012-03-07 17:49 ` Peter Maydell
2012-03-07 19:32 ` Peter Maydell
2012-03-08 9:50 ` Avi Kivity
2012-03-08 10:09 ` Peter Maydell
2012-03-08 11:11 ` Avi Kivity
2012-03-08 11:25 ` Peter Maydell
2012-02-14 9:27 ` [Qemu-devel] [PATCH 09/20] memory: compress phys_map node pointers to 16 bits Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 10/20] memory: fix RAM subpages in newly initialized pages Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 11/20] memory: unify the two branches of cpu_register_physical_memory_log() Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 12/20] memory: move tlb flush to MemoryListener commit callback Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 13/20] memory: make phys_page_find() return a MemoryRegionSection Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 14/20] memory: give phys_page_find() its own tree search loop Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 15/20] memory: simplify multipage/subpage registration Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 16/20] memory: replace phys_page_find_alloc() with phys_page_set() Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 17/20] memory: switch phys_page_set() to a recursive implementation Avi Kivity
2012-02-14 9:27 ` Avi Kivity [this message]
2012-02-14 9:27 ` [Qemu-devel] [PATCH 19/20] memory: unify PhysPageEntry::node and ::leaf Avi Kivity
2012-02-14 9:27 ` [Qemu-devel] [PATCH 20/20] memory: allow phys_map tree paths to terminate early Avi Kivity
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=1329211670-11548-19-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=qemu-devel@nongnu.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).