]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: inline for the sake of BitMapAreaLeaf::child_check_n_lock.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 2 Mar 2017 08:07:17 +0000 (09:07 +0100)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 2 Mar 2017 11:03:59 +0000 (12:03 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/os/bluestore/BitAllocator.cc
src/os/bluestore/BitAllocator.h

index b5dea053cc799ddd91ff5b73734200474ef30be9..b74e8100c6da2490d63795ca67472b7328f09600 100644 (file)
@@ -44,60 +44,6 @@ int64_t BitMapZone::total_blocks = 0;
 bool BmapEntry::m_bit_mask_init = false;
 bmap_mask_vec_t BmapEntry::m_bit_to_mask;
 
-/*
- * BmapEntityList functions.
- */
-void BmapEntityListIter::init(BitMapAreaList *list, int64_t start_idx, bool wrap)
-{
-  m_list = list;
-  m_start_idx = start_idx;
-  m_cur_idx = m_start_idx;
-  m_wrap = wrap;
-  m_wrapped = false;
-  m_end = false;
-}
-
-BmapEntityListIter::BmapEntityListIter(BitMapAreaList *list, int64_t start_idx)
-{
-  init(list, start_idx, false);
-}
-
-BmapEntityListIter::BmapEntityListIter(BitMapAreaList *list, int64_t start_idx, bool wrap)
-{
-  init(list, start_idx, wrap);
-}
-
-BitMapArea* BmapEntityListIter::next()
-{
-  int64_t cur_idx = m_cur_idx;
-
-  if (m_wrapped &&
-    cur_idx == m_start_idx) {
-    /*
-     * End of wrap cycle + 1
-     */
-    if (!m_end) {
-      m_end = true;
-      return m_list->get_nth_item(cur_idx);
-    }
-    return NULL;
-  }
-  m_cur_idx++;
-
-  if (m_cur_idx == m_list->size() &&
-      m_wrap) {
-    m_cur_idx = 0;
-    m_wrapped = true;
-  }
-  if (cur_idx == m_list->size()) {
-    /*
-     * End of list
-     */
-    return NULL;
-  }
-  alloc_assert(cur_idx < m_list->size());
-  return m_list->get_nth_item(cur_idx);
-}
 
 int64_t BmapEntityListIter::index()
 {
@@ -370,7 +316,8 @@ int64_t BitMapZone::add_used_blocks(int64_t num_blocks)
   return std::atomic_fetch_add(&m_used_blocks, (int32_t)num_blocks) + num_blocks;
 }
 
-int64_t BitMapZone::get_used_blocks()
+/* Intensionally hinted because BitMapAreaLeaf::child_check_n_lock. */
+inline int64_t BitMapZone::get_used_blocks()
 {
   return std::atomic_load(&m_used_blocks);
 }
@@ -417,8 +364,13 @@ BitMapZone::~BitMapZone()
 
 /*
  * Check if some search took zone marker to end.
+ *
+ * The inline hint has been added intensionally because of importance of this
+ * method for BitMapAreaLeaf::child_check_n_lock, and thus for the overall
+ * allocator's performance. Examination of disassemblies coming from GCC 5.4.0
+ * showed that the compiler really needs that hint.
  */
-bool BitMapZone::is_exhausted()
+inline bool BitMapZone::is_exhausted()
 {
   /* BitMapZone::get_used_blocks operates atomically. No need for lock. */
   return get_used_blocks() == size();
@@ -1095,9 +1047,10 @@ BitMapAreaLeaf::~BitMapAreaLeaf()
   unlock();
 }
 
-bool BitMapAreaLeaf::child_check_n_lock(BitMapZone* const child,
-                                        const int64_t required,
-                                        const bool lock)
+/* Intensionally hinted because BitMapAreaLeaf::alloc_blocks_dis_int. */
+inline bool BitMapAreaLeaf::child_check_n_lock(BitMapZone* const child,
+                                               const int64_t required,
+                                               const bool lock)
 {
   /* The exhausted check can be performed without acquiring the lock. This
    * is because 1) BitMapZone::is_exhausted() actually operates atomically
index 2b24a324fcee165ec6c87a89aca7ab7f7a77a64d..43570d24b8c6934dbdd43e393f73199e45020646 100644 (file)
@@ -283,25 +283,58 @@ public:
   }
 };
 
+/* Intensionally inlined for the sake of BitMapAreaLeaf::alloc_blocks_dis_int. */
 class BmapEntityListIter {
-  BitMapAreaList *m_list;
+  BitMapAreaListm_list;
   int64_t m_start_idx;
   int64_t m_cur_idx;
   bool m_wrap;
   bool m_wrapped;
   bool m_end;
-public:
-
-  void init(BitMapAreaList *list, int64_t start_idx, bool wrap);
-  BmapEntityListIter(BitMapAreaList *list);
 
-  BmapEntityListIter(BitMapAreaList *list, bool wrap);
+public:
+  BmapEntityListIter(BitMapAreaList* const list,
+                     const int64_t start_idx,
+                     const bool wrap = false)
+    : m_list(list),
+      m_start_idx(start_idx),
+      m_cur_idx(start_idx),
+      m_wrap(wrap),
+      m_wrapped(false),
+      m_end(false) {
+  }
+
+  BitMapArea* next() {
+    int64_t cur_idx = m_cur_idx;
 
-  BmapEntityListIter(BitMapAreaList *list, int64_t start_idx);
+    if (m_wrapped &&
+      cur_idx == m_start_idx) {
+      /*
+       * End of wrap cycle + 1
+       */
+      if (!m_end) {
+        m_end = true;
+        return m_list->get_nth_item(cur_idx);
+      }
+      return NULL;
+    }
+    m_cur_idx++;
 
-  BmapEntityListIter(BitMapAreaList *list, int64_t start_idx, bool wrap);
+    if (m_cur_idx == m_list->size() &&
+        m_wrap) {
+      m_cur_idx = 0;
+      m_wrapped = true;
+    }
+    if (cur_idx == m_list->size()) {
+      /*
+       * End of list
+       */
+      return NULL;
+    }
+    alloc_assert(cur_idx < m_list->size());
+    return m_list->get_nth_item(cur_idx);
+  }
 
-  BitMapArea *next();
   int64_t index();
 };