mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 15:30:52 +01:00
ircd::ctx: Expose stack usage functions to user.
This commit is contained in:
parent
cbdd176819
commit
f98be1582d
2 changed files with 14 additions and 2 deletions
|
@ -24,6 +24,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define HAVE_IRCD_CTX_PROF_H
|
#define HAVE_IRCD_CTX_PROF_H
|
||||||
|
|
||||||
|
namespace ircd::ctx
|
||||||
|
{
|
||||||
|
size_t stack_usage_here(const ctx &) __attribute__((noinline));
|
||||||
|
size_t stack_usage_here() __attribute__((noinline));
|
||||||
|
}
|
||||||
|
|
||||||
/* Profiling for the context system. These facilities provide tools and statistics.
|
/* Profiling for the context system. These facilities provide tools and statistics.
|
||||||
* The primary purpose here is to alert developers of unwanted context behavior, in
|
* The primary purpose here is to alert developers of unwanted context behavior, in
|
||||||
* addition to optimizing the overall performance of the context system.
|
* addition to optimizing the overall performance of the context system.
|
||||||
|
|
10
ircd/ctx.cc
10
ircd/ctx.cc
|
@ -617,7 +617,6 @@ namespace ircd::ctx::prof
|
||||||
{
|
{
|
||||||
time_point cur_slice_start; // Time slice state
|
time_point cur_slice_start; // Time slice state
|
||||||
|
|
||||||
size_t stack_usage_here(const ctx &) __attribute__((noinline));
|
|
||||||
void check_stack();
|
void check_stack();
|
||||||
void check_slice();
|
void check_slice();
|
||||||
void slice_start();
|
void slice_start();
|
||||||
|
@ -726,7 +725,14 @@ ircd::ctx::prof::check_stack()
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
ircd::ctx::prof::stack_usage_here(const ctx &ctx)
|
ircd::ctx::stack_usage_here()
|
||||||
|
{
|
||||||
|
assert(current);
|
||||||
|
return stack_usage_here(*current);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
ircd::ctx::stack_usage_here(const ctx &ctx)
|
||||||
{
|
{
|
||||||
return ctx.stack_base - uintptr_t(__builtin_frame_address(0));
|
return ctx.stack_base - uintptr_t(__builtin_frame_address(0));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue