Blame SOURCES/kvm-memory-inline-some-performance-sensitive-accessors.patch

37e7a1
From 30484611dd815207d249e2034b976ac05753487d Mon Sep 17 00:00:00 2001
37e7a1
From: Paolo Bonzini <pbonzini@redhat.com>
37e7a1
Date: Thu, 8 Mar 2018 15:58:14 +0100
37e7a1
Subject: [PATCH 01/17] memory: inline some performance-sensitive accessors
37e7a1
37e7a1
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
37e7a1
Message-id: <20180308155819.20598-2-pbonzini@redhat.com>
37e7a1
Patchwork-id: 79193
37e7a1
O-Subject: [RHEL7.5 qemu-kvm-rhev PATCH 1/6] memory: inline some performance-sensitive accessors
37e7a1
Bugzilla: 1554930
37e7a1
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
37e7a1
RH-Acked-by: Thomas Huth <thuth@redhat.com>
37e7a1
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
37e7a1
37e7a1
These accessors are called from inlined functions, and the call sequence
37e7a1
is much more expensive than just inlining the access.  Move the
37e7a1
struct declaration to memory-internal.h so that exec.c and memory.c
37e7a1
can both use an inline function.
37e7a1
37e7a1
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
37e7a1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
37e7a1
(cherry pick from commit 785a507ec78bbda1c346f3d3593e5a58b62e73ef)
37e7a1
37e7a1
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
37e7a1
---
37e7a1
 include/exec/memory-internal.h | 13 +++++++++----
37e7a1
 include/exec/memory.h          | 22 +++++++++++++++++++++-
37e7a1
 memory.c                       | 30 ------------------------------
37e7a1
 3 files changed, 30 insertions(+), 35 deletions(-)
37e7a1
37e7a1
diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h
37e7a1
index 647e9bd..fca523f 100644
37e7a1
--- a/include/exec/memory-internal.h
37e7a1
+++ b/include/exec/memory-internal.h
37e7a1
@@ -20,7 +20,15 @@
37e7a1
 #define MEMORY_INTERNAL_H
37e7a1
 
37e7a1
 #ifndef CONFIG_USER_ONLY
37e7a1
-typedef struct AddressSpaceDispatch AddressSpaceDispatch;
37e7a1
+static inline AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv)
37e7a1
+{
37e7a1
+    return fv->dispatch;
37e7a1
+}
37e7a1
+
37e7a1
+static inline AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as)
37e7a1
+{
37e7a1
+    return flatview_to_dispatch(address_space_to_flatview(as));
37e7a1
+}
37e7a1
 
37e7a1
 extern const MemoryRegionOps unassigned_mem_ops;
37e7a1
 
37e7a1
@@ -30,9 +38,6 @@ bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr,
37e7a1
 void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section);
37e7a1
 AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv);
37e7a1
 void address_space_dispatch_compact(AddressSpaceDispatch *d);
37e7a1
-
37e7a1
-AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as);
37e7a1
-AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv);
37e7a1
 void address_space_dispatch_free(AddressSpaceDispatch *d);
37e7a1
 
37e7a1
 void mtree_print_dispatch(fprintf_function mon, void *f,
37e7a1
diff --git a/include/exec/memory.h b/include/exec/memory.h
37e7a1
index b100df6..3df0dcc 100644
37e7a1
--- a/include/exec/memory.h
37e7a1
+++ b/include/exec/memory.h
37e7a1
@@ -328,7 +328,27 @@ struct AddressSpace {
37e7a1
     QTAILQ_ENTRY(AddressSpace) address_spaces_link;
37e7a1
 };
37e7a1
 
37e7a1
-FlatView *address_space_to_flatview(AddressSpace *as);
37e7a1
+typedef struct AddressSpaceDispatch AddressSpaceDispatch;
37e7a1
+typedef struct FlatRange FlatRange;
37e7a1
+
37e7a1
+/* Flattened global view of current active memory hierarchy.  Kept in sorted
37e7a1
+ * order.
37e7a1
+ */
37e7a1
+struct FlatView {
37e7a1
+    struct rcu_head rcu;
37e7a1
+    unsigned ref;
37e7a1
+    FlatRange *ranges;
37e7a1
+    unsigned nr;
37e7a1
+    unsigned nr_allocated;
37e7a1
+    struct AddressSpaceDispatch *dispatch;
37e7a1
+    MemoryRegion *root;
37e7a1
+};
37e7a1
+
37e7a1
+static inline FlatView *address_space_to_flatview(AddressSpace *as)
37e7a1
+{
37e7a1
+    return atomic_rcu_read(&as->current_map);
37e7a1
+}
37e7a1
+
37e7a1
 
37e7a1
 /**
37e7a1
  * MemoryRegionSection: describes a fragment of a #MemoryRegion
37e7a1
diff --git a/memory.c b/memory.c
37e7a1
index a1f1e68..5a91b9b 100644
37e7a1
--- a/memory.c
37e7a1
+++ b/memory.c
37e7a1
@@ -210,8 +210,6 @@ static bool memory_region_ioeventfd_equal(MemoryRegionIoeventfd a,
37e7a1
         && !memory_region_ioeventfd_before(b, a);
37e7a1
 }
37e7a1
 
37e7a1
-typedef struct FlatRange FlatRange;
37e7a1
-
37e7a1
 /* Range of memory in the global map.  Addresses are absolute. */
37e7a1
 struct FlatRange {
37e7a1
     MemoryRegion *mr;
37e7a1
@@ -222,19 +220,6 @@ struct FlatRange {
37e7a1
     bool readonly;
37e7a1
 };
37e7a1
 
37e7a1
-/* Flattened global view of current active memory hierarchy.  Kept in sorted
37e7a1
- * order.
37e7a1
- */
37e7a1
-struct FlatView {
37e7a1
-    struct rcu_head rcu;
37e7a1
-    unsigned ref;
37e7a1
-    FlatRange *ranges;
37e7a1
-    unsigned nr;
37e7a1
-    unsigned nr_allocated;
37e7a1
-    struct AddressSpaceDispatch *dispatch;
37e7a1
-    MemoryRegion *root;
37e7a1
-};
37e7a1
-
37e7a1
 typedef struct AddressSpaceOps AddressSpaceOps;
37e7a1
 
37e7a1
 #define FOR_EACH_FLAT_RANGE(var, view)          \
37e7a1
@@ -322,21 +307,6 @@ static void flatview_unref(FlatView *view)
37e7a1
     }
37e7a1
 }
37e7a1
 
37e7a1
-FlatView *address_space_to_flatview(AddressSpace *as)
37e7a1
-{
37e7a1
-    return atomic_rcu_read(&as->current_map);
37e7a1
-}
37e7a1
-
37e7a1
-AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv)
37e7a1
-{
37e7a1
-    return fv->dispatch;
37e7a1
-}
37e7a1
-
37e7a1
-AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as)
37e7a1
-{
37e7a1
-    return flatview_to_dispatch(address_space_to_flatview(as));
37e7a1
-}
37e7a1
-
37e7a1
 static bool can_merge(FlatRange *r1, FlatRange *r2)
37e7a1
 {
37e7a1
     return int128_eq(addrrange_end(r1->addr), r2->addr.start)
37e7a1
-- 
37e7a1
1.8.3.1
37e7a1