Added kernel tracing for the swap support.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27178 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-08-23 14:54:28 +00:00
parent fe34b1990b
commit fa2fa606af
2 changed files with 82 additions and 0 deletions
+1
View File
@@ -34,6 +34,7 @@
#define RUNTIME_LOADER_TRACING 0
#define SCHEDULER_TRACING 0
#define SIGNAL_TRACING 0
#define SWAP_TRACING 0
#define SYSCALL_TRACING 0
#define SYSCALL_TRACING_IGNORE_KTRACE_OUTPUT 1
#define TCP_TRACING 0
+81
View File
@@ -26,6 +26,7 @@
#include <kernel_daemon.h>
#include <slab/Slab.h>
#include <syscalls.h>
#include <tracing.h>
#include <util/AutoLock.h>
#include <util/DoublyLinkedList.h>
#include <util/OpenHashTable.h>
@@ -147,6 +148,78 @@ static mutex sAvailSwapSpaceLock;
static object_cache *sSwapBlockCache;
#if SWAP_TRACING
namespace SwapTracing {
class SwapTraceEntry : public AbstractTraceEntry {
public:
SwapTraceEntry(VMAnonymousCache* cache)
:
fCache(cache)
{
}
protected:
VMAnonymousCache* fCache;
};
class ReadPage : public SwapTraceEntry {
public:
ReadPage(VMAnonymousCache* cache, page_num_t pageIndex,
swap_addr_t swapSlotIndex)
:
SwapTraceEntry(cache),
fPageIndex(pageIndex),
fSwapSlotIndex(swapSlotIndex)
{
Initialized();
}
virtual void AddDump(TraceOutput& out)
{
out.Print("swap read: cache %p, page index: %lu <- swap slot: %lu",
fCache, fPageIndex, fSwapSlotIndex);
}
private:
page_num_t fPageIndex;
swap_addr_t fSwapSlotIndex;
};
class WritePage : public SwapTraceEntry {
public:
WritePage(VMAnonymousCache* cache, page_num_t pageIndex,
swap_addr_t swapSlotIndex)
:
SwapTraceEntry(cache),
fPageIndex(pageIndex),
fSwapSlotIndex(swapSlotIndex)
{
Initialized();
}
virtual void AddDump(TraceOutput& out)
{
out.Print("swap write: cache %p, page index: %lu -> swap slot: %lu",
fCache, fPageIndex, fSwapSlotIndex);
}
private:
page_num_t fPageIndex;
swap_addr_t fSwapSlotIndex;
};
} // namespace SwapTracing
# define T(x) new(std::nothrow) SwapTracing::x;
#else
# define T(x) ;
#endif
static int
dump_swap_info(int argc, char** argv)
{
@@ -488,6 +561,9 @@ VMAnonymousCache::Read(off_t offset, const iovec *vecs, size_t count,
break;
}
T(ReadPage(this, pageIndex, startSlotIndex));
// TODO: Assumes that only one page is read.
swap_file *swapFile = find_swap_file(startSlotIndex);
off_t pos = (startSlotIndex - swapFile->first_slot) * B_PAGE_SIZE;
@@ -534,6 +610,9 @@ VMAnonymousCache::Write(off_t offset, const iovec *vecs, size_t count,
if (slotIndex == SWAP_SLOT_NONE)
panic("VMAnonymousCache::Write(): can't allocate swap space\n");
T(WritePage(this, pageIndex, slotIndex));
// TODO: Assumes that only one page is written.
swap_file *swapFile = find_swap_file(slotIndex);
off_t pos = (slotIndex - swapFile->first_slot) * B_PAGE_SIZE;
@@ -603,6 +682,8 @@ VMAnonymousCache::WriteAsync(off_t offset, const iovec* vecs, size_t count,
callback->SetTo(pageIndex, slotIndex, newSlot);
T(WritePage(this, pageIndex, slotIndex));
// write the page asynchrounously
swap_file* swapFile = find_swap_file(slotIndex);
off_t pos = (slotIndex - swapFile->first_slot) * B_PAGE_SIZE;