#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
+#define expect(x, hint) __builtin_expect((x),(hint))
+
#endif
#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.
#include <vector>
#include <algorithm>
+#include "common/likely.h"
#include "common/subsys_types.h"
#include "include/assert.h"
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) {