From 6679b668069cff345cfff127e31348a85273744e Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 6 Mar 2020 15:19:05 -0800 Subject: [PATCH] ircd::prof: Move ctx::syscall_usage_warning into prof. --- include/ircd/ctx/ctx.h | 1 - include/ircd/prof/prof.h | 1 + .../{ctx => prof}/syscall_usage_warning.h | 19 ++++---- ircd/ctx.cc | 41 ---------------- ircd/fs.cc | 6 +-- ircd/fs_aio.cc | 2 +- ircd/prof.cc | 47 +++++++++++++++++++ 7 files changed, 61 insertions(+), 56 deletions(-) rename include/ircd/{ctx => prof}/syscall_usage_warning.h (71%) diff --git a/include/ircd/ctx/ctx.h b/include/ircd/ctx/ctx.h index f7e1d75e6..ee4d05853 100644 --- a/include/ircd/ctx/ctx.h +++ b/include/ircd/ctx/ctx.h @@ -83,7 +83,6 @@ namespace ircd::ctx #include "sleep.h" #include "stack_usage_assertion.h" #include "slice_usage_warning.h" -#include "syscall_usage_warning.h" #include "critical_assertion.h" #include "critical_indicator.h" #include "exception_handler.h" diff --git a/include/ircd/prof/prof.h b/include/ircd/prof/prof.h index 72ec3fe5e..12a4e9c4b 100644 --- a/include/ircd/prof/prof.h +++ b/include/ircd/prof/prof.h @@ -39,6 +39,7 @@ namespace ircd::prof #include "cycles.h" #include "scope_cycles.h" #include "syscall_timer.h" +#include "syscall_usage_warning.h" #include "instructions.h" #include "resource.h" #include "times.h" diff --git a/include/ircd/ctx/syscall_usage_warning.h b/include/ircd/prof/syscall_usage_warning.h similarity index 71% rename from include/ircd/ctx/syscall_usage_warning.h rename to include/ircd/prof/syscall_usage_warning.h index fbb04bf40..f2023e0de 100644 --- a/include/ircd/ctx/syscall_usage_warning.h +++ b/include/ircd/prof/syscall_usage_warning.h @@ -1,7 +1,7 @@ -// Matrix Construct +// The Construct // -// Copyright (C) Matrix Construct Developers, Authors & Contributors -// Copyright (C) 2016-2019 Jason Volk +// Copyright (C) The Construct Developers, Authors & Contributors +// Copyright (C) 2016-2020 Jason Volk // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above @@ -9,16 +9,15 @@ // full license for this software is available in the LICENSE file. #pragma once -#define HAVE_IRCD_CTX_SYSCALL_USAGE_WARNING_H +#define HAVE_IRCD_PROF_SYSCALL_USAGE_WARNING_H -namespace ircd::ctx { -inline namespace this_ctx +namespace ircd::prof { struct syscall_usage_warning; -}} +} -#ifndef NDEBUG -struct ircd::ctx::this_ctx::syscall_usage_warning +#ifdef RB_DEBUG +struct ircd::prof::syscall_usage_warning { const string_view fmt; const va_rtti ap; @@ -37,7 +36,7 @@ struct ircd::ctx::this_ctx::syscall_usage_warning ~syscall_usage_warning() noexcept; }; #else -struct ircd::ctx::this_ctx::syscall_usage_warning +struct ircd::prof::syscall_usage_warning { syscall_usage_warning(const string_view &fmt, ...) { diff --git a/ircd/ctx.cc b/ircd/ctx.cc index 9a800ccba..92a8f59b1 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -924,47 +924,6 @@ noexcept } #endif -/////////////////////////////////////////////////////////////////////////////// -// -// ctx/syscall_usage_warning.h -// - -#ifndef NDEBUG -ircd::ctx::this_ctx::syscall_usage_warning::~syscall_usage_warning() -noexcept -{ - const uint64_t total - { - timer.stopped? - timer.at(): - timer.sample() - }; - - if(likely(!total)) - return; - - thread_local char buf[512]; - const string_view reason - { - fmt::vsprintf{buf, fmt, ap} - }; - - thread_local char tmbuf[64]; - log::dwarning - { - log, "[%s] context id:%lu watchdog :system call took %s :%s", - current? - name(cur()): - ios::handler::current? - name(*ios::handler::current): - "*"_sv, - current? id(cur()) : 0, - pretty_nanoseconds(tmbuf, total, true), - reason - }; -} -#endif - /////////////////////////////////////////////////////////////////////////////// // // ctx/slice_usage_warning.h diff --git a/ircd/fs.cc b/ircd/fs.cc index 9f3c12346..dc6d48332 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -461,7 +461,7 @@ ircd::fs::sync(const fd &fd, const sync_opts &opts) { assert(opts.op == op::SYNC); - const ctx::syscall_usage_warning message + const prof::syscall_usage_warning message { "fs::sync(fd:%d)", int(fd) }; @@ -504,7 +504,7 @@ ircd::fs::flush(const fd &fd, } #endif - const ctx::syscall_usage_warning message + const prof::syscall_usage_warning message { "fs::flush(fd:%d, {metadata:%b aio:%b:%b})", int(fd), @@ -1705,7 +1705,7 @@ ircd::fs::fd::fd(const string_view &path, :fdno{[&path, &opts] () -> int { - const ctx::syscall_usage_warning message + const prof::syscall_usage_warning message { "fs::fs::fd(): open(2): %s", path }; diff --git a/ircd/fs_aio.cc b/ircd/fs_aio.cc index 19747d3b5..c8d27e172 100644 --- a/ircd/fs_aio.cc +++ b/ircd/fs_aio.cc @@ -932,7 +932,7 @@ try count_queued(op::SYNC), }; - ctx::syscall_usage_warning warning + prof::syscall_usage_warning warning { "fs::aio::system::submit(in_flight:%zu qcount:%zu r:%zu w:%zu s:%zu)", in_flight, diff --git a/ircd/prof.cc b/ircd/prof.cc index 22492a21d..3a6a30ca9 100644 --- a/ircd/prof.cc +++ b/ircd/prof.cc @@ -95,6 +95,53 @@ noexcept start(); } +/////////////////////////////////////////////////////////////////////////////// +// +// prof/syscall_usage_warning.h +// + +#ifdef RB_DEBUG +ircd::prof::syscall_usage_warning::~syscall_usage_warning() +noexcept +{ + const uint64_t total + { + timer.stopped? + timer.at(): + timer.sample() + }; + + if(likely(!total)) + return; + + thread_local char buf[512]; + const string_view reason + { + fmt::vsprintf + { + buf, fmt, ap + } + }; + + thread_local char tmbuf[64]; + log::dwarning + { + log, "[%s] context id:%lu watchdog :system call took %s :%s", + ctx::current? + name(ctx::cur()): + ios::handler::current? + name(*ios::handler::current): + "*"_sv, + ctx::current? + id(ctx::cur()): + 0, + pretty_nanoseconds(tmbuf, total, true), + reason + }; +} +#endif + + /////////////////////////////////////////////////////////////////////////////// // // prof/syscall_timer.h