* Moved more debug macros to kernel_debug_config.h.

* Turned the checks for all those macros to "#if"s instead of "#ifdef"s.
* Introduced macro KDEBUG_LEVEL which serves as a master setting.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28248 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-10-20 14:24:46 +00:00
parent 1894a0a98b
commit 59dbd26f5f
13 changed files with 116 additions and 67 deletions
+59 -8
View File
@@ -1,39 +1,90 @@
#ifndef KERNEL_DEBUG_CONFIG_H #ifndef KERNEL_DEBUG_CONFIG_H
#define KERNEL_DEBUG_CONFIG_H #define KERNEL_DEBUG_CONFIG_H
// Master switch:
// 0: Disables all debug code that hasn't been enabled otherwise.
// 1: Enables some lightweight debug code.
// 2: Enables more debug code. Will impact performance.
#define KDEBUG_LEVEL 2
#define KDEBUG_LEVEL_2 (KDEBUG_LEVEL >= 2)
#define KDEBUG_LEVEL_1 (KDEBUG_LEVEL >= 1)
#define KDEBUG_LEVEL_0 (KDEBUG_LEVEL >= 0)
// general kernel debugging // general kernel debugging
// Enables kernel ASSERT()s and various checks, locking primitives aren't // Enables kernel ASSERT()s and various checks, locking primitives aren't
// benaphore-style. // benaphore-style.
#define KDEBUG 1 #define KDEBUG KDEBUG_LEVEL_2
// Enable this to get support for kernel breakpoints. // Enable this to get support for kernel breakpoints.
//#define KERNEL_BREAKPOINTS 1 #define KERNEL_BREAKPOINTS 0
// block cache // block/file cache
// Enables debugger commands. // Enables debugger commands.
#define DEBUG_BLOCK_CACHE #define DEBUG_BLOCK_CACHE KDEBUG_LEVEL_1
// Enables checks that non-dirty blocks really aren't changed. Seriously // Enables checks that non-dirty blocks really aren't changed. Seriously
// degrades performance when the block cache is used heavily. // degrades performance when the block cache is used heavily.
#define BLOCK_CACHE_DEBUG_CHANGED #define BLOCK_CACHE_DEBUG_CHANGED KDEBUG_LEVEL_2
// Enables a global list of file maps and related debugger commands.
#define DEBUG_FILE_MAP KDEBUG_LEVEL_1
// heap
// Initialize newly allocated memory with something non zero.
#define PARANOID_KERNEL_MALLOC KDEBUG_LEVEL_2
// Check for double free, and fill freed memory with 0xdeadbeef.
#define PARANOID_KERNEL_FREE KDEBUG_LEVEL_2
// Validate sanity of the heap after each operation (slow!).
#define PARANOID_HEAP_VALIDATION 0
// Store size, thread and team info at the end of each allocation block.
// Enables the "allocations*" debugger commands.
#define KERNEL_HEAP_LEAK_CHECK 0
// interrupts
// Adds statistics and unhandled counter per interrupts. Enables the "ints"
// debugger command.
#define DEBUG_INTERRUPTS KDEBUG_LEVEL_1
// semaphores
// Enables tracking of the last threads that acquired/released a semaphore.
#define DEBUG_SEM_LAST_ACQUIRER KDEBUG_LEVEL_1
// SMP
// Enables spinlock caller debugging. When acquiring a spinlock twice on a
// non-SMP machine, this will give a clue who locked it the first time.
// Furthermore (also on SMP machines) the "spinlock" debugger command will be
// available.
#define DEBUG_SPINLOCKS KDEBUG_LEVEL_2
// VM // VM
// Enables the vm_page::queue, i.e. it is tracked which queue the page should // Enables the vm_page::queue, i.e. it is tracked which queue the page should
// be in. // be in.
//#define DEBUG_PAGE_QUEUE 1 #define DEBUG_PAGE_QUEUE 0
// Enables extra debug fields in the vm_page used to track page transitions // Enables extra debug fields in the vm_page used to track page transitions
// between caches. // between caches.
//#define DEBUG_PAGE_CACHE_TRANSITIONS 1 #define DEBUG_PAGE_CACHE_TRANSITIONS 0
// Enables a global list of all vm_cache structures. // Enables a global list of all vm_cache structures.
//#define DEBUG_CACHE_LIST 1 #define DEBUG_CACHE_LIST KDEBUG_LEVEL_1
// Enables swap support. // Enables swap support.
#define ENABLE_SWAP_SUPPORT 1 #define ENABLE_SWAP_SUPPORT 1
+3 -3
View File
@@ -10,6 +10,9 @@
#include <OS.h> #include <OS.h>
#include "kernel_debug_config.h"
// allocate 16MB initial heap for the kernel // allocate 16MB initial heap for the kernel
#define INITIAL_HEAP_SIZE 16 * 1024 * 1024 #define INITIAL_HEAP_SIZE 16 * 1024 * 1024
// grow by another 4MB each time the heap runs out of memory // grow by another 4MB each time the heap runs out of memory
@@ -19,9 +22,6 @@
// use areas for allocations bigger than 1MB // use areas for allocations bigger than 1MB
#define HEAP_AREA_USE_THRESHOLD 1 * 1024 * 1024 #define HEAP_AREA_USE_THRESHOLD 1 * 1024 * 1024
// store size, thread and team info at the end of each allocation block
#define KERNEL_HEAP_LEAK_CHECK 0
typedef struct heap_class_s { typedef struct heap_class_s {
const char *name; const char *name;
+2 -2
View File
@@ -83,11 +83,11 @@ struct vm_page {
vm_page_mappings mappings; vm_page_mappings mappings;
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
void* queue; void* queue;
#endif #endif
#ifdef DEBUG_PAGE_CACHE_TRANSITIONS #if DEBUG_PAGE_CACHE_TRANSITIONS
uint32 debug_flags; uint32 debug_flags;
struct vm_page *collided_page; struct vm_page *collided_page;
#endif #endif
+7 -7
View File
@@ -65,7 +65,7 @@ struct cached_block {
void *current_data; void *current_data;
void *original_data; void *original_data;
void *parent_data; void *parent_data;
#ifdef BLOCK_CACHE_DEBUG_CHANGED #if BLOCK_CACHE_DEBUG_CHANGED
void *compare; void *compare;
#endif #endif
int32 ref_count; int32 ref_count;
@@ -837,7 +837,7 @@ block_cache::FreeBlock(cached_block *block)
block->block_number, block->original_data, block->parent_data); block->block_number, block->original_data, block->parent_data);
} }
#ifdef BLOCK_CACHE_DEBUG_CHANGED #if BLOCK_CACHE_DEBUG_CHANGED
Free(block->compare); Free(block->compare);
#endif #endif
@@ -909,7 +909,7 @@ block_cache::NewBlock(off_t blockNumber)
block->parent_data = NULL; block->parent_data = NULL;
block->is_dirty = false; block->is_dirty = false;
block->unused = false; block->unused = false;
#ifdef BLOCK_CACHE_DEBUG_CHANGED #if BLOCK_CACHE_DEBUG_CHANGED
block->compare = NULL; block->compare = NULL;
#endif #endif
@@ -1000,7 +1000,7 @@ block_cache::LowMemoryHandler(void *data, uint32 resources, int32 level)
static void static void
put_cached_block(block_cache *cache, cached_block *block) put_cached_block(block_cache *cache, cached_block *block)
{ {
#ifdef BLOCK_CACHE_DEBUG_CHANGED #if BLOCK_CACHE_DEBUG_CHANGED
if (!block->is_dirty && block->compare != NULL if (!block->is_dirty && block->compare != NULL
&& memcmp(block->current_data, block->compare, cache->block_size)) { && memcmp(block->current_data, block->compare, cache->block_size)) {
dprintf("new block:\n"); dprintf("new block:\n");
@@ -1321,7 +1321,7 @@ write_cached_block(block_cache *cache, cached_block *block,
} }
#ifdef DEBUG_BLOCK_CACHE #if DEBUG_BLOCK_CACHE
static void static void
dump_block(cached_block *block) dump_block(cached_block *block)
@@ -1752,7 +1752,7 @@ block_cache_init(void)
if (sNotifierWriterThread >= B_OK) if (sNotifierWriterThread >= B_OK)
send_signal_etc(sNotifierWriterThread, SIGCONT, B_DO_NOT_RESCHEDULE); send_signal_etc(sNotifierWriterThread, SIGCONT, B_DO_NOT_RESCHEDULE);
#ifdef DEBUG_BLOCK_CACHE #if DEBUG_BLOCK_CACHE
add_debugger_command_etc("block_caches", &dump_caches, add_debugger_command_etc("block_caches", &dump_caches,
"dumps all block caches", "\n", 0); "dumps all block caches", "\n", 0);
add_debugger_command_etc("block_cache", &dump_cache, add_debugger_command_etc("block_cache", &dump_cache,
@@ -2519,7 +2519,7 @@ block_cache_get_etc(void *_cache, off_t blockNumber, off_t base, off_t length)
if (block == NULL) if (block == NULL)
return NULL; return NULL;
#ifdef BLOCK_CACHE_DEBUG_CHANGED #if BLOCK_CACHE_DEBUG_CHANGED
if (block->compare == NULL) if (block->compare == NULL)
block->compare = cache->Allocate(); block->compare = cache->Allocate();
if (block->compare != NULL) if (block->compare != NULL)
+8 -7
View File
@@ -21,6 +21,8 @@
#include <vm_page.h> #include <vm_page.h>
#include <vm_cache.h> #include <vm_cache.h>
#include "kernel_debug_config.h"
//#define TRACE_FILE_MAP //#define TRACE_FILE_MAP
#ifdef TRACE_FILE_MAP #ifdef TRACE_FILE_MAP
@@ -34,7 +36,6 @@
// for the whole map. // for the whole map.
// TODO: it would be nice if we could free a file map in low memory situations. // TODO: it would be nice if we could free a file map in low memory situations.
#define DEBUG_FILE_MAP
#define CACHED_FILE_EXTENTS 2 #define CACHED_FILE_EXTENTS 2
// must be smaller than MAX_FILE_IO_VECS // must be smaller than MAX_FILE_IO_VECS
@@ -51,7 +52,7 @@ struct file_extent_array {
}; };
class FileMap class FileMap
#ifdef DEBUG_FILE_MAP #if DEBUG_FILE_MAP
: public DoublyLinkedListLinkImpl<FileMap> : public DoublyLinkedListLinkImpl<FileMap>
#endif #endif
{ {
@@ -94,7 +95,7 @@ private:
bool fCacheAll; bool fCacheAll;
}; };
#ifdef DEBUG_FILE_MAP #if DEBUG_FILE_MAP
typedef DoublyLinkedList<FileMap> FileMapList; typedef DoublyLinkedList<FileMap> FileMapList;
static FileMapList sList; static FileMapList sList;
@@ -111,7 +112,7 @@ FileMap::FileMap(struct vnode* vnode, off_t size)
{ {
mutex_init(&fLock, "file map"); mutex_init(&fLock, "file map");
#ifdef DEBUG_FILE_MAP #if DEBUG_FILE_MAP
MutexLocker _(sLock); MutexLocker _(sLock);
sList.Add(this); sList.Add(this);
#endif #endif
@@ -123,7 +124,7 @@ FileMap::~FileMap()
_Free(); _Free();
mutex_destroy(&fLock); mutex_destroy(&fLock);
#ifdef DEBUG_FILE_MAP #if DEBUG_FILE_MAP
MutexLocker _(sLock); MutexLocker _(sLock);
sList.Remove(this); sList.Remove(this);
#endif #endif
@@ -459,7 +460,7 @@ FileMap::Translate(off_t offset, size_t size, file_io_vec* vecs, size_t* _count,
// #pragma mark - // #pragma mark -
#ifdef DEBUG_FILE_MAP #if DEBUG_FILE_MAP
static int static int
dump_file_map(int argc, char** argv) dump_file_map(int argc, char** argv)
@@ -553,7 +554,7 @@ dump_file_map_stats(int argc, char** argv)
extern "C" status_t extern "C" status_t
file_map_init(void) file_map_init(void)
{ {
#ifdef DEBUG_FILE_MAP #if DEBUG_FILE_MAP
add_debugger_command_etc("file_map", &dump_file_map, add_debugger_command_etc("file_map", &dump_file_map,
"Dumps the specified file map.", "Dumps the specified file map.",
"[-p] <file-map>\n" "[-p] <file-map>\n"
+1 -6
View File
@@ -25,6 +25,7 @@
#include <util/DoublyLinkedList.h> #include <util/DoublyLinkedList.h>
#include <vm.h> #include <vm.h>
//#define TRACE_HEAP //#define TRACE_HEAP
#ifdef TRACE_HEAP #ifdef TRACE_HEAP
# define TRACE(x) dprintf x # define TRACE(x) dprintf x
@@ -32,12 +33,6 @@
# define TRACE(x) ; # define TRACE(x) ;
#endif #endif
// initialize newly allocated memory with something non zero
#define PARANOID_KERNEL_MALLOC 1
// check for double free, and fill freed memory with 0xdeadbeef
#define PARANOID_KERNEL_FREE 1
// validate sanity of the heap after each operation (slow!)
#define PARANOID_HEAP_VALIDATION 0
#if KERNEL_HEAP_LEAK_CHECK #if KERNEL_HEAP_LEAK_CHECK
typedef struct heap_leak_check_info_s { typedef struct heap_leak_check_info_s {
+7 -7
View File
@@ -20,6 +20,8 @@
#include <util/kqueue.h> #include <util/kqueue.h>
#include <smp.h> #include <smp.h>
#include "kernel_debug_config.h"
//#define TRACE_INT //#define TRACE_INT
#ifdef TRACE_INT #ifdef TRACE_INT
@@ -28,8 +30,6 @@
# define TRACE(x) ; # define TRACE(x) ;
#endif #endif
#define DEBUG_INT
// adds statistics and unhandled counter
struct io_handler { struct io_handler {
struct io_handler *next; struct io_handler *next;
@@ -44,7 +44,7 @@ struct io_vector {
spinlock vector_lock; spinlock vector_lock;
int32 enable_count; int32 enable_count;
bool no_lock_vector; bool no_lock_vector;
#ifdef DEBUG_INT #if DEBUG_INTERRUPTS
int64 handled_count; int64 handled_count;
int64 unhandled_count; int64 unhandled_count;
int trigger_count; int trigger_count;
@@ -55,7 +55,7 @@ struct io_vector {
static struct io_vector sVectors[NUM_IO_VECTORS]; static struct io_vector sVectors[NUM_IO_VECTORS];
#ifdef DEBUG_INT #if DEBUG_INTERRUPTS
static int static int
dump_int_statistics(int argc, char **argv) dump_int_statistics(int argc, char **argv)
{ {
@@ -128,7 +128,7 @@ int_init_post_vm(kernel_args *args)
B_INITIALIZE_SPINLOCK(&sVectors[i].vector_lock); B_INITIALIZE_SPINLOCK(&sVectors[i].vector_lock);
sVectors[i].enable_count = 0; sVectors[i].enable_count = 0;
sVectors[i].no_lock_vector = false; sVectors[i].no_lock_vector = false;
#ifdef DEBUG_INT #if DEBUG_INTERRUPTS
sVectors[i].handled_count = 0; sVectors[i].handled_count = 0;
sVectors[i].unhandled_count = 0; sVectors[i].unhandled_count = 0;
sVectors[i].trigger_count = 0; sVectors[i].trigger_count = 0;
@@ -137,7 +137,7 @@ int_init_post_vm(kernel_args *args)
initque(&sVectors[i].handler_list); /* initialize handler queue */ initque(&sVectors[i].handler_list); /* initialize handler queue */
} }
#ifdef DEBUG_INT #if DEBUG_INTERRUPTS
add_debugger_command("ints", &dump_int_statistics, add_debugger_command("ints", &dump_int_statistics,
"list interrupt statistics"); "list interrupt statistics");
#endif #endif
@@ -199,7 +199,7 @@ int_io_interrupt_handler(int vector, bool levelTriggered)
invokeScheduler = true; invokeScheduler = true;
} }
#ifdef DEBUG_INT #if DEBUG_INTERRUPTS
sVectors[vector].trigger_count++; sVectors[vector].trigger_count++;
if (status != B_UNHANDLED_INTERRUPT || handled || invokeScheduler) { if (status != B_UNHANDLED_INTERRUPT || handled || invokeScheduler) {
sVectors[vector].handled_count++; sVectors[vector].handled_count++;
+7 -6
View File
@@ -34,6 +34,8 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "kernel_debug_config.h"
//#define TRACE_SEM //#define TRACE_SEM
#ifdef TRACE_SEM #ifdef TRACE_SEM
@@ -49,7 +51,6 @@
# define KTRACE(x...) do {} while (false) # define KTRACE(x...) do {} while (false)
#endif #endif
#define DEBUG_LAST_ACQUIRER
struct queued_thread : DoublyLinkedListLinkImpl<queued_thread> { struct queued_thread : DoublyLinkedListLinkImpl<queued_thread> {
queued_thread(struct thread *thread, int32 count) queued_thread(struct thread *thread, int32 count)
@@ -81,7 +82,7 @@ struct sem_entry {
team_id owner; // if set to -1, means owned by a port team_id owner; // if set to -1, means owned by a port
select_info *select_infos; select_info *select_infos;
thread_id last_acquirer; thread_id last_acquirer;
#ifdef DEBUG_LAST_ACQUIRER #if DEBUG_SEM_LAST_ACQUIRER
int32 last_acquire_count; int32 last_acquire_count;
thread_id last_releaser; thread_id last_releaser;
int32 last_release_count; int32 last_release_count;
@@ -177,7 +178,7 @@ dump_sem(struct sem_entry *sem)
set_debug_variable("_semID", sem->id); set_debug_variable("_semID", sem->id);
set_debug_variable("_owner", sem->u.used.owner); set_debug_variable("_owner", sem->u.used.owner);
#ifdef DEBUG_LAST_ACQUIRER #if DEBUG_SEM_LAST_ACQUIRER
kprintf("last acquired by: %ld, count: %ld\n", sem->u.used.last_acquirer, kprintf("last acquired by: %ld, count: %ld\n", sem->u.used.last_acquirer,
sem->u.used.last_acquire_count); sem->u.used.last_acquire_count);
kprintf("last released by: %ld, count: %ld\n", sem->u.used.last_releaser, kprintf("last released by: %ld, count: %ld\n", sem->u.used.last_releaser,
@@ -817,7 +818,7 @@ switch_sem_etc(sem_id semToBeReleased, sem_id id, int32 count,
if (acquireStatus >= B_OK) { if (acquireStatus >= B_OK) {
sSems[slot].u.used.last_acquirer = thread_get_current_thread_id(); sSems[slot].u.used.last_acquirer = thread_get_current_thread_id();
#ifdef DEBUG_LAST_ACQUIRER #if DEBUG_SEM_LAST_ACQUIRER
sSems[slot].u.used.last_acquire_count = count; sSems[slot].u.used.last_acquire_count = count;
#endif #endif
} }
@@ -833,7 +834,7 @@ switch_sem_etc(sem_id semToBeReleased, sem_id id, int32 count,
} else { } else {
sSems[slot].u.used.net_count -= count; sSems[slot].u.used.net_count -= count;
sSems[slot].u.used.last_acquirer = thread_get_current_thread_id(); sSems[slot].u.used.last_acquirer = thread_get_current_thread_id();
#ifdef DEBUG_LAST_ACQUIRER #if DEBUG_SEM_LAST_ACQUIRER
sSems[slot].u.used.last_acquire_count = count; sSems[slot].u.used.last_acquire_count = count;
#endif #endif
} }
@@ -902,7 +903,7 @@ release_sem_etc(sem_id id, int32 count, uint32 flags)
flags); flags);
sSems[slot].u.used.last_acquirer = -sSems[slot].u.used.last_acquirer; sSems[slot].u.used.last_acquirer = -sSems[slot].u.used.last_acquirer;
#ifdef DEBUG_LAST_ACQUIRER #if DEBUG_SEM_LAST_ACQUIRER
sSems[slot].u.used.last_releaser = thread_get_current_thread_id(); sSems[slot].u.used.last_releaser = thread_get_current_thread_id();
sSems[slot].u.used.last_release_count = count; sSems[slot].u.used.last_release_count = count;
#endif #endif
+2 -1
View File
@@ -24,8 +24,9 @@
#include <spinlock_contention.h> #include <spinlock_contention.h>
#include <thread.h> #include <thread.h>
#include "kernel_debug_config.h"
#define DEBUG_SPINLOCKS 1
//#define TRACE_SMP //#define TRACE_SMP
#ifdef TRACE_SMP #ifdef TRACE_SMP
+1 -1
View File
@@ -735,7 +735,7 @@ VMAnonymousCache::Merge(VMCache* _source)
!= SWAP_SLOT_NONE) { != SWAP_SLOT_NONE) {
page->merge_swap = true; page->merge_swap = true;
} }
#ifdef DEBUG_PAGE_CACHE_TRANSITIONS #if DEBUG_PAGE_CACHE_TRANSITIONS
} else { } else {
page->debug_flags = 0; page->debug_flags = 0;
if (consumerPage->state == PAGE_STATE_BUSY) if (consumerPage->state == PAGE_STATE_BUSY)
+3 -3
View File
@@ -4565,7 +4565,7 @@ fault_get_page(vm_translation_map *map, vm_cache *topCache, off_t cacheOffset,
// If we inserted a dummy page into this cache (i.e. if it is the top // If we inserted a dummy page into this cache (i.e. if it is the top
// cache), we have to remove it now // cache), we have to remove it now
if (dummyPage.state == PAGE_STATE_BUSY && dummyPage.cache == cache) { if (dummyPage.state == PAGE_STATE_BUSY && dummyPage.cache == cache) {
#ifdef DEBUG_PAGE_CACHE_TRANSITIONS #if DEBUG_PAGE_CACHE_TRANSITIONS
page->debug_flags = dummyPage.debug_flags | 0x8; page->debug_flags = dummyPage.debug_flags | 0x8;
if (dummyPage.collided_page != NULL) { if (dummyPage.collided_page != NULL) {
dummyPage.collided_page->collided_page = page; dummyPage.collided_page->collided_page = page;
@@ -4579,7 +4579,7 @@ fault_get_page(vm_translation_map *map, vm_cache *topCache, off_t cacheOffset,
cache->InsertPage(page, cacheOffset); cache->InsertPage(page, cacheOffset);
if (dummyPage.state == PAGE_STATE_BUSY) { if (dummyPage.state == PAGE_STATE_BUSY) {
#ifdef DEBUG_PAGE_CACHE_TRANSITIONS #if DEBUG_PAGE_CACHE_TRANSITIONS
page->debug_flags = dummyPage.debug_flags | 0x10; page->debug_flags = dummyPage.debug_flags | 0x10;
if (dummyPage.collided_page != NULL) { if (dummyPage.collided_page != NULL) {
dummyPage.collided_page->collided_page = page; dummyPage.collided_page->collided_page = page;
@@ -4756,7 +4756,7 @@ vm_soft_fault(vm_address_space *addressSpace, addr_t originalAddress,
dummyPage.state = PAGE_STATE_INACTIVE; dummyPage.state = PAGE_STATE_INACTIVE;
dummyPage.type = PAGE_TYPE_DUMMY; dummyPage.type = PAGE_TYPE_DUMMY;
dummyPage.wired_count = 0; dummyPage.wired_count = 0;
#ifdef DEBUG_PAGE_CACHE_TRANSITIONS #if DEBUG_PAGE_CACHE_TRANSITIONS
dummyPage.debug_flags = 0; dummyPage.debug_flags = 0;
dummyPage.collided_page = NULL; dummyPage.collided_page = NULL;
#endif // DEBUG_PAGE_CACHE_TRANSITIONS #endif // DEBUG_PAGE_CACHE_TRANSITIONS
+1 -1
View File
@@ -923,7 +923,7 @@ VMCache::Merge(VMCache* source)
// the page is not yet in the consumer cache - move it upwards // the page is not yet in the consumer cache - move it upwards
source->RemovePage(page); source->RemovePage(page);
InsertPage(page, (off_t)page->cache_offset << PAGE_SHIFT); InsertPage(page, (off_t)page->cache_offset << PAGE_SHIFT);
#ifdef DEBUG_PAGE_CACHE_TRANSITIONS #if DEBUG_PAGE_CACHE_TRANSITIONS
} else { } else {
page->debug_flags = 0; page->debug_flags = 0;
if (consumerPage->state == PAGE_STATE_BUSY) if (consumerPage->state == PAGE_STATE_BUSY)
+14 -14
View File
@@ -286,7 +286,7 @@ dequeue_page(page_queue *queue)
if (page->type != PAGE_TYPE_DUMMY) if (page->type != PAGE_TYPE_DUMMY)
queue->count--; queue->count--;
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
if (page->queue != queue) { if (page->queue != queue) {
panic("dequeue_page(queue: %p): page %p thinks it is in queue " panic("dequeue_page(queue: %p): page %p thinks it is in queue "
"%p", queue, page, page->queue); "%p", queue, page, page->queue);
@@ -304,7 +304,7 @@ dequeue_page(page_queue *queue)
static void static void
enqueue_page(page_queue *queue, vm_page *page) enqueue_page(page_queue *queue, vm_page *page)
{ {
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
if (page->queue != NULL) { if (page->queue != NULL) {
panic("enqueue_page(queue: %p, page: %p): page thinks it is " panic("enqueue_page(queue: %p, page: %p): page thinks it is "
"already in queue %p", queue, page, page->queue); "already in queue %p", queue, page, page->queue);
@@ -321,7 +321,7 @@ enqueue_page(page_queue *queue, vm_page *page)
if (page->type != PAGE_TYPE_DUMMY) if (page->type != PAGE_TYPE_DUMMY)
queue->count++; queue->count++;
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
page->queue = queue; page->queue = queue;
#endif #endif
} }
@@ -331,7 +331,7 @@ enqueue_page(page_queue *queue, vm_page *page)
static void static void
enqueue_page_to_head(page_queue *queue, vm_page *page) enqueue_page_to_head(page_queue *queue, vm_page *page)
{ {
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
if (page->queue != NULL) { if (page->queue != NULL) {
panic("enqueue_page_to_head(queue: %p, page: %p): page thinks it is " panic("enqueue_page_to_head(queue: %p, page: %p): page thinks it is "
"already in queue %p", queue, page, page->queue); "already in queue %p", queue, page, page->queue);
@@ -348,7 +348,7 @@ enqueue_page_to_head(page_queue *queue, vm_page *page)
if (page->type != PAGE_TYPE_DUMMY) if (page->type != PAGE_TYPE_DUMMY)
queue->count++; queue->count++;
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
page->queue = queue; page->queue = queue;
#endif #endif
} }
@@ -357,7 +357,7 @@ enqueue_page_to_head(page_queue *queue, vm_page *page)
static void static void
remove_page_from_queue(page_queue *queue, vm_page *page) remove_page_from_queue(page_queue *queue, vm_page *page)
{ {
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
if (page->queue != queue) { if (page->queue != queue) {
panic("remove_page_from_queue(queue: %p, page: %p): page thinks it " panic("remove_page_from_queue(queue: %p, page: %p): page thinks it "
"is in queue %p", queue, page, page->queue); "is in queue %p", queue, page, page->queue);
@@ -377,7 +377,7 @@ remove_page_from_queue(page_queue *queue, vm_page *page)
if (page->type != PAGE_TYPE_DUMMY) if (page->type != PAGE_TYPE_DUMMY)
queue->count--; queue->count--;
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
page->queue = NULL; page->queue = NULL;
#endif #endif
} }
@@ -400,7 +400,7 @@ move_page_to_queue(page_queue *fromQueue, page_queue *toQueue, vm_page *page)
static void static void
insert_page_after(page_queue *queue, vm_page *before, vm_page *page) insert_page_after(page_queue *queue, vm_page *before, vm_page *page)
{ {
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
if (page->queue != NULL) { if (page->queue != NULL) {
panic("enqueue_page(queue: %p, page: %p): page thinks it is " panic("enqueue_page(queue: %p, page: %p): page thinks it is "
"already in queue %p", queue, page, page->queue); "already in queue %p", queue, page, page->queue);
@@ -424,7 +424,7 @@ insert_page_after(page_queue *queue, vm_page *before, vm_page *page)
if (page->type != PAGE_TYPE_DUMMY) if (page->type != PAGE_TYPE_DUMMY)
queue->count++; queue->count++;
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
page->queue = queue; page->queue = queue;
#endif #endif
} }
@@ -558,10 +558,10 @@ dump_page(int argc, char **argv)
kprintf("wired_count: %d\n", page->wired_count); kprintf("wired_count: %d\n", page->wired_count);
kprintf("usage_count: %d\n", page->usage_count); kprintf("usage_count: %d\n", page->usage_count);
kprintf("busy_writing: %d\n", page->busy_writing); kprintf("busy_writing: %d\n", page->busy_writing);
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
kprintf("queue: %p\n", page->queue); kprintf("queue: %p\n", page->queue);
#endif #endif
#ifdef DEBUG_PAGE_CACHE_TRANSITIONS #if DEBUG_PAGE_CACHE_TRANSITIONS
kprintf("debug_flags: 0x%lx\n", page->debug_flags); kprintf("debug_flags: 0x%lx\n", page->debug_flags);
kprintf("collided page: %p\n", page->collided_page); kprintf("collided page: %p\n", page->collided_page);
#endif // DEBUG_PAGE_CACHE_TRANSITIONS #endif // DEBUG_PAGE_CACHE_TRANSITIONS
@@ -1674,10 +1674,10 @@ vm_page_init(kernel_args *args)
sPages[i].busy_writing = false; sPages[i].busy_writing = false;
sPages[i].merge_swap = false; sPages[i].merge_swap = false;
sPages[i].cache = NULL; sPages[i].cache = NULL;
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
sPages[i].queue = NULL; sPages[i].queue = NULL;
#endif #endif
#ifdef DEBUG_PAGE_CACHE_TRANSITIONS #if DEBUG_PAGE_CACHE_TRANSITIONS
sPages[i].debug_flags = 0; sPages[i].debug_flags = 0;
sPages[i].collided_page = NULL; sPages[i].collided_page = NULL;
#endif // DEBUG_PAGE_CACHE_TRANSITIONS #endif // DEBUG_PAGE_CACHE_TRANSITIONS
@@ -1896,7 +1896,7 @@ vm_page_allocate_page(int pageState, bool reserved)
if (reserved || sReservedPages < free_page_queue_count()) { if (reserved || sReservedPages < free_page_queue_count()) {
page = dequeue_page(queue); page = dequeue_page(queue);
if (page == NULL) { if (page == NULL) {
#ifdef DEBUG_PAGE_QUEUE #if DEBUG_PAGE_QUEUE
if (queue->count != 0) if (queue->count != 0)
panic("queue %p corrupted, count = %d\n", queue, queue->count); panic("queue %p corrupted, count = %d\n", queue, queue->count);
#endif #endif