Add vma list memory usage to memory accounting.
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Tue, 17 Oct 2006 17:52:34 +0000 (19:52 +0200)
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Tue, 17 Oct 2006 17:52:34 +0000 (19:52 +0200)
Use byte unit for /proc printout of memory usage for small sizes to be
able to detect memory allocation bugs more easily.

linux-core/drmP.h
linux-core/drm_drv.c
linux-core/drm_proc.c
linux-core/drm_stub.c
linux-core/drm_vm.c

index e59322d..b10e988 100644 (file)
@@ -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;
 
 
index e1ee35c..75c89c1 100644 (file)
@@ -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");
index 4bb71ca..863cacf 100644 (file)
@@ -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", 
index 6631056..8413fb4 100644 (file)
@@ -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,
index 1654236..aa11275 100644 (file)
@@ -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;
                }
        }