All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: properly init lockdep class
       [not found] <201711250649.n1NUHo79%fengguang.wu@intel.com>
@ 2017-11-30 15:19 ` Sebastian Andrzej Siewior
  2017-12-13 14:00   ` Joonas Lahtinen
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2017-11-30 15:19 UTC (permalink / raw)
  To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi
  Cc: David Airlie, intel-gfx, dri-devel, kbuild-all, Thomas Gleixner,
	kbuild test robot

The code has an ifdef and uses two functions to either init the bare
spinlock or init it and set a lock-class. It is possible to do the same
thing without an ifdef.
With this patch (in debug case) we first use the "default" lock class
which is later overwritten to the supplied one. Without lockdep the set
name/class function vanishes.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/gpu/drm/i915/i915_gem_timeline.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

--- a/drivers/gpu/drm/i915/i915_gem_timeline.c
+++ b/drivers/gpu/drm/i915/i915_gem_timeline.c
@@ -33,11 +33,8 @@ static void __intel_timeline_init(struct
 {
 	tl->fence_context = context;
 	tl->common = parent;
-#ifdef CONFIG_DEBUG_SPINLOCK
-	__raw_spin_lock_init(&tl->lock.rlock, lockname, lockclass);
-#else
 	spin_lock_init(&tl->lock);
-#endif
+	lockdep_set_class_and_name(&tl->lock, lockclass, lockname);
 	init_request_active(&tl->last_request, NULL);
 	INIT_LIST_HEAD(&tl->requests);
 	i915_syncmap_init(&tl->sync);
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915: properly init lockdep class
  2017-11-30 15:19 ` [PATCH] drm/i915: properly init lockdep class Sebastian Andrzej Siewior
@ 2017-12-13 14:00   ` Joonas Lahtinen
  2017-12-13 15:06     ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 6+ messages in thread
From: Joonas Lahtinen @ 2017-12-13 14:00 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, Jani Nikula, Rodrigo Vivi
  Cc: David Airlie, intel-gfx, dri-devel, kbuild-all, Thomas Gleixner,
	kbuild test robot

On Thu, 2017-11-30 at 16:19 +0100, Sebastian Andrzej Siewior wrote:
> The code has an ifdef and uses two functions to either init the bare
> spinlock or init it and set a lock-class. It is possible to do the same
> thing without an ifdef.
> With this patch (in debug case) we first use the "default" lock class
> which is later overwritten to the supplied one. Without lockdep the set
> name/class function vanishes.
> 
> Reported-by: kbuild test robot <fengguang.wu@intel.com>

How exactly did kbuild test robot figure this out?

At least according to the source there doesn't seem to be clarity about
what is the right thing to do, this being just one option.

Regards, Joonas

> +++ b/drivers/gpu/drm/i915/i915_gem_timeline.c
> @@ -33,11 +33,8 @@ static void __intel_timeline_init(struct
>  {
>  	tl->fence_context = context;
>  	tl->common = parent;
> -#ifdef CONFIG_DEBUG_SPINLOCK
> -	__raw_spin_lock_init(&tl->lock.rlock, lockname, lockclass);
> -#else
>  	spin_lock_init(&tl->lock);
> -#endif
> +	lockdep_set_class_and_name(&tl->lock, lockclass, lockname);
>  	init_request_active(&tl->last_request, NULL);
>  	INIT_LIST_HEAD(&tl->requests);
>  	i915_syncmap_init(&tl->sync);
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915: properly init lockdep class
  2017-12-13 14:00   ` Joonas Lahtinen
@ 2017-12-13 15:06     ` Sebastian Andrzej Siewior
  2017-12-13 15:37       ` Joonas Lahtinen
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2017-12-13 15:06 UTC (permalink / raw)
  To: Joonas Lahtinen
  Cc: dri-devel, David Airlie, intel-gfx, kbuild-all, Rodrigo Vivi,
	Thomas Gleixner, kbuild test robot

On 2017-12-13 16:00:49 [+0200], Joonas Lahtinen wrote:
> On Thu, 2017-11-30 at 16:19 +0100, Sebastian Andrzej Siewior wrote:
> > The code has an ifdef and uses two functions to either init the bare
> > spinlock or init it and set a lock-class. It is possible to do the same
> > thing without an ifdef.
> > With this patch (in debug case) we first use the "default" lock class
> > which is later overwritten to the supplied one. Without lockdep the set
> > name/class function vanishes.
> > 
> > Reported-by: kbuild test robot <fengguang.wu@intel.com>
> 
> How exactly did kbuild test robot figure this out?

I fixed it up for RT, then robot found a way to complain about it. Then
I slapped myself for not submitting this patch in the first place.

> At least according to the source there doesn't seem to be clarity about
> what is the right thing to do, this being just one option.

I don' think `ifdef CONFIG_DEBUG_SPINLOCK' is an option. Especially
since the i915 driver here is the only user in tree doing this kind of
thing.
Then we have lockdep_set_class_and_name() (which I promote here). This
looks like the official way of doing lockdep related things and it has
even more than ten users in tree.

> Regards, Joonas

Sebastian
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915: properly init lockdep class
  2017-12-13 15:06     ` Sebastian Andrzej Siewior
@ 2017-12-13 15:37       ` Joonas Lahtinen
  2017-12-13 17:36         ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 6+ messages in thread
From: Joonas Lahtinen @ 2017-12-13 15:37 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: dri-devel, David Airlie, intel-gfx, kbuild-all, Rodrigo Vivi,
	Thomas Gleixner, kbuild test robot

On Wed, 2017-12-13 at 16:06 +0100, Sebastian Andrzej Siewior wrote:
> On 2017-12-13 16:00:49 [+0200], Joonas Lahtinen wrote:
> > On Thu, 2017-11-30 at 16:19 +0100, Sebastian Andrzej Siewior wrote:
> > > The code has an ifdef and uses two functions to either init the bare
> > > spinlock or init it and set a lock-class. It is possible to do the same
> > > thing without an ifdef.
> > > With this patch (in debug case) we first use the "default" lock class
> > > which is later overwritten to the supplied one. Without lockdep the set
> > > name/class function vanishes.
> > > 
> > > Reported-by: kbuild test robot <fengguang.wu@intel.com>
> > 
> > How exactly did kbuild test robot figure this out?
> 
> I fixed it up for RT, then robot found a way to complain about it. Then
> I slapped myself for not submitting this patch in the first place.

Right, I was kinda wondering if the robot has gained consciuousness and
is developing new checks...

> > At least according to the source there doesn't seem to be clarity about
> > what is the right thing to do, this being just one option.
> 
> I don' think `ifdef CONFIG_DEBUG_SPINLOCK' is an option. Especially
> since the i915 driver here is the only user in tree doing this kind of
> thing.
> Then we have lockdep_set_class_and_name() (which I promote here). This
> looks like the official way of doing lockdep related things and it has
> even more than ten users in tree.

I think it be worthwhile to suggest would be the addition of
__spin_lock_init where you can pass in the the lockclass and name.

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915: properly init lockdep class
  2017-12-13 15:37       ` Joonas Lahtinen
@ 2017-12-13 17:36         ` Sebastian Andrzej Siewior
  2017-12-13 18:40           ` Peter Zijlstra
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2017-12-13 17:36 UTC (permalink / raw)
  To: Joonas Lahtinen, Peter Zijlstra
  Cc: dri-devel, David Airlie, intel-gfx, kbuild-all, Rodrigo Vivi,
	Thomas Gleixner, kbuild test robot

+peterz
context: http://www.spinics.net/lists/intel-gfx/msg149011.html

On 2017-12-13 17:37:21 [+0200], Joonas Lahtinen wrote:
> On Wed, 2017-12-13 at 16:06 +0100, Sebastian Andrzej Siewior wrote:
> > On 2017-12-13 16:00:49 [+0200], Joonas Lahtinen wrote:
> > > On Thu, 2017-11-30 at 16:19 +0100, Sebastian Andrzej Siewior wrote:
> > > > The code has an ifdef and uses two functions to either init the bare
> > > > spinlock or init it and set a lock-class. It is possible to do the same
> > > > thing without an ifdef.
> > > > With this patch (in debug case) we first use the "default" lock class
> > > > which is later overwritten to the supplied one. Without lockdep the set
> > > > name/class function vanishes.
> > > At least according to the source there doesn't seem to be clarity about
> > > what is the right thing to do, this being just one option.
> > 
> > I don' think `ifdef CONFIG_DEBUG_SPINLOCK' is an option. Especially
> > since the i915 driver here is the only user in tree doing this kind of
> > thing.
> > Then we have lockdep_set_class_and_name() (which I promote here). This
> > looks like the official way of doing lockdep related things and it has
> > even more than ten users in tree.
> 
> I think it be worthwhile to suggest would be the addition of
> __spin_lock_init where you can pass in the the lockclass and name.

I don't due to the existing interface. However I don't call the shots
here and added peterz instead :)

> Regards, Joonas

Sebastian
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915: properly init lockdep class
  2017-12-13 17:36         ` Sebastian Andrzej Siewior
@ 2017-12-13 18:40           ` Peter Zijlstra
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2017-12-13 18:40 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: dri-devel, David Airlie, intel-gfx, kbuild-all, Rodrigo Vivi,
	Thomas Gleixner, kbuild test robot

On Wed, Dec 13, 2017 at 06:36:33PM +0100, Sebastian Andrzej Siewior wrote:
> +peterz
> context: http://www.spinics.net/lists/intel-gfx/msg149011.html
> 
> On 2017-12-13 17:37:21 [+0200], Joonas Lahtinen wrote:
> > On Wed, 2017-12-13 at 16:06 +0100, Sebastian Andrzej Siewior wrote:
> > > On 2017-12-13 16:00:49 [+0200], Joonas Lahtinen wrote:
> > > > On Thu, 2017-11-30 at 16:19 +0100, Sebastian Andrzej Siewior wrote:
> > > > > The code has an ifdef and uses two functions to either init the bare
> > > > > spinlock or init it and set a lock-class. It is possible to do the same
> > > > > thing without an ifdef.
> > > > > With this patch (in debug case) we first use the "default" lock class
> > > > > which is later overwritten to the supplied one. Without lockdep the set
> > > > > name/class function vanishes.
> …
> > > > At least according to the source there doesn't seem to be clarity about
> > > > what is the right thing to do, this being just one option.

The proposed patch is definitely the right thing to do. The fact that it
doesn't require #ifdef is a very big clue.
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-13 18:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <201711250649.n1NUHo79%fengguang.wu@intel.com>
2017-11-30 15:19 ` [PATCH] drm/i915: properly init lockdep class Sebastian Andrzej Siewior
2017-12-13 14:00   ` Joonas Lahtinen
2017-12-13 15:06     ` Sebastian Andrzej Siewior
2017-12-13 15:37       ` Joonas Lahtinen
2017-12-13 17:36         ` Sebastian Andrzej Siewior
2017-12-13 18:40           ` Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.