diff mbox series

[1/2] drm/i915: Initialise the obj->rcu head

Message ID 20181108092101.27598-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/i915: Initialise the obj->rcu head | expand

Commit Message

Chris Wilson Nov. 8, 2018, 9:21 a.m. UTC
Make the rcu_head known to the system, in particular for debugobjects.
And having declared it for debugobjects, we need to tidy up afterwards.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108691
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Mika Kuoppala Nov. 9, 2018, 8:40 a.m. UTC | #1
Chris Wilson <chris@chris-wilson.co.uk> writes:

> Make the rcu_head known to the system, in particular for debugobjects.
> And having declared it for debugobjects, we need to tidy up afterwards.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108691
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_gem.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 5b80b0c14aed..24f126ccf21e 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -4739,6 +4739,8 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,
>  	INIT_LIST_HEAD(&obj->lut_list);
>  	INIT_LIST_HEAD(&obj->batch_pool_link);
>  
> +	init_rcu_head(&obj->rcu);
> +
>  	obj->ops = ops;
>  
>  	reservation_object_init(&obj->__builtin_resv);
> @@ -4941,6 +4943,8 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
>  		drm_gem_object_release(&obj->base);
>  		i915_gem_info_remove_obj(i915, obj->base.size);
>  
> +		destroy_rcu_head(&obj->rcu);
> +

It looks like you need to break the union in struct drm_i915_gem_object
for this to work. Or did I get the ordering of events wrong?
-Mika

>  		kfree(obj->bit_17);
>  		i915_gem_object_free(obj);
>  
> -- 
> 2.19.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson Nov. 9, 2018, 9 a.m. UTC | #2
Quoting Mika Kuoppala (2018-11-09 08:40:56)
> Chris Wilson <chris@chris-wilson.co.uk> writes:
> 
> > Make the rcu_head known to the system, in particular for debugobjects.
> > And having declared it for debugobjects, we need to tidy up afterwards.
> >
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108691
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > ---
> >  drivers/gpu/drm/i915/i915_gem.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> > index 5b80b0c14aed..24f126ccf21e 100644
> > --- a/drivers/gpu/drm/i915/i915_gem.c
> > +++ b/drivers/gpu/drm/i915/i915_gem.c
> > @@ -4739,6 +4739,8 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,
> >       INIT_LIST_HEAD(&obj->lut_list);
> >       INIT_LIST_HEAD(&obj->batch_pool_link);
> >  
> > +     init_rcu_head(&obj->rcu);
> > +
> >       obj->ops = ops;
> >  
> >       reservation_object_init(&obj->__builtin_resv);
> > @@ -4941,6 +4943,8 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
> >               drm_gem_object_release(&obj->base);
> >               i915_gem_info_remove_obj(i915, obj->base.size);
> >  
> > +             destroy_rcu_head(&obj->rcu);
> > +
> 
> It looks like you need to break the union in struct drm_i915_gem_object
> for this to work. Or did I get the ordering of events wrong?

Not the ordering of events, just the insensitivity of debugobjects. All
we are saying here is to remove the hash of this pointer from the set
of debugobjects so that when this memory block is freed we do not
complain that the debugobject still exists. To address the complaint, we
can just move to where the rcu transitions to being the llist, which I
had forgotten about.
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 5b80b0c14aed..24f126ccf21e 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4739,6 +4739,8 @@  void i915_gem_object_init(struct drm_i915_gem_object *obj,
 	INIT_LIST_HEAD(&obj->lut_list);
 	INIT_LIST_HEAD(&obj->batch_pool_link);
 
+	init_rcu_head(&obj->rcu);
+
 	obj->ops = ops;
 
 	reservation_object_init(&obj->__builtin_resv);
@@ -4941,6 +4943,8 @@  static void __i915_gem_free_objects(struct drm_i915_private *i915,
 		drm_gem_object_release(&obj->base);
 		i915_gem_info_remove_obj(i915, obj->base.size);
 
+		destroy_rcu_head(&obj->rcu);
+
 		kfree(obj->bit_17);
 		i915_gem_object_free(obj);