diff options
author | behlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c> | 2008-03-14 20:56:26 +0000 |
---|---|---|
committer | behlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c> | 2008-03-14 20:56:26 +0000 |
commit | c19c06f3b05a220cb638050c0e06578a09ad64ad (patch) | |
tree | 1e5b3f9fc76225a6b87672239de8f93fe9639d6b /include | |
parent | 79b31f3601af530f64b3f2ae87233b3fa5271df1 (diff) |
Fix kmem memory accounting
Adjust kmem slab interface to make a copy of the slab name before
passing it on to the linux slab (we free it latter too)
git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@47 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
Diffstat (limited to 'include')
-rw-r--r-- | include/sys/kmem.h | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/include/sys/kmem.h b/include/sys/kmem.h index 2560b380a..cce2a05e7 100644 --- a/include/sys/kmem.h +++ b/include/sys/kmem.h @@ -24,30 +24,32 @@ extern "C" { #define KM_FLAGS __GFP_BITS_MASK #ifdef DEBUG_KMEM -extern atomic_t kmem_alloc_used; -extern unsigned int kmem_alloc_max; -extern atomic_t vmem_alloc_used; -extern unsigned int vmem_alloc_max; +extern atomic64_t kmem_alloc_used; +extern unsigned long kmem_alloc_max; +extern atomic64_t vmem_alloc_used; +extern unsigned long vmem_alloc_max; +extern int kmem_warning_flag; #define __kmem_alloc(size, flags, allocator) \ ({ void *_ptr_; \ \ /* Marked unlikely because we should never be doing this */ \ - if (unlikely((size) > (PAGE_SIZE * 2))) \ + if (unlikely((size) > (PAGE_SIZE * 2)) && kmem_warning_flag) \ printk("Warning: kmem_alloc(%d, 0x%x) large alloc at %s:%d " \ - "(%d/%d)\n", (int)(size), (int)(flags), \ + "(%ld/%ld)\n", (int)(size), (int)(flags), \ __FILE__, __LINE__, \ - atomic_read(&kmem_alloc_used), kmem_alloc_max); \ + atomic64_read(&kmem_alloc_used), kmem_alloc_max); \ \ _ptr_ = (void *)allocator((size), (flags)); \ if (_ptr_ == NULL) { \ printk("Warning: kmem_alloc(%d, 0x%x) failed at %s:%d " \ - "(%d/%d)\n", (int)(size), (int)(flags), \ + "(%ld/%ld)\n", (int)(size), (int)(flags), \ __FILE__, __LINE__, \ - atomic_read(&kmem_alloc_used), kmem_alloc_max); \ - atomic_add((size), &kmem_alloc_used); \ - if (unlikely(atomic_read(&kmem_alloc_used) > kmem_alloc_max)) \ - kmem_alloc_max = atomic_read(&kmem_alloc_used); \ + atomic64_read(&kmem_alloc_used), kmem_alloc_max); \ + } else { \ + atomic64_add((size), &kmem_alloc_used); \ + if (unlikely(atomic64_read(&kmem_alloc_used)>kmem_alloc_max)) \ + kmem_alloc_max = atomic64_read(&kmem_alloc_used); \ } \ \ _ptr_; \ @@ -59,7 +61,7 @@ extern unsigned int vmem_alloc_max; #define kmem_free(ptr, size) \ ({ \ BUG_ON(!(ptr) || (size) < 0); \ - atomic_sub((size), &kmem_alloc_used); \ + atomic64_sub((size), &kmem_alloc_used); \ memset(ptr, 0x5a, (size)); /* Poison */ \ kfree(ptr); \ }) @@ -72,12 +74,13 @@ extern unsigned int vmem_alloc_max; _ptr_ = (void *)vmalloc((size)); \ if (_ptr_ == NULL) { \ printk("Warning: vmem_alloc(%d, 0x%x) failed at %s:%d " \ - "(%d/%d)\n", (int)(size), (int)(flags), \ + "(%ld/%ld)\n", (int)(size), (int)(flags), \ __FILE__, __LINE__, \ - atomic_read(&vmem_alloc_used), vmem_alloc_max); \ - atomic_add((size), &vmem_alloc_used); \ - if (unlikely(atomic_read(&vmem_alloc_used) > vmem_alloc_max)) \ - vmem_alloc_max = atomic_read(&vmem_alloc_used); \ + atomic64_read(&vmem_alloc_used), vmem_alloc_max); \ + } else { \ + atomic64_add((size), &vmem_alloc_used); \ + if (unlikely(atomic64_read(&vmem_alloc_used)>vmem_alloc_max)) \ + vmem_alloc_max = atomic64_read(&vmem_alloc_used); \ } \ \ _ptr_; \ @@ -88,7 +91,7 @@ extern unsigned int vmem_alloc_max; #define vmem_free(ptr, size) \ ({ \ BUG_ON(!(ptr) || (size) < 0); \ - atomic_sub((size), &vmem_alloc_used); \ + atomic64_sub((size), &vmem_alloc_used); \ memset(ptr, 0x5a, (size)); /* Poison */ \ vfree(ptr); \ }) @@ -186,6 +189,8 @@ typedef int (*kmem_constructor_t)(void *, void *, int); typedef void (*kmem_destructor_t)(void *, void *); typedef void (*kmem_reclaim_t)(void *); +extern int kmem_set_warning(int flag); + extern kmem_cache_t * __kmem_cache_create(char *name, size_t size, size_t align, kmem_constructor_t constructor, |