summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2006-10-17 19:52:34 +0200
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2006-10-17 19:52:34 +0200
commitf22f89e6b3c970a29197d3a53c170fb7d0340cbe (patch)
treee36c1e56ae728a57c2af09025a82786d944b6006
parentd515936ea7f98f6aaa9217699796beadef9d664b (diff)
Add vma list memory usage to memory accounting.
Use byte unit for /proc printout of memory usage for small sizes to be able to detect memory allocation bugs more easily.
-rw-r--r--linux-core/drmP.h1
-rw-r--r--linux-core/drm_drv.c12
-rw-r--r--linux-core/drm_proc.c9
-rw-r--r--linux-core/drm_stub.c3
-rw-r--r--linux-core/drm_vm.c6
5 files changed, 12 insertions, 19 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index e59322d0..b10e9881 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -763,7 +763,6 @@ typedef struct drm_cache {
kmem_cache_t *mm;
kmem_cache_t *fence_object;
- kmem_cache_t *ref_object;
} drm_cache_t;
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index e1ee35c1..75c89c1c 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -228,7 +228,7 @@ int drm_lastclose(drm_device_t * dev)
if (dev->vmalist) {
for (vma = dev->vmalist; vma; vma = vma_next) {
vma_next = vma->next;
- drm_free(vma, sizeof(*vma), DRM_MEM_VMAS);
+ drm_ctl_free(vma, sizeof(*vma), DRM_MEM_VMAS);
}
dev->vmalist = NULL;
}
@@ -464,14 +464,6 @@ static int drm_create_memory_caches(void)
if (!drm_cache.fence_object)
return -ENOMEM;
- drm_cache.ref_object= kmem_cache_create("drm_ref_object_t",
- sizeof(drm_ref_object_t),
- 0,
- SLAB_HWCACHE_ALIGN,
- NULL,NULL);
- if (!drm_cache.ref_object)
- return -ENOMEM;
-
return 0;
}
@@ -489,8 +481,6 @@ static void drm_free_mem_cache(kmem_cache_t *cache,
static void drm_free_memory_caches(void )
{
- drm_free_mem_cache(drm_cache.ref_object, "ref object");
- drm_cache.ref_object = NULL;
drm_free_mem_cache(drm_cache.fence_object, "fence object");
drm_cache.fence_object = NULL;
drm_free_mem_cache(drm_cache.mm, "memory manager block");
diff --git a/linux-core/drm_proc.c b/linux-core/drm_proc.c
index 4bb71ca7..863cacfc 100644
--- a/linux-core/drm_proc.c
+++ b/linux-core/drm_proc.c
@@ -469,8 +469,13 @@ static int drm__objects_info(char *buf, char **start, off_t offset, int request,
drm_query_memctl(&used_mem, &low_mem, &high_mem);
- DRM_PROC_PRINT("Used object memory is %lu pages.\n",
- (unsigned long) (used_mem >> PAGE_SHIFT));
+ if (used_mem > 16*PAGE_SIZE) {
+ DRM_PROC_PRINT("Used object memory is %lu pages.\n",
+ (unsigned long) (used_mem >> PAGE_SHIFT));
+ } else {
+ DRM_PROC_PRINT("Used object memory is %lu bytes.\n",
+ (unsigned long) used_mem);
+ }
DRM_PROC_PRINT("Soft object memory usage threshold is %lu pages.\n",
(unsigned long) (low_mem >> PAGE_SHIFT));
DRM_PROC_PRINT("Hard object memory usage threshold is %lu pages.\n",
diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c
index 66310560..8413fb4f 100644
--- a/linux-core/drm_stub.c
+++ b/linux-core/drm_stub.c
@@ -56,8 +56,7 @@ struct proc_dir_entry *drm_proc_root;
drm_cache_t drm_cache =
{ .mm = NULL,
- .fence_object = NULL,
- .ref_object = NULL
+ .fence_object = NULL
};
static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c
index 1654236d..aa112751 100644
--- a/linux-core/drm_vm.c
+++ b/linux-core/drm_vm.c
@@ -315,7 +315,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
} else {
dev->vmalist = pt->next;
}
- drm_free(pt, sizeof(*pt), DRM_MEM_VMAS);
+ drm_ctl_free(pt, sizeof(*pt), DRM_MEM_VMAS);
} else {
prev = pt;
}
@@ -567,7 +567,7 @@ static void drm_vm_open(struct vm_area_struct *vma)
vma->vm_start, vma->vm_end - vma->vm_start);
atomic_inc(&dev->vma_count);
- vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
+ vma_entry = drm_ctl_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
if (vma_entry) {
mutex_lock(&dev->struct_mutex);
vma_entry->vma = vma;
@@ -627,7 +627,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
} else {
dev->vmalist = pt->next;
}
- drm_free(pt, sizeof(*pt), DRM_MEM_VMAS);
+ drm_ctl_free(pt, sizeof(*pt), DRM_MEM_VMAS);
break;
}
}