Add some tracing to the backend
This commit is contained in:
committed by
Matthew Parkinson
parent
9f9964239e
commit
325c013e85
@@ -117,23 +117,33 @@ namespace snmalloc
|
||||
}
|
||||
|
||||
// Global range of memory
|
||||
using GlobalR = GlobalRange<
|
||||
LargeBuddyRange<Base, 24, bits::BITS - 1, Pagemap, MinBaseSizeBits()>>;
|
||||
using GlobalR = GlobalRange<LogRange<
|
||||
2,
|
||||
LargeBuddyRange<Base, 24, bits::BITS - 1, Pagemap, MinBaseSizeBits()>>>;
|
||||
|
||||
#ifdef SNMALLOC_META_PROTECTED
|
||||
// Introduce two global ranges, so we don't mix Object and Meta
|
||||
using CentralObectRange = GlobalRange<
|
||||
LargeBuddyRange<GlobalR, 24, bits::BITS - 1, Pagemap, MinBaseSizeBits()>>;
|
||||
using CentralMetaRange = GlobalRange<LargeBuddyRange<
|
||||
SubRange<GlobalR, PAL, 6>, // Use SubRange to introduce guard pages.
|
||||
24,
|
||||
bits::BITS - 1,
|
||||
Pagemap,
|
||||
MinBaseSizeBits()>>;
|
||||
using CentralObjectRange = GlobalRange<LogRange<
|
||||
3,
|
||||
LargeBuddyRange<
|
||||
GlobalR,
|
||||
24,
|
||||
bits::BITS - 1,
|
||||
Pagemap,
|
||||
MinBaseSizeBits()>>>;
|
||||
using CentralMetaRange = GlobalRange<LogRange<
|
||||
4,
|
||||
LargeBuddyRange<
|
||||
SubRange<GlobalR, PAL, 6>, // Use SubRange to introduce guard pages.
|
||||
24,
|
||||
bits::BITS - 1,
|
||||
Pagemap,
|
||||
MinBaseSizeBits()>>>;
|
||||
|
||||
// Source for object allocations
|
||||
using StatsObject = StatsRange<CommitRange<CentralObectRange, PAL>>;
|
||||
using ObjectRange = LargeBuddyRange<StatsObject, 21, 21, Pagemap>;
|
||||
using StatsObject = StatsRange<CommitRange<CentralObjectRange, PAL>>;
|
||||
using ObjectRange =
|
||||
LogRange<5, LargeBuddyRange<StatsObject, 21, 21, Pagemap>>;
|
||||
|
||||
using StatsMeta = StatsRange<CommitRange<CentralMetaRange, PAL>>;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "empty_range.h"
|
||||
#include "globalrange.h"
|
||||
#include "largebuddyrange.h"
|
||||
#include "logrange.h"
|
||||
#include "pagemap.h"
|
||||
#include "pagemapregisterrange.h"
|
||||
#include "palrange.h"
|
||||
|
||||
52
src/snmalloc/backend_helpers/logrange.h
Normal file
52
src/snmalloc/backend_helpers/logrange.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
namespace snmalloc
|
||||
{
|
||||
/**
|
||||
* RangeName is an integer to specify which range is being logged. Strings can
|
||||
* be used as template parameters.
|
||||
*
|
||||
* ParentRange is what the range is logging calls to.
|
||||
*/
|
||||
template<size_t RangeName, typename ParentRange>
|
||||
class LogRange
|
||||
{
|
||||
ParentRange parent{};
|
||||
|
||||
public:
|
||||
static constexpr bool Aligned = ParentRange::Aligned;
|
||||
|
||||
static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe;
|
||||
|
||||
constexpr LogRange() = default;
|
||||
|
||||
capptr::Chunk<void> alloc_range(size_t size)
|
||||
{
|
||||
#ifdef SNMALLOC_TRACING
|
||||
message<1024>("Call alloc_range({}) on {}", size, RangeName);
|
||||
#endif
|
||||
auto range = parent.alloc_range(size);
|
||||
#ifdef SNMALLOC_TRACING
|
||||
message<1024>(
|
||||
"{} = alloc_range({}) in {}", range.unsafe_ptr(), size, RangeName);
|
||||
#endif
|
||||
return range;
|
||||
}
|
||||
|
||||
void dealloc_range(capptr::Chunk<void> base, size_t size)
|
||||
{
|
||||
#ifdef SNMALLOC_TRACING
|
||||
message<1024>(
|
||||
"dealloc_range({}, {}}) on {}", base.unsafe_ptr(), size, RangeName);
|
||||
#endif
|
||||
parent.dealloc_range(base, size);
|
||||
#ifdef SNMALLOC_TRACING
|
||||
message<1024>(
|
||||
"Done dealloc_range({}, {}})! on {}",
|
||||
base.unsafe_ptr(),
|
||||
size,
|
||||
RangeName);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
} // namespace snmalloc
|
||||
Reference in New Issue
Block a user