[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/34] memory: inline some performance-sensitive acce
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 16/34] memory: inline some performance-sensitive accessors |
Date: |
Tue, 6 Mar 2018 14:19:12 +0100 |
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.
Reviewed-by: Alexey Kardashevskiy <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
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 4162474..6a5ee42 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 15e8111..4b65b56 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 6515131..e70b64b 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)
--
1.8.3.1
- [Qemu-devel] [PULL 13/34] sdhci-test: fix leaks, (continued)
- [Qemu-devel] [PULL 13/34] sdhci-test: fix leaks, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 14/34] chardev: fix leak in tcp_chr_telnet_init_io(), Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 12/34] ahci-test: fix opts leak of skip tests, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 15/34] openpic_kvm: drop address_space_to_flatview call, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 19/34] address_space_access_valid: address_space_to_flatview needs RCU lock, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 17/34] address_space_write: address_space_to_flatview needs RCU lock, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 22/34] checkpatch: add a warning for basename/dirname, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 18/34] address_space_read: address_space_to_flatview needs RCU lock, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 16/34] memory: inline some performance-sensitive accessors,
Paolo Bonzini <=
- [Qemu-devel] [PULL 20/34] address_space_map: address_space_to_flatview needs RCU lock, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 21/34] address_space_rw: address_space_to_flatview needs RCU lock, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 23/34] checkpatch: add check for `while` and `for`, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 24/34] Revert "build-sys: compile with -Og or -O1 when --enable-debug", Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 25/34] Fixing WHPX casing to match SDK, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 27/34] Remove unnecessary WHPX __debugbreak();, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 26/34] Resolves WHPX breaking changes in SDK 17095, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 29/34] Fix WHPX typo in 'mmio', Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 30/34] Fix WHPX issue leaking tpr values, Paolo Bonzini, 2018/03/06