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

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