[intel-gem] add gtt and pin counts to /proc/dri/*/gem_objects

Not quite portable, but these are useful for intel. Some more general
mechanism could be done...
main
Keith Packard 2008-06-13 15:43:02 -07:00
parent 4086cdb655
commit 217beb9c8d
4 changed files with 35 additions and 7 deletions

View File

@ -965,6 +965,11 @@ struct drm_device {
spinlock_t object_name_lock;
struct idr object_name_idr;
atomic_t object_count;
atomic_t object_memory;
atomic_t pin_count;
atomic_t pin_memory;
atomic_t gtt_count;
atomic_t gtt_memory;
uint32_t invalidate_domains; /* domains pending invalidation */
uint32_t flush_domains; /* domains pending flush */
/*@} */

View File

@ -74,6 +74,11 @@ drm_gem_init(struct drm_device *dev)
spin_lock_init(&dev->object_name_lock);
idr_init(&dev->object_name_idr);
atomic_set(&dev->object_count, 0);
atomic_set(&dev->object_memory, 0);
atomic_set(&dev->pin_count, 0);
atomic_set(&dev->pin_memory, 0);
atomic_set(&dev->gtt_count, 0);
atomic_set(&dev->gtt_memory, 0);
return 0;
}
@ -106,6 +111,7 @@ drm_gem_object_alloc(struct drm_device *dev, size_t size)
return NULL;
}
atomic_inc(&dev->object_count);
atomic_add(obj->size, &dev->object_memory);
return obj;
}
EXPORT_SYMBOL(drm_gem_object_alloc);
@ -376,6 +382,7 @@ drm_gem_object_free(struct kref *kref)
fput(obj->filp);
atomic_dec(&dev->object_count);
atomic_sub(obj->size, &dev->object_memory);
kfree(obj);
}
EXPORT_SYMBOL(drm_gem_object_free);

View File

@ -655,6 +655,10 @@ static int drm_gem_object_info(char *buf, char **start, off_t offset,
*start = &buf[offset];
*eof = 0;
DRM_PROC_PRINT ("%d objects\n", atomic_read (&dev->object_count));
DRM_PROC_PRINT ("%d object bytes\n", atomic_read (&dev->object_memory));
DRM_PROC_PRINT ("%d pinned\n", atomic_read (&dev->pin_count));
DRM_PROC_PRINT ("%d pin bytes\n", atomic_read (&dev->pin_memory));
DRM_PROC_PRINT ("%d gtt bytes\n", atomic_read (&dev->gtt_memory));
if (len > request + offset)
return request;
*eof = 1;

View File

@ -677,6 +677,7 @@ i915_gem_object_wait_rendering(struct drm_gem_object *obj)
static int
i915_gem_object_unbind(struct drm_gem_object *obj)
{
struct drm_device *dev = obj->dev;
struct drm_i915_gem_object *obj_priv = obj->driver_private;
int ret = 0;
@ -706,6 +707,9 @@ i915_gem_object_unbind(struct drm_gem_object *obj)
i915_gem_object_free_page_list(obj);
atomic_dec(&dev->gtt_count);
atomic_sub(obj->size, &dev->gtt_memory);
drm_memrange_put_block(obj_priv->gtt_space);
obj_priv->gtt_space = NULL;
@ -995,6 +999,8 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
obj_priv->gtt_space = NULL;
return -ENOMEM;
}
atomic_inc(&dev->gtt_count);
atomic_add(obj->size, &dev->gtt_memory);
/* Assert that the object is not currently in any GPU domain. As it
* wasn't in the GTT, there shouldn't be any way it could have been in
@ -1764,6 +1770,7 @@ pre_mutex_err:
int
i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment)
{
struct drm_device *dev = obj->dev;
struct drm_i915_gem_object *obj_priv = obj->driver_private;
int ret;
@ -1779,10 +1786,12 @@ i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment)
/* If the object is not active and not pending a flush,
* remove it from the inactive list
*/
if (obj_priv->pin_count == 1 &&
!obj_priv->active &&
obj->write_domain == 0)
if (obj_priv->pin_count == 1) {
atomic_inc(&dev->pin_count);
atomic_add(obj->size, &dev->pin_memory);
if (!obj_priv->active && obj->write_domain == 0)
list_del_init(&obj_priv->list);
}
return 0;
}
@ -1802,9 +1811,12 @@ i915_gem_object_unpin(struct drm_gem_object *obj)
* neither active nor being flushed, then stick it on
* the inactive list
*/
if (obj_priv->pin_count == 0 &&
!obj_priv->active && obj->write_domain == 0)
if (obj_priv->pin_count == 0) {
if (!obj_priv->active && obj->write_domain == 0)
list_move_tail(&obj_priv->list, &dev_priv->mm.inactive_list);
atomic_dec(&dev->pin_count);
atomic_sub(obj->size, &dev->pin_memory);
}
}
int