From: Radoslaw Zarzynski Date: Thu, 5 Apr 2018 14:55:27 +0000 (+0200) Subject: common: hint the main branch of dout() accordingly to default verbosity. X-Git-Tag: v13.1.0~321^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bebf35a61d0aa7e2d14c6c5ec8590081565b8214;p=ceph.git common: hint the main branch of dout() accordingly to default verbosity. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/common/likely.h b/src/common/likely.h index e8146a3f69e..c095dd39d3b 100644 --- a/src/common/likely.h +++ b/src/common/likely.h @@ -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 diff --git a/src/common/subsys_types.h b/src/common/subsys_types.h index 385fbc4209f..52171809b23 100644 --- a/src/common/subsys_types.h +++ b/src/common/subsys_types.h @@ -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. diff --git a/src/log/SubsystemMap.h b/src/log/SubsystemMap.h index 94d5d382b55..934ee66036e 100644 --- a/src/log/SubsystemMap.h +++ b/src/log/SubsystemMap.h @@ -8,6 +8,7 @@ #include #include +#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(m_gather_levels[SubV]); + // we expect that setting level different than the default + // is rather unusual. + return expect(LvlV <= static_cast(m_gather_levels[SubV]), + LvlV <= ceph_subsys_get_max_default_level(SubV)); } } bool should_gather(const unsigned sub, int level) {