Re: [Intel-gfx] [PATCH] drm/i915: fix the racy object accounting

2013-07-25 Thread Daniel Vetter
On Wed, Jul 24, 2013 at 11:01:08PM +0100, Chris Wilson wrote:
 On Wed, Jul 24, 2013 at 10:40:23PM +0200, Daniel Vetter wrote:
  Just use a spinlock to protect them.
  
  v2: Rebase onto the new object create refcount fix patch.
  
  v3: Don't kill dev_priv-mm.object_memory as requested by Chris and
  hence just use a spinlock instead of atomic_t.
  
  Cc: Chris Wilson ch...@chris-wilson.co.uk
  Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch
 
 Sadly, I have no better answer to my desire have my cake and eat it.
 Reviewed-by: Chris Wilson ch...@chris-wilson.co.uk

Queued for -next, thanks for the review.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm/i915: fix the racy object accounting

2013-07-24 Thread Daniel Vetter
Just use a spinlock to protect them.

v2: Rebase onto the new object create refcount fix patch.

v3: Don't kill dev_priv-mm.object_memory as requested by Chris and
hence just use a spinlock instead of atomic_t.

Cc: Chris Wilson ch...@chris-wilson.co.uk
Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch
---
 drivers/gpu/drm/i915/i915_dma.c | 1 +
 drivers/gpu/drm/i915/i915_drv.h | 1 +
 drivers/gpu/drm/i915/i915_gem.c | 4 
 3 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 15ed8f5..8b9b4ba 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1493,6 +1493,7 @@ int i915_driver_load(struct drm_device *dev, unsigned 
long flags)
spin_lock_init(dev_priv-irq_lock);
spin_lock_init(dev_priv-gpu_error.lock);
spin_lock_init(dev_priv-backlight.lock);
+   spin_lock_init(dev_priv-mm.object_stat_lock);
mutex_init(dev_priv-dpio_lock);
mutex_init(dev_priv-rps.hw_lock);
mutex_init(dev_priv-modeset_restore_lock);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index e295561..49be021 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -926,6 +926,7 @@ struct i915_gem_mm {
struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT];
 
/* accounting, useful for userland debugging */
+   spinlock_t object_stat_lock;
size_t object_memory;
u32 object_count;
 };
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index dc7e6de..ec79fa0 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -75,15 +75,19 @@ static inline void i915_gem_object_fence_lost(struct 
drm_i915_gem_object *obj)
 static void i915_gem_info_add_obj(struct drm_i915_private *dev_priv,
  size_t size)
 {
+   spin_lock(dev_priv-mm.object_stat_lock);
dev_priv-mm.object_count++;
dev_priv-mm.object_memory += size;
+   spin_unlock(dev_priv-mm.object_stat_lock);
 }
 
 static void i915_gem_info_remove_obj(struct drm_i915_private *dev_priv,
 size_t size)
 {
+   spin_lock(dev_priv-mm.object_stat_lock);
dev_priv-mm.object_count--;
dev_priv-mm.object_memory -= size;
+   spin_unlock(dev_priv-mm.object_stat_lock);
 }
 
 static int
-- 
1.8.1.4

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: fix the racy object accounting

2013-07-24 Thread Chris Wilson
On Wed, Jul 24, 2013 at 10:40:23PM +0200, Daniel Vetter wrote:
 Just use a spinlock to protect them.
 
 v2: Rebase onto the new object create refcount fix patch.
 
 v3: Don't kill dev_priv-mm.object_memory as requested by Chris and
 hence just use a spinlock instead of atomic_t.
 
 Cc: Chris Wilson ch...@chris-wilson.co.uk
 Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch

Sadly, I have no better answer to my desire have my cake and eat it.
Reviewed-by: Chris Wilson ch...@chris-wilson.co.uk

Now, I guess to pester Ben to make sure there is adequate^Wsuperficial
per-vma, per-ctx, per-file accounting.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx