From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: David Gibson <david@gibson.dropbear.id.au>,
Alexey Kardashevskiy <aik@ozlabs.ru>,
qemu-stable@nongnu.org
Subject: [Qemu-devel] [PATCH 2/7] memory: inline some performance-sensitive accessors
Date: Mon, 5 Mar 2018 09:36:50 +0100 [thread overview]
Message-ID: <20180305083655.6186-3-pbonzini@redhat.com> (raw)
In-Reply-To: <20180305083655.6186-1-pbonzini@redhat.com>
These accessors are called from inlined functions, and the call sequence
is much more expensive than just inlining the access. Move the
struct declaration to memory-internal.h so that exec.c and memory.c
can both use an inline function.
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/exec/memory-internal.h | 13 +++++++++----
include/exec/memory.h | 22 +++++++++++++++++++++-
memory.c | 30 ------------------------------
3 files changed, 30 insertions(+), 35 deletions(-)
diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h
index 4162474fd5..6a5ee42d36 100644
--- a/include/exec/memory-internal.h
+++ b/include/exec/memory-internal.h
@@ -21,7 +21,15 @@
#define MEMORY_INTERNAL_H
#ifndef CONFIG_USER_ONLY
-typedef struct AddressSpaceDispatch AddressSpaceDispatch;
+static inline AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv)
+{
+ return fv->dispatch;
+}
+
+static inline AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as)
+{
+ return flatview_to_dispatch(address_space_to_flatview(as));
+}
extern const MemoryRegionOps unassigned_mem_ops;
@@ -31,9 +39,6 @@ bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr,
void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section);
AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv);
void address_space_dispatch_compact(AddressSpaceDispatch *d);
-
-AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as);
-AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv);
void address_space_dispatch_free(AddressSpaceDispatch *d);
void mtree_print_dispatch(fprintf_function mon, void *f,
diff --git a/include/exec/memory.h b/include/exec/memory.h
index fff9b1d871..6c8e394675 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -326,7 +326,27 @@ struct AddressSpace {
QTAILQ_ENTRY(AddressSpace) address_spaces_link;
};
-FlatView *address_space_to_flatview(AddressSpace *as);
+typedef struct AddressSpaceDispatch AddressSpaceDispatch;
+typedef struct FlatRange FlatRange;
+
+/* Flattened global view of current active memory hierarchy. Kept in sorted
+ * order.
+ */
+struct FlatView {
+ struct rcu_head rcu;
+ unsigned ref;
+ FlatRange *ranges;
+ unsigned nr;
+ unsigned nr_allocated;
+ struct AddressSpaceDispatch *dispatch;
+ MemoryRegion *root;
+};
+
+static inline FlatView *address_space_to_flatview(AddressSpace *as)
+{
+ return atomic_rcu_read(&as->current_map);
+}
+
/**
* MemoryRegionSection: describes a fragment of a #MemoryRegion
diff --git a/memory.c b/memory.c
index c7f6588452..78d07aa51d 100644
--- a/memory.c
+++ b/memory.c
@@ -210,8 +210,6 @@ static bool memory_region_ioeventfd_equal(MemoryRegionIoeventfd a,
&& !memory_region_ioeventfd_before(b, a);
}
-typedef struct FlatRange FlatRange;
-
/* Range of memory in the global map. Addresses are absolute. */
struct FlatRange {
MemoryRegion *mr;
@@ -222,19 +220,6 @@ struct FlatRange {
bool readonly;
};
-/* Flattened global view of current active memory hierarchy. Kept in sorted
- * order.
- */
-struct FlatView {
- struct rcu_head rcu;
- unsigned ref;
- FlatRange *ranges;
- unsigned nr;
- unsigned nr_allocated;
- struct AddressSpaceDispatch *dispatch;
- MemoryRegion *root;
-};
-
typedef struct AddressSpaceOps AddressSpaceOps;
#define FOR_EACH_FLAT_RANGE(var, view) \
@@ -322,21 +307,6 @@ static void flatview_unref(FlatView *view)
}
}
-FlatView *address_space_to_flatview(AddressSpace *as)
-{
- return atomic_rcu_read(&as->current_map);
-}
-
-AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv)
-{
- return fv->dispatch;
-}
-
-AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as)
-{
- return flatview_to_dispatch(address_space_to_flatview(as));
-}
-
static bool can_merge(FlatRange *r1, FlatRange *r2)
{
return int128_eq(addrrange_end(r1->addr), r2->addr.start)
--
2.14.3
next prev parent reply other threads:[~2018-03-05 8:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-05 8:36 [Qemu-devel] [PATCH 0/7] memory: address_space_to_flatview needs RCU lock Paolo Bonzini
2018-03-05 8:36 ` [Qemu-devel] [PATCH 1/7] openpic_kvm: drop address_space_to_flatview call Paolo Bonzini
2018-03-06 0:10 ` David Gibson
2018-03-06 12:25 ` Paolo Bonzini
2018-03-06 7:46 ` Alexey Kardashevskiy
2018-03-05 8:36 ` Paolo Bonzini [this message]
2018-03-06 7:46 ` [Qemu-devel] [PATCH 2/7] memory: inline some performance-sensitive accessors Alexey Kardashevskiy
2018-03-05 8:36 ` [Qemu-devel] [PATCH 3/7] address_space_write: address_space_to_flatview needs RCU lock Paolo Bonzini
2018-03-06 7:46 ` Alexey Kardashevskiy
2018-03-05 8:36 ` [Qemu-devel] [PATCH 4/7] address_space_read: " Paolo Bonzini
2018-03-06 7:46 ` Alexey Kardashevskiy
2018-03-05 8:36 ` [Qemu-devel] [PATCH 5/7] address_space_access_valid: " Paolo Bonzini
2018-03-06 7:46 ` Alexey Kardashevskiy
2018-03-05 8:36 ` [Qemu-devel] [PATCH 6/7] address_space_map: " Paolo Bonzini
2018-03-06 7:46 ` Alexey Kardashevskiy
2018-03-05 8:36 ` [Qemu-devel] [PATCH 7/7] address_space_rw: " Paolo Bonzini
2018-03-06 7:47 ` Alexey Kardashevskiy
2018-03-06 7:47 ` [Qemu-devel] [PATCH 0/7] memory: " Alexey Kardashevskiy
2018-03-06 8:16 ` Paolo Bonzini
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=20180305083655.6186-3-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=aik@ozlabs.ru \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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).