Skip to contentSkip to conversation

locking fixes

GIT PULL Paul E. McKenney 2 participants 3 messages Aug 19, 2016

Subsystems (3)
lore
Share & tools
lore
#1 lore raw
In reply to Paul E. McKenney
Quoted 7 lines · Paul E. McKenney

Hello, Eric,

Does Johannes's recent change to lockless_dereference() help with the sparse issue?

Thanx, Paul

Hi Paul

Yes indeed, this helps.

Thanks !

Quoted 72 lines

----- Forwarded message from Ingo Molnar <[email protected]> -----

Date: Thu, 18 Aug 2016 22:34:21 +0200
From: Ingo Molnar <[email protected]>
To: Linus Torvalds <[email protected]>
Cc: [email protected], Peter Zijlstra <[email protected]>,
Thomas Gleixner <[email protected]>, Andrew Morton <[email protected]>, "Paul E. McKenney" <[email protected]>
Subject: [GIT PULL] locking fixes

Linus,

Please pull the latest locking-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking-urgent-for-linus

   # HEAD: 112dc0c8069e5554e0ad29c58228f1e6ca49e13d locking/barriers: Suppress sparse warnings in lockless_dereference()

Two lockless_dereference() related fixes.

Thanks,

Ingo

------------------>
Johannes Berg (2):
Revert "drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference" locking/barriers: Suppress sparse warnings in lockless_dereference()

 drivers/gpu/drm/drm_fb_helper.c | 2 +-
 include/linux/compiler.h        | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +1 -1
index ce54e985d91b..0a06f9120b5a 100644
@@ -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 (lockless_dereference(dev->master))
+	if (READ_ONCE(dev->master))
 		return false;
 
 	drm_for_each_crtc(crtc, dev) {
include/linux/compiler.h +3 -4
index 1bb954842725..436aa4e42221 100644
@@ -527,13 +527,13 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
  * object's lifetime is managed by something other than RCU.  That
  * "something other" might be reference counting or simple immortality.
  *
- * The seemingly unused void * variable is to validate @p is indeed a pointer
- * type. All pointer types silently cast to void *.
+ * The seemingly unused size_t variable is to validate @p is indeed a pointer
+ * type by making sure it can be dereferenced.
  */
 #define lockless_dereference(p) \
 ({ \
 	typeof(p) _________p1 = READ_ONCE(p); \
-	__maybe_unused const void * const _________p2 = _________p1; \
+	size_t __maybe_unused __size_of_ptr = sizeof(*(p)); \
 	smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
 	(_________p1); \
 })
 
 
----- End forwarded message -----
#2 lore raw
Quoted 6 lines · Eric Dumazet
Quoted 5 lines · Paul E. McKenney

Hello, Eric,

Does Johannes's recent change to lockless_dereference() help with the sparse issue?

Quoted 8 lines
Quoted 2 lines

Thanx, Paul

Hi Paul

Yes indeed, this helps.

Thanks !

Woo-hoo! ;-)

Thanx, Paul

#0 lore raw

Hello, Eric,

Does Johannes's recent change to lockless_dereference() help with the sparse issue?

Thanx, Paul

----- Forwarded message from Ingo Molnar <[email protected]> -----

Date: Thu, 18 Aug 2016 22:34:21 +0200
From: Ingo Molnar <[email protected]>
To: Linus Torvalds <[email protected]>
Cc: [email protected], Peter Zijlstra <[email protected]>,
Thomas Gleixner <[email protected]>, Andrew Morton <[email protected]>, "Paul E. McKenney" <[email protected]>
Subject: [GIT PULL] locking fixes

Linus,

Please pull the latest locking-urgent-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking-urgent-for-linus

# HEAD: 112dc0c8069e5554e0ad29c58228f1e6ca49e13d locking/barriers: Suppress sparse warnings in lockless_dereference()

Two lockless_dereference() related fixes.

Thanks,

Ingo

------------------>
Johannes Berg (2):
Revert "drm/fb-helper: Reduce READ_ONCE(master) to lockless_dereference" locking/barriers: Suppress sparse warnings in lockless_dereference()

 drivers/gpu/drm/drm_fb_helper.c | 2 +-
 include/linux/compiler.h        | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +1 -1
index ce54e985d91b..0a06f9120b5a 100644
@@ -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 (lockless_dereference(dev->master))
+	if (READ_ONCE(dev->master))
 		return false;
 
 	drm_for_each_crtc(crtc, dev) {
include/linux/compiler.h +3 -3
index 1bb954842725..436aa4e42221 100644
@@ -527,13 +527,13 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
  * object's lifetime is managed by something other than RCU.  That
  * "something other" might be reference counting or simple immortality.
  *
- * The seemingly unused void * variable is to validate @p is indeed a pointer
- * type. All pointer types silently cast to void *.
+ * The seemingly unused size_t variable is to validate @p is indeed a pointer
+ * type by making sure it can be dereferenced.
  */
 #define lockless_dereference(p) \
 ({ \
 	typeof(p) _________p1 = READ_ONCE(p); \
-	__maybe_unused const void * const _________p2 = _________p1; \
+	size_t __maybe_unused __size_of_ptr = sizeof(*(p)); \
 	smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
 	(_________p1); \
 })

----- End forwarded message -----