summaryrefslogtreecommitdiff
path: root/Kernel/VM
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-12 11:38:43 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-12 11:38:43 +0100
commit3985468e83042ae8e9e2822fec73319d0b153843 (patch)
tree56abf644e45c85abe68ac20b7fc5de96b6cea715 /Kernel/VM
parent72cccfddbf0883f1b08e31b681607b372a089162 (diff)
downloadserenity-3985468e83042ae8e9e2822fec73319d0b153843.zip
Kernel: Convert klog() => AK::Format in PurgeablePageRanges
Diffstat (limited to 'Kernel/VM')
-rw-r--r--Kernel/VM/PurgeablePageRanges.cpp57
1 files changed, 30 insertions, 27 deletions
diff --git a/Kernel/VM/PurgeablePageRanges.cpp b/Kernel/VM/PurgeablePageRanges.cpp
index 3e3407286b..7cdedb3b9b 100644
--- a/Kernel/VM/PurgeablePageRanges.cpp
+++ b/Kernel/VM/PurgeablePageRanges.cpp
@@ -33,23 +33,26 @@
#include <Kernel/VM/PhysicalPage.h>
#include <Kernel/VM/PurgeablePageRanges.h>
-namespace Kernel {
-
-#if VOLATILE_PAGE_RANGES_DEBUG
-inline LogStream& operator<<(const LogStream& stream, const VolatilePageRange& range)
-{
- stream << "{" << range.base << " (" << range.count << ") purged: " << range.was_purged << "}";
- return const_cast<LogStream&>(stream);
+namespace AK {
+template<>
+struct Formatter<Kernel::VolatilePageRange> : Formatter<String> {
+ void format(FormatBuilder& builder, const Kernel::VolatilePageRange& value)
+ {
+ return Formatter<String>::format(builder, String::formatted("{{{} ({}) purged: {}}}", value.base, value.count, value.was_purged));
+ }
+};
}
+namespace Kernel {
+
static void dump_volatile_page_ranges(const Vector<VolatilePageRange>& ranges)
{
- for (size_t i = 0; i < ranges.size(); i++) {
- const auto& range = ranges[i];
- klog() << " [" << i << "] " << range;
+ if constexpr (VOLATILE_PAGE_RANGES_DEBUG) {
+ for (size_t i = 0; i < ranges.size(); i++) {
+ dbgln("[{}] {}", i, ranges[i]);
+ }
}
}
-#endif
void VolatilePageRanges::add_unchecked(const VolatilePageRange& range)
{
@@ -66,15 +69,15 @@ bool VolatilePageRanges::add(const VolatilePageRange& range)
return false;
add_range.was_purged = range.was_purged;
-#if VOLATILE_PAGE_RANGES_DEBUG
- klog() << "ADD " << range << " (total range: " << m_total_range << ") -->";
- dump_volatile_page_ranges(m_ranges);
- ScopeGuard debug_guard([&]() {
- klog() << "After adding " << range << " (total range: " << m_total_range << ")";
+ if constexpr (VOLATILE_PAGE_RANGES_DEBUG) {
+ dbgln("ADD {} (total range: {}) -->", range, m_total_range);
dump_volatile_page_ranges(m_ranges);
- klog() << "<-- ADD " << range << " (total range: " << m_total_range << ")";
- });
-#endif
+ ScopeGuard debug_guard([&]() {
+ dbgln("After adding {} (total range: {})", range, m_total_range);
+ dump_volatile_page_ranges(m_ranges);
+ dbgln("<-- ADD {} (total range: {})", range, m_total_range);
+ });
+ }
size_t nearby_index = 0;
auto* existing_range = binary_search(
@@ -140,15 +143,15 @@ bool VolatilePageRanges::remove(const VolatilePageRange& range, bool& was_purged
if (remove_range.is_empty())
return false;
-#if VOLATILE_PAGE_RANGES_DEBUG
- klog() << "REMOVE " << range << " (total range: " << m_total_range << ") -->";
- dump_volatile_page_ranges(m_ranges);
- ScopeGuard debug_guard([&]() {
- klog() << "After removing " << range << " (total range: " << m_total_range << ")";
+ if constexpr (VOLATILE_PAGE_RANGES_DEBUG) {
+ dbgln("REMOVE {} (total range: {}) -->", range, m_total_range);
dump_volatile_page_ranges(m_ranges);
- klog() << "<-- REMOVE " << range << " (total range: " << m_total_range << ") was_purged: " << was_purged;
- });
-#endif
+ ScopeGuard debug_guard([&]() {
+ dbgln("After removing {} (total range: {})", range, m_total_range);
+ dump_volatile_page_ranges(m_ranges);
+ dbgln("<-- REMOVE {} (total range: {}) was_purged: {}", range, m_total_range, was_purged);
+ });
+ }
size_t nearby_index = 0;
auto* existing_range = binary_search(