* Added kernel tracing for the page daemon and the page writer.
* Added some commented out debug output in vm.cpp. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27971 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -28,6 +28,8 @@
|
|||||||
#define KERNEL_HEAP_TRACING 0
|
#define KERNEL_HEAP_TRACING 0
|
||||||
#define KTRACE_PRINTF_STACK_TRACE 0 /* stack trace depth */
|
#define KTRACE_PRINTF_STACK_TRACE 0 /* stack trace depth */
|
||||||
#define PAGE_ALLOCATION_TRACING 0
|
#define PAGE_ALLOCATION_TRACING 0
|
||||||
|
#define PAGE_DAEMON_TRACING 0
|
||||||
|
#define PAGE_WRITER_TRACING 0
|
||||||
#define PARANOIA_TRACING 0
|
#define PARANOIA_TRACING 0
|
||||||
#define PARANOIA_TRACING_STACK_TRACE 0 /* stack trace depth */
|
#define PARANOIA_TRACING_STACK_TRACE 0 /* stack trace depth */
|
||||||
#define OBJECT_CACHE_TRACING 0
|
#define OBJECT_CACHE_TRACING 0
|
||||||
|
|||||||
@@ -1529,6 +1529,9 @@ map_backing_store(vm_address_space *addressSpace, vm_cache *cache,
|
|||||||
// grab a ref to the address space (the area holds this)
|
// grab a ref to the address space (the area holds this)
|
||||||
atomic_add(&addressSpace->ref_count, 1);
|
atomic_add(&addressSpace->ref_count, 1);
|
||||||
|
|
||||||
|
// ktrace_printf("map_backing_store: cache: %p (source: %p), \"%s\" -> %p",
|
||||||
|
// cache, sourceCache, areaName, area);
|
||||||
|
|
||||||
*_area = area;
|
*_area = area;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
@@ -4717,6 +4720,10 @@ vm_soft_fault(vm_address_space *addressSpace, addr_t originalAddress,
|
|||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ktrace_printf("page fault: %s %#lx, %s, area: %p",
|
||||||
|
// isWrite ? "write" : "read", originalAddress, isUser ? "user" : "kernel",
|
||||||
|
// area);
|
||||||
|
|
||||||
// check permissions
|
// check permissions
|
||||||
uint32 protection = get_area_page_protection(area, address);
|
uint32 protection = get_area_page_protection(area, address);
|
||||||
if (isUser && (protection & B_USER_PROTECTION) == 0) {
|
if (isUser && (protection & B_USER_PROTECTION) == 0) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
|
#include <tracing.h>
|
||||||
#include <vm.h>
|
#include <vm.h>
|
||||||
#include <vm_priv.h>
|
#include <vm_priv.h>
|
||||||
#include <vm_cache.h>
|
#include <vm_cache.h>
|
||||||
@@ -109,6 +110,84 @@ PageCacheLocker::Unlock()
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
#if PAGE_DAEMON_TRACING
|
||||||
|
|
||||||
|
namespace PageDaemonTracing {
|
||||||
|
|
||||||
|
class ActivatePage : public AbstractTraceEntry {
|
||||||
|
public:
|
||||||
|
ActivatePage(vm_page* page)
|
||||||
|
:
|
||||||
|
fCache(page->cache),
|
||||||
|
fPage(page)
|
||||||
|
{
|
||||||
|
Initialized();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void AddDump(TraceOutput& out)
|
||||||
|
{
|
||||||
|
out.Print("page activated: %p, cache: %p", fPage, fCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
VMCache* fCache;
|
||||||
|
vm_page* fPage;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class DeactivatePage : public AbstractTraceEntry {
|
||||||
|
public:
|
||||||
|
DeactivatePage(vm_page* page)
|
||||||
|
:
|
||||||
|
fCache(page->cache),
|
||||||
|
fPage(page)
|
||||||
|
{
|
||||||
|
Initialized();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void AddDump(TraceOutput& out)
|
||||||
|
{
|
||||||
|
out.Print("page deactivated: %p, cache: %p", fPage, fCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
VMCache* fCache;
|
||||||
|
vm_page* fPage;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class FreedPageSwap : public AbstractTraceEntry {
|
||||||
|
public:
|
||||||
|
FreedPageSwap(vm_page* page)
|
||||||
|
:
|
||||||
|
fCache(page->cache),
|
||||||
|
fPage(page)
|
||||||
|
{
|
||||||
|
Initialized();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void AddDump(TraceOutput& out)
|
||||||
|
{
|
||||||
|
out.Print("page swap freed: %p, cache: %p", fPage, fCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
VMCache* fCache;
|
||||||
|
vm_page* fPage;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PageDaemonTracing
|
||||||
|
|
||||||
|
# define T(x) new(std::nothrow) PageDaemonTracing::x
|
||||||
|
|
||||||
|
#else
|
||||||
|
# define T(x)
|
||||||
|
#endif // PAGE_DAEMON_TRACING
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
#ifdef TRACK_PAGE_USAGE_STATS
|
#ifdef TRACK_PAGE_USAGE_STATS
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -205,6 +284,7 @@ check_page_activation(int32 index)
|
|||||||
vm_page_set_state(page, PAGE_STATE_ACTIVE);
|
vm_page_set_state(page, PAGE_STATE_ACTIVE);
|
||||||
page->usage_count = 1;
|
page->usage_count = 1;
|
||||||
TRACE(("page %p -> move to active\n", page));
|
TRACE(("page %p -> move to active\n", page));
|
||||||
|
T(ActivatePage(page));
|
||||||
} else if (page->usage_count < 127)
|
} else if (page->usage_count < 127)
|
||||||
page->usage_count++;
|
page->usage_count++;
|
||||||
|
|
||||||
@@ -237,6 +317,7 @@ check_page_activation(int32 index)
|
|||||||
else
|
else
|
||||||
vm_page_set_state(page, PAGE_STATE_INACTIVE);
|
vm_page_set_state(page, PAGE_STATE_INACTIVE);
|
||||||
TRACE(("page %p -> move to inactive\n", page));
|
TRACE(("page %p -> move to inactive\n", page));
|
||||||
|
T(DeactivatePage(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -260,6 +341,7 @@ free_page_swap_space(int32 index)
|
|||||||
// We need to mark the page modified, since otherwise it could be
|
// We need to mark the page modified, since otherwise it could be
|
||||||
// stolen and we'd lose its data.
|
// stolen and we'd lose its data.
|
||||||
vm_page_set_state(page, PAGE_STATE_MODIFIED);
|
vm_page_set_state(page, PAGE_STATE_MODIFIED);
|
||||||
|
T(FreedPageSwap(page));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,7 +381,7 @@ page_daemon(void* /*unused*/)
|
|||||||
* pagesLeft / sLowPagesCount;
|
* pagesLeft / sLowPagesCount;
|
||||||
uint32 leftToFree = sLowPagesCount - pagesLeft;
|
uint32 leftToFree = sLowPagesCount - pagesLeft;
|
||||||
TRACE(("wait interval %Ld, scan pages %lu, free %lu, "
|
TRACE(("wait interval %Ld, scan pages %lu, free %lu, "
|
||||||
"target %lu\n", scanWaitInterval, scanPagesCount,
|
"target %lu\n", scanWaitInterval, scanPagesCount,
|
||||||
pagesLeft, leftToFree));
|
pagesLeft, leftToFree));
|
||||||
|
|
||||||
for (uint32 i = 0; i < scanPagesCount && leftToFree > 0; i++) {
|
for (uint32 i = 0; i < scanPagesCount && leftToFree > 0; i++) {
|
||||||
|
|||||||
@@ -230,6 +230,39 @@ class StolenPage : public AbstractTraceEntry {
|
|||||||
#endif // PAGE_ALLOCATION_TRACING
|
#endif // PAGE_ALLOCATION_TRACING
|
||||||
|
|
||||||
|
|
||||||
|
#if PAGE_WRITER_TRACING
|
||||||
|
|
||||||
|
namespace PageWriterTracing {
|
||||||
|
|
||||||
|
class WritePage : public AbstractTraceEntry {
|
||||||
|
public:
|
||||||
|
WritePage(vm_page* page)
|
||||||
|
:
|
||||||
|
fCache(page->cache),
|
||||||
|
fPage(page)
|
||||||
|
{
|
||||||
|
Initialized();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void AddDump(TraceOutput& out)
|
||||||
|
{
|
||||||
|
out.Print("page write: %p, cache: %p", fPage, fCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
VMCache* fCache;
|
||||||
|
vm_page* fPage;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace PageWriterTracing
|
||||||
|
|
||||||
|
# define TPW(x) new(std::nothrow) PageWriterTracing::x
|
||||||
|
|
||||||
|
#else
|
||||||
|
# define TPW(x)
|
||||||
|
#endif // PAGE_WRITER_TRACING
|
||||||
|
|
||||||
|
|
||||||
/*! Dequeues a page from the head of the given queue */
|
/*! Dequeues a page from the head of the given queue */
|
||||||
static vm_page *
|
static vm_page *
|
||||||
dequeue_page(page_queue *queue)
|
dequeue_page(page_queue *queue)
|
||||||
@@ -1222,6 +1255,8 @@ page_writer(void* /*unused*/)
|
|||||||
locker.Unlock();
|
locker.Unlock();
|
||||||
|
|
||||||
//dprintf("write page %p, cache %p (%ld)\n", page, page->cache, page->cache->ref_count);
|
//dprintf("write page %p, cache %p (%ld)\n", page, page->cache, page->cache->ref_count);
|
||||||
|
TPW(WritePage(page));
|
||||||
|
|
||||||
vm_clear_map_flags(page, PAGE_MODIFIED);
|
vm_clear_map_flags(page, PAGE_MODIFIED);
|
||||||
cache->AcquireRefLocked();
|
cache->AcquireRefLocked();
|
||||||
numPages++;
|
numPages++;
|
||||||
|
|||||||
Reference in New Issue
Block a user