0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 08:12:37 +01:00

ircd::allocator: Add argument for options string to info() interface.

This commit is contained in:
Jason Volk 2020-05-22 15:10:54 -07:00
parent f069cdfca0
commit c7b473485b
4 changed files with 23 additions and 6 deletions

View file

@ -40,7 +40,7 @@ namespace ircd::allocator
profile operator+(const profile &, const profile &);
profile operator-(const profile &, const profile &);
string_view info(const mutable_buffer &);
string_view info(const mutable_buffer &, const string_view &opts = {});
string_view get(const string_view &var, const mutable_buffer &val);
string_view set(const string_view &var, const string_view &val, const mutable_buffer &cur = {});
bool trim(const size_t &pad = 0) noexcept; // malloc_trim(3)

View file

@ -34,7 +34,8 @@ namespace ircd::allocator
#ifdef IRCD_ALLOCATOR_USE_GNU
ircd::string_view
ircd::allocator::info(const mutable_buffer &buf)
ircd::allocator::info(const mutable_buffer &buf,
[[unused]] const string_view &opts)
{
std::stringstream out;
pubsetbuf(out, buf);

View file

@ -125,7 +125,8 @@ catch(const std::bad_function_call &)
#if defined(IRCD_ALLOCATOR_JEMALLOC)
ircd::string_view
ircd::allocator::info(const mutable_buffer &buf)
ircd::allocator::info(const mutable_buffer &buf,
const string_view &opts_)
{
std::stringstream out;
pubsetbuf(out, buf);
@ -136,9 +137,12 @@ ircd::allocator::info(const mutable_buffer &buf)
out << msg;
};
static const char *const &opts
thread_local char opts_buf[64];
const char *const opts
{
""
opts_?
data(strlcpy(opts_buf, opts_)):
""
};
malloc_stats_print(je::stats_handler, &out, opts);

View file

@ -1028,6 +1028,18 @@ console_cmd__proc__smaps(opt &out, const string_view &line)
bool
console_cmd__mem(opt &out, const string_view &line)
{
const params param{line, " ",
{
"opts"
}};
// Optional options string passed to implementation; might not be available
// or ignored. See jemalloc(3) etc.
const string_view &opts
{
param["opts"]
};
auto &this_thread
{
ircd::allocator::profile::this_thread
@ -1043,7 +1055,7 @@ console_cmd__mem(opt &out, const string_view &line)
thread_local char buf[48_KiB];
out << "Allocator information:" << std::endl
<< allocator::info(buf) << std::endl
<< allocator::info(buf, opts) << std::endl
;
return true;