]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: hint the main branch of dout() accordingly to default verbosity. 21259/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 5 Apr 2018 14:55:27 +0000 (16:55 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 10 Apr 2018 23:27:57 +0000 (01:27 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/common/likely.h
src/common/subsys_types.h
src/log/SubsystemMap.h

index e8146a3f69eb0884388e4e857a847276c3dd7fa5..c095dd39d3bd0cc9f1757e6116313dfb5cf8a420 100644 (file)
@@ -21,4 +21,6 @@
 #define likely(x)       __builtin_expect((x),1)
 #define unlikely(x)     __builtin_expect((x),0)
 
+#define expect(x, hint) __builtin_expect((x),(hint))
+
 #endif
index 385fbc4209fc346b7406e1d317dc2d78f9b8b7e6..52171809b23fde1cf84e56a8b0ff1af22a20006f 100644 (file)
@@ -53,6 +53,12 @@ ceph_subsys_get_as_array() {
 #undef DEFAULT_SUBSYS
 }
 
+constexpr static std::uint8_t
+ceph_subsys_get_max_default_level(const std::size_t subidx) {
+  const auto item = ceph_subsys_get_as_array()[subidx];
+  return std::max(item.log_level, item.gather_level);
+}
+
 // Compile time-capable version of std::strlen. Resorting to own
 // implementation only because C++17 doesn't mandate constexpr
 // on the standard one.
index 94d5d382b55db9bc3c5df98c154a9fb319dc0c54..934ee66036edca7d5146018f040dcaf714545d2b 100644 (file)
@@ -8,6 +8,7 @@
 #include <vector>
 #include <algorithm>
 
+#include "common/likely.h"
 #include "common/subsys_types.h"
 
 #include "include/assert.h"
@@ -74,11 +75,14 @@ public:
 
     if constexpr (LvlV <= 0) {
       // handle the -1 and 0 levels entirely at compile-time.
-      // Such debugs are intended be gathered regardless even
+      // Such debugs are intended to be gathered regardless even
       // of the user configuration.
       return true;
     } else {
-      return LvlV <= static_cast<int>(m_gather_levels[SubV]);
+      // we expect that setting level different than the default
+      // is rather unusual.
+      return expect(LvlV <= static_cast<int>(m_gather_levels[SubV]),
+                   LvlV <= ceph_subsys_get_max_default_level(SubV));
     }
   }
   bool should_gather(const unsigned sub, int level) {