* [PATCH] drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference
@ 2016-06-22 7:46 Chris Wilson
2016-06-22 8:07 ` Daniel Vetter
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Chris Wilson @ 2016-06-22 7:46 UTC (permalink / raw)
To: dri-devel; +Cc: Daniel Vetter, intel-gfx, Julia Lawall
We are only documenting that the read is outside of the lock, and do not
require strict ordering on the operation. In this case the more relaxed
lockless_dereference() will suffice.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
---
drivers/gpu/drm/drm_fb_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 0a06f9120b5a..ce54e985d91b 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -464,7 +464,7 @@ static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper)
/* Sometimes user space wants everything disabled, so don't steal the
* display if there's a master. */
- if (READ_ONCE(dev->master))
+ if (lockless_dereference(dev->master))
return false;
drm_for_each_crtc(crtc, dev) {
--
2.8.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference
2016-06-22 7:46 [PATCH] drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference Chris Wilson
@ 2016-06-22 8:07 ` Daniel Vetter
2016-06-22 8:10 ` ✓ Ro.CI.BAT: success for " Patchwork
2016-08-11 9:44 ` Peter Zijlstra
2 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2016-06-22 8:07 UTC (permalink / raw)
To: Chris Wilson; +Cc: Daniel Vetter, intel-gfx, dri-devel, Julia Lawall
On Wed, Jun 22, 2016 at 08:46:12AM +0100, Chris Wilson wrote:
> We are only documenting that the read is outside of the lock, and do not
> require strict ordering on the operation. In this case the more relaxed
> lockless_dereference() will suffice.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Julia Lawall <julia.lawall@lip6.fr>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
Applied to drm-misc.
-Daniel
> ---
> drivers/gpu/drm/drm_fb_helper.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 0a06f9120b5a..ce54e985d91b 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -464,7 +464,7 @@ static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper)
>
> /* Sometimes user space wants everything disabled, so don't steal the
> * display if there's a master. */
> - if (READ_ONCE(dev->master))
> + if (lockless_dereference(dev->master))
> return false;
>
> drm_for_each_crtc(crtc, dev) {
> --
> 2.8.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
* ✓ Ro.CI.BAT: success for drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference
2016-06-22 7:46 [PATCH] drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference Chris Wilson
2016-06-22 8:07 ` Daniel Vetter
@ 2016-06-22 8:10 ` Patchwork
2016-08-11 9:44 ` Peter Zijlstra
2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2016-06-22 8:10 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference
URL : https://patchwork.freedesktop.org/series/9029/
State : success
== Summary ==
Series 9029v1 drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference
http://patchwork.freedesktop.org/api/1.0/series/9029/revisions/1/mbox
fi-skl-i5-6260u total:225 pass:198 dwarn:0 dfail:0 fail:2 skip:25
fi-skl-i7-6700k total:225 pass:186 dwarn:0 dfail:0 fail:2 skip:37
fi-snb-i7-2600 total:225 pass:172 dwarn:0 dfail:0 fail:2 skip:51
ro-ivb-i7-3770 total:224 pass:180 dwarn:0 dfail:0 fail:0 skip:44
fi-hsw-i7-4770k failed to connect after reboot
Results at /archive/results/CI_IGT_test/RO_Patchwork_1261/
9201a72 drm-intel-nightly: 2016y-06m-21d-21h-26m-35s UTC integration manifest
26bb3f3 drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference
2016-06-22 7:46 [PATCH] drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference Chris Wilson
2016-06-22 8:07 ` Daniel Vetter
2016-06-22 8:10 ` ✓ Ro.CI.BAT: success for " Patchwork
@ 2016-08-11 9:44 ` Peter Zijlstra
2016-08-11 17:57 ` Paul E. McKenney
2 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2016-08-11 9:44 UTC (permalink / raw)
To: Chris Wilson
Cc: intel-gfx, Emil Velikov, dri-devel, Julia Lawall, Daniel Vetter,
Johannes Berg, Paul McKenney
On Wed, Jun 22, 2016 at 08:46:12AM +0100, Chris Wilson wrote:
> We are only documenting that the read is outside of the lock, and do not
> require strict ordering on the operation. In this case the more relaxed
> lockless_dereference() will suffice.
No, no, no... This is 'broken'. lockless_dereference() is _stronger_
than READ_ONCE(), not weaker.
lockless_dereference() is a wrapper around smp_read_barrier_depends()
and is used to form read dependencies. There is no read dependency here,
therefore using lockless_dereference() is entirely pointless.
Look at the definition of lockless_dereference(), it does a READ_ONCE()
and then smp_read_barrier_depends().
Also, clue is in the name: 'dereference', you don't actually dereference
the pointer here, only load it.
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -464,7 +464,7 @@ static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper)
>
> /* Sometimes user space wants everything disabled, so don't steal the
> * display if there's a master. */
> - if (READ_ONCE(dev->master))
> + if (lockless_dereference(dev->master))
> return false;
>
> drm_for_each_crtc(crtc, dev) {
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference
2016-08-11 9:44 ` Peter Zijlstra
@ 2016-08-11 17:57 ` Paul E. McKenney
0 siblings, 0 replies; 5+ messages in thread
From: Paul E. McKenney @ 2016-08-11 17:57 UTC (permalink / raw)
To: Peter Zijlstra
Cc: intel-gfx, dri-devel, Julia Lawall, Daniel Vetter, Johannes Berg
On Thu, Aug 11, 2016 at 11:44:08AM +0200, Peter Zijlstra wrote:
> On Wed, Jun 22, 2016 at 08:46:12AM +0100, Chris Wilson wrote:
> > We are only documenting that the read is outside of the lock, and do not
> > require strict ordering on the operation. In this case the more relaxed
> > lockless_dereference() will suffice.
>
> No, no, no... This is 'broken'. lockless_dereference() is _stronger_
> than READ_ONCE(), not weaker.
>
> lockless_dereference() is a wrapper around smp_read_barrier_depends()
> and is used to form read dependencies. There is no read dependency here,
> therefore using lockless_dereference() is entirely pointless.
>
> Look at the definition of lockless_dereference(), it does a READ_ONCE()
> and then smp_read_barrier_depends().
>
> Also, clue is in the name: 'dereference', you don't actually dereference
> the pointer here, only load it.
What Peter said!
If you are just checking the value of an RCU-protected pointer,
that is, one on which you would use rcu_dereference() rather than
lockless_dereference(), rcu_access_pointer() does the job of READ_ONCE()
while keeping sparse happy.
Thanx, Paul
> > +++ b/drivers/gpu/drm/drm_fb_helper.c
> > @@ -464,7 +464,7 @@ static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper)
> >
> > /* Sometimes user space wants everything disabled, so don't steal the
> > * display if there's a master. */
> > - if (READ_ONCE(dev->master))
> > + if (lockless_dereference(dev->master))
> > return false;
> >
> > drm_for_each_crtc(crtc, dev) {
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-08-11 22:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-22 7:46 [PATCH] drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference Chris Wilson
2016-06-22 8:07 ` Daniel Vetter
2016-06-22 8:10 ` ✓ Ro.CI.BAT: success for " Patchwork
2016-08-11 9:44 ` Peter Zijlstra
2016-08-11 17:57 ` Paul E. McKenney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox