From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com, marcel.a@redhat.com
Subject: [Qemu-devel] [PATCH 4/4] memory: small tweaks
Date: Mon, 2 Dec 2013 15:40:28 +0100 [thread overview]
Message-ID: <1385995228-19585-4-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1385994239-19016-1-git-send-email-pbonzini@redhat.com>
Make adjust_endianness inline, and do not use a ctz instruction
when a shift will do.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
memory.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/memory.c b/memory.c
index 495e693..d3b0dce 100644
--- a/memory.c
+++ b/memory.c
@@ -357,7 +357,7 @@ static bool memory_region_wrong_endianness(MemoryRegion *mr)
#endif
}
-static void adjust_endianness(MemoryRegion *mr, uint64_t *data, unsigned size)
+static inline void adjust_endianness(MemoryRegion *mr, uint64_t *data, unsigned size)
{
if (memory_region_wrong_endianness(mr)) {
switch (size) {
@@ -378,6 +378,11 @@ static void adjust_endianness(MemoryRegion *mr, uint64_t *data, unsigned size)
}
}
+static inline int ctz3(unsigned size)
+{
+ return size >> 1;
+}
+
static void memory_region_oldmmio_read_accessor(MemoryRegion *mr,
hwaddr addr,
uint64_t *value,
@@ -387,7 +392,7 @@ static void memory_region_oldmmio_read_accessor(MemoryRegion *mr,
{
uint64_t tmp;
- tmp = mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr);
+ tmp = mr->ops->old_mmio.read[ctz3(size)](mr->opaque, addr);
trace_memory_region_ops_read(mr, addr, tmp, size);
*value |= (tmp & mask) << shift;
}
@@ -417,7 +422,7 @@ static void memory_region_oldmmio_write_accessor(MemoryRegion *mr,
tmp = (*value >> shift) & mask;
trace_memory_region_ops_write(mr, addr, tmp, size);
- mr->ops->old_mmio.write[ctz32(size)](mr->opaque, addr, tmp);
+ mr->ops->old_mmio.write[ctz3(size)](mr->opaque, addr, tmp);
}
static void memory_region_write_accessor(MemoryRegion *mr,
@@ -937,7 +942,7 @@ static uint64_t memory_region_dispatch_read1(MemoryRegion *mr,
if (mr->ops->read) {
data = mr->ops->read(mr->opaque, addr, size);
} else {
- data = mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr);
+ data = mr->ops->old_mmio.read[ctz3(size)](mr->opaque, addr);
}
trace_memory_region_ops_read(mr, addr, data, size);
return data;
@@ -992,7 +997,7 @@ static void memory_region_dispatch_write1(MemoryRegion *mr,
if (mr->ops->write) {
mr->ops->write(mr->opaque, addr, data, size);
} else {
- mr->ops->old_mmio.write[ctz32(size)](mr->opaque, addr, data);
+ mr->ops->old_mmio.write[ctz3(size)](mr->opaque, addr, data);
}
return;
--
1.8.4.2
next prev parent reply other threads:[~2013-12-02 14:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-02 14:23 [Qemu-devel] [PATCH 0/4] speedup memory dispatch Paolo Bonzini
2013-12-02 14:40 ` [Qemu-devel] [PATCH 1/4] memory: cache min/max_access_size Paolo Bonzini
2013-12-05 12:19 ` Uri Lublin
2013-12-05 12:20 ` Paolo Bonzini
2013-12-02 14:40 ` [Qemu-devel] [PATCH 2/4] memory: streamline common case for memory dispatch Paolo Bonzini
2013-12-02 14:40 ` [Qemu-devel] [PATCH 3/4] memory: hoist coalesced MMIO flush Paolo Bonzini
2013-12-02 14:40 ` Paolo Bonzini [this message]
2013-12-10 11:55 ` [Qemu-devel] [PATCH 0/4] speedup memory dispatch Marcel Apfelbaum
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=1385995228-19585-4-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=marcel.a@redhat.com \
--cc=mst@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).