Skip to contentSkip to conversation

Fix improper uses of smp_mb__{before,after}_atomic()

PATCH In review Andrea Parri 7 participants 26 messages Apr 29, 2019 – May 14, 2019

Subsystems (10)
lore
Share & tools
lore
#1 lore raw

PATCH 1/5 drm/msm: Fix improper uses of smp_mb__{before,after}_atomic()

In reply to Andrea Parri

These barriers only apply to the read-modify-write operations; in particular, they do not apply to the atomic_set() primitive.

Replace the barriers with smp_mb()s.

Fixes b1fc2839d2f92 ("drm/msm: Implement preemption for A5XX targets")
Cc Rob Clark <[email protected]>
Cc Sean Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jordan Crouse <[email protected]>
---
 drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +2 -2
index 3d62310a535fb..ee0820ee0c664 100644
@@ -39,10 +39,10 @@ static inline void set_preempt_state(struct a5xx_gpu *gpu,
 	 * preemption or in the interrupt handler so barriers are needed
 	 * before...
 	 */
-	smp_mb__before_atomic();
+	smp_mb();
 	atomic_set(&gpu->preempt_state, new);
 	/* ... and after*/
-	smp_mb__after_atomic();
+	smp_mb();
 }
 
 /* Write the most recent wptr for the given ring into the hardware */
Signature · 1 line
2.7.4
#11 lore raw

PATCH 4/5 ceph: fix improper use of smp_mb__before_atomic()

In reply to Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic64_set() primitive.

Replace the barrier with an smp_mb().

Fixes fdd4e15838e59 ("ceph: rework dcache readdir")
Cc "Yan, Zheng" <[email protected]>
Cc Sage Weil <[email protected]>
Cc Ilya Dryomov <[email protected]>
---
 fs/ceph/super.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/super.h +1 -1
index 16c03188578ea..b5c782e6d62f1 100644
@@ -541,7 +541,7 @@ static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci,
 					   long long release_count,
 					   long long ordered_count)
 {
-	smp_mb__before_atomic();
+	smp_mb();
 	atomic64_set(&ci->i_complete_seq[0], release_count);
 	atomic64_set(&ci->i_complete_seq[1], ordered_count);
 }
Signature · 1 line
2.7.4
#17 lore raw

PATCH 5/5 IB/hfi1: Fix improper uses of smp_mb__before_atomic()

In reply to Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_read() primitive.

Replace the barrier with an smp_mb().

Fixes 856cc4c237add ("IB/hfi1: Add the capability for reserved operations")
Cc Dennis Dalessandro <[email protected]>
Cc Mike Marciniszyn <[email protected]>
Cc Doug Ledford <[email protected]>
Cc Jason Gunthorpe <[email protected]>
---
 drivers/infiniband/sw/rdmavt/qp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/sw/rdmavt/qp.c +3 -3
index a34b9a2a32b60..b64fd151d31fb 100644
@@ -1863,11 +1863,11 @@ static inline int rvt_qp_is_avail(
 	u32 reserved_used;
 
 	/* see rvt_qp_wqe_unreserve() */
-	smp_mb__before_atomic();
+	smp_mb();
 	reserved_used = atomic_read(&qp->s_reserved_used);
 	if (unlikely(reserved_op)) {
 		/* see rvt_qp_wqe_unreserve() */
-		smp_mb__before_atomic();
+		smp_mb();
 		if (reserved_used >= rdi->dparms.reserved_operations)
 			return -ENOMEM;
 		return 0;
@@ -1882,7 +1882,7 @@ static inline int rvt_qp_is_avail(
 		avail = slast - qp->s_head;
 
 	/* see rvt_qp_wqe_unreserve() */
-	smp_mb__before_atomic();
+	smp_mb();
 	reserved_used = atomic_read(&qp->s_reserved_used);
 	avail =  avail - 1 -
 		(rdi->dparms.reserved_operations - reserved_used);
Signature · 1 line
2.7.4
#0 lore raw

cover Fix improper uses of smp_mb__{before,after}_atomic()

Hello!

A relatively common misuse of these barriers is to apply these to operations which are not read-modify-write operations, such as atomic_set() and atomic_read(); examples were discussed in [1].

This series attempts to fix those uses by (conservatively) replacing the smp_mb__{before,after}_atomic() barriers with full memory barriers.

Applies on 5.1-rc7.

Thanks,
Andrea

Cc "Paul E. McKenney" <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Rob Clark <[email protected]>
Cc Sean Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jordan Crouse <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Omar Sandoval <[email protected]>
Cc "Yan, Zheng" <[email protected]>
Cc Sage Weil <[email protected]>
Cc Ilya Dryomov <[email protected]>
Cc Dennis Dalessandro <[email protected]>
Cc Mike Marciniszyn <[email protected]>
Cc Doug Ledford <[email protected]>
Cc Jason Gunthorpe <[email protected]>

[1] http://lkml.kernel.org/r/[email protected]

Andrea Parri (5):
drm/msm: Fix improper uses of smp_mb__{before,after}_atomic()
bio: fix improper use of smp_mb__before_atomic()
sbitmap: fix improper use of smp_mb__before_atomic()
ceph: fix improper use of smp_mb__before_atomic() IB/hfi1: Fix improper uses of smp_mb__before_atomic()

 drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 4 ++--
 drivers/infiniband/sw/rdmavt/qp.c         | 6 +++---
 fs/ceph/super.h                           | 2 +-
 include/linux/bio.h                       | 2 +-
 lib/sbitmap.c                             | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.4
#3 lore raw

PATCH 2/5 bio: fix improper use of smp_mb__before_atomic()

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_set() primitive.

Replace the barrier with an smp_mb().

Fixes dac56212e8127 ("bio: skip atomic inc/dec of ->bi_cnt for most use cases")
Cc Jens Axboe <[email protected]>
---
 include/linux/bio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bio.h +1 -1
index e584673c18814..5becbafb84e8a 100644
@@ -224,7 +224,7 @@ static inline void bio_cnt_set(struct bio *bio, unsigned int count)
 {
 	if (count != 1) {
 		bio->bi_flags |= (1 << BIO_REFFED);
-		smp_mb__before_atomic();
+		smp_mb();
 	}
 	atomic_set(&bio->__bi_cnt, count);
 }
Signature · 1 line
2.7.4
#7 lore raw

PATCH 3/5 sbitmap: fix improper use of smp_mb__before_atomic()

In reply to Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_set() primitive.

Replace the barrier with an smp_mb().

Fixes 6c0ca7ae292ad ("sbitmap: fix wakeup hang after sbq resize")
Cc Jens Axboe <[email protected]>
Cc Omar Sandoval <[email protected]>
---
 lib/sbitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sbitmap.c +1 -1
index 155fe38756ecf..4a7fc4915dfc6 100644
@@ -435,7 +435,7 @@ static void sbitmap_queue_update_wake_batch(struct sbitmap_queue *sbq,
 		 * to ensure that the batch size is updated before the wait
 		 * counts.
 		 */
-		smp_mb__before_atomic();
+		smp_mb();
 		for (i = 0; i < SBQ_WAIT_QUEUES; i++)
 			atomic_set(&sbq->ws[i].wait_cnt, 1);
 	}
Signature · 1 line
2.7.4
#18 lore raw

RE: [PATCH 5/5] IB/hfi1: Fix improper uses of smp_mb__before_atomic()

In reply to Andrea Parri
Quoted 12 lines

-----Original Message-----
From: [email protected] [mailto:linux-rdma- [email protected]] On Behalf Of Andrea Parri
Sent: Monday, April 29, 2019 4:15 PM
To: [email protected]
Cc: Andrea Parri <[email protected]>; [email protected]; Dalessandro, Dennis <[email protected]>; Marciniszyn, Mike <[email protected]>; Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>; [email protected]
Subject: [PATCH 5/5] IB/hfi1: Fix improper uses of smp_mb__before_atomic()

Quoted 4 lines

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_read() primitive.

Replace the barrier with an smp_mb().

This is one of a couple of barrier issues that we are currently looking into.

See:

[PATCH for-next 6/9] IB/rdmavt: Add new completion inline

We will take a look at this one as well.

Thanks,

Mike

Quoted 44 lines
Fixes 856cc4c237add ("IB/hfi1: Add the capability for reserved operations")
Cc Dennis Dalessandro <[email protected]>
Cc Mike Marciniszyn <[email protected]>
Cc Doug Ledford <[email protected]>
Cc Jason Gunthorpe <[email protected]>

---
drivers/infiniband/sw/rdmavt/qp.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/sw/rdmavt/qp.c +3 -4
index a34b9a2a32b60..b64fd151d31fb 100644
@@ -1863,11 +1863,11 @@ static inline int rvt_qp_is_avail(
 	u32 reserved_used;
 
 	/* see rvt_qp_wqe_unreserve() */
-	smp_mb__before_atomic();
+	smp_mb();
 	reserved_used = atomic_read(&qp->s_reserved_used);
 	if (unlikely(reserved_op)) {
 		/* see rvt_qp_wqe_unreserve() */
-		smp_mb__before_atomic();
+		smp_mb();
 		if (reserved_used >= rdi->dparms.reserved_operations)
 			return -ENOMEM;
 		return 0;
@@ -1882,7 +1882,7 @@ static inline int rvt_qp_is_avail(
 		avail = slast - qp->s_head;
 
 	/* see rvt_qp_wqe_unreserve() */
-	smp_mb__before_atomic();
+	smp_mb();
 	reserved_used = atomic_read(&qp->s_reserved_used);
 	avail =  avail - 1 -
 		(rdi->dparms.reserved_operations - reserved_used);
--

2.7.4

#19 lore raw

Re: [PATCH 5/5] IB/hfi1: Fix improper uses of smp_mb__before_atomic()

Hi Mike,

Quoted 5 lines
Quoted 4 lines

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_read() primitive.

Replace the barrier with an smp_mb().

Quoted 7 lines

This is one of a couple of barrier issues that we are currently looking into.

See:

[PATCH for-next 6/9] IB/rdmavt: Add new completion inline

We will take a look at this one as well.

Thank you for the reference and for looking into this,

Andrea

#4 lore raw

Re: [PATCH 2/5] bio: fix improper use of smp_mb__before_atomic()

In reply to Andrea Parri

include/linux/bio.h static inline void bio_cnt_set(struct bio *bio, unsigned int count) · line 227

Quoted 10 lines · Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_set() primitive.

Replace the barrier with an smp_mb().

include/linux/bio.h +0 -1
@@ -224,7 +224,7 @@ static inline void bio_cnt_set(struct bio *bio, unsigned int count)
 {
 	if (count != 1) {
 		bio->bi_flags |= (1 << BIO_REFFED);
-		smp_mb__before_atomic();

Maybe also add:

		/*
		 * XXX the comment that explain this barrier goes here
		 */
Quoted 4 lines
include/linux/bio.h +1 -0
+		smp_mb();
 	}
 	atomic_set(&bio->__bi_cnt, count);
 }
#12 lore raw

Re: [PATCH 4/5] ceph: fix improper use of smp_mb__before_atomic()

In reply to Andrea Parri

fs/ceph/super.h static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci, · line 544

Quoted 11 lines · Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic64_set() primitive.

Replace the barrier with an smp_mb().

fs/ceph/super.h +0 -1
@@ -541,7 +541,7 @@ static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci,
 					   long long release_count,
 					   long long ordered_count)
 {
-	smp_mb__before_atomic();

same

	/*
	 * XXX: the comment that explain this barrier goes here.
	 */
Quoted 8 lines
fs/ceph/super.h +1 -0
+	smp_mb();
 
 	atomic64_set(&ci->i_complete_seq[0], release_count);
 	atomic64_set(&ci->i_complete_seq[1], ordered_count);

}

Signature · 1 line
2.7.4
#23 lore raw

Re: [PATCH 5/5] IB/hfi1: Fix improper uses of smp_mb__before_atomic()

In reply to Andrea Parri
Quoted 24 lines · Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_read() primitive.

Replace the barrier with an smp_mb().

Fixes 856cc4c237add ("IB/hfi1: Add the capability for reserved operations")
Cc Dennis Dalessandro <[email protected]>
Cc Mike Marciniszyn <[email protected]>
Cc Doug Ledford <[email protected]>
Cc Jason Gunthorpe <[email protected]>
---
 drivers/infiniband/sw/rdmavt/qp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/sw/rdmavt/qp.c +0 -0
index a34b9a2a32b60..b64fd151d31fb 100644

drivers/infiniband/sw/rdmavt/qp.c static inline int rvt_qp_is_avail( · line 1865

Quoted 3 lines
drivers/infiniband/sw/rdmavt/qp.c +0 -0
@@ -1863,11 +1863,11 @@ static inline int rvt_qp_is_avail(
 	u32 reserved_used;
 
 	/* see rvt_qp_wqe_unreserve() */

I see a completely bogus comment in rvf_op_wqe_unreserve(), referring to bogus comments makes this barrier bogus too.

drivers/infiniband/sw/rdmavt/qp.c static inline int rvt_qp_is_avail( · line 1870

Quoted 6 lines
drivers/infiniband/sw/rdmavt/qp.c +1 -2
-	smp_mb__before_atomic();
+	smp_mb();
 	reserved_used = atomic_read(&qp->s_reserved_used);
 	if (unlikely(reserved_op)) {
 		/* see rvt_qp_wqe_unreserve() */
-		smp_mb__before_atomic();

This was before, but there is nothing _after_ this. Which means this barrier was complete garbage anyway.

drivers/infiniband/sw/rdmavt/qp.c static inline int rvt_qp_is_avail( · line 1885

Quoted 10 lines
drivers/infiniband/sw/rdmavt/qp.c +2 -1
+		smp_mb();
 		if (reserved_used >= rdi->dparms.reserved_operations)
 			return -ENOMEM;
 		return 0;
@@ -1882,7 +1882,7 @@ static inline int rvt_qp_is_avail(
 		avail = slast - qp->s_head;
 
 	/* see rvt_qp_wqe_unreserve() */
-	smp_mb__before_atomic();
+	smp_mb();

Same as the first.

Quoted 3 lines
drivers/infiniband/sw/rdmavt/qp.c +0 -0
 	reserved_used = atomic_read(&qp->s_reserved_used);
 	avail =  avail - 1 -
 		(rdi->dparms.reserved_operations - reserved_used);
#24 lore raw
In reply to Andrea Parri
Quoted 8 lines · Andrea Parri

Hello!

A relatively common misuse of these barriers is to apply these to operations which are not read-modify-write operations, such as atomic_set() and atomic_read(); examples were discussed in [1].

This series attempts to fix those uses by (conservatively) replacing the smp_mb__{before,after}_atomic() barriers with full memory barriers.

I don't think blindly doing this replacement makes the code any better; much of the code you found is just straight up dodgy to begin with.

I think the people should mostly just consider this a bug report.

Also, remember a memory barrier without a coherent comment is most likely a bug anyway.

#13 lore raw

Re: [PATCH 4/5] ceph: fix improper use of smp_mb__before_atomic()

In reply to Peter Zijlstra
Quoted 15 lines · Peter Zijlstra

fs/ceph/super.h static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci, · line 544

Quoted 11 lines · Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic64_set() primitive.

Replace the barrier with an smp_mb().

fs/ceph/super.h +0 -1
@@ -541,7 +541,7 @@ static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci,
                                         long long release_count,
                                         long long ordered_count)
 {
-     smp_mb__before_atomic();

same

Quoted 4 lines
        /*
         * XXX: the comment that explain this barrier goes here.
         */

makes sure operations that setup readdir cache (update page cache and i_size) are strongly ordered with following atomic64_set.

Quoted 8 lines
Quoted 8 lines
fs/ceph/super.h +1 -0
+     smp_mb();
 
      atomic64_set(&ci->i_complete_seq[0], release_count);
      atomic64_set(&ci->i_complete_seq[1], ordered_count);

}
--
2.7.4

#25 lore raw
In reply to Peter Zijlstra
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Andrea Parri

Hello!

A relatively common misuse of these barriers is to apply these to operations which are not read-modify-write operations, such as atomic_set() and atomic_read(); examples were discussed in [1].

Quoted 7 lines
Quoted 2 lines

This series attempts to fix those uses by (conservatively) replacing the smp_mb__{before,after}_atomic() barriers with full memory barriers.

I don't think blindly doing this replacement makes the code any better; much of the code you found is just straight up dodgy to begin with.

I think the people should mostly just consider this a bug report.

Bug, misuse, patch, and rfc seem all appropriate to me in this context.

Quoted 2 lines

Also, remember a memory barrier without a coherent comment is most likely a bug anyway.

Right. Hopefully, the people in Cc: will want to shed some light about
this: I know what these smp_mb__{before,after}_atomic() can not do, but I can only guess (I won't!) what they are supposed to accomplish (e.g., which mem. accesses are being ordered, what are the matching barriers); maybe this can also justify the "conservative" approach presented here.

Andrea

#2 lore raw

Re: [PATCH 1/5] drm/msm: Fix improper uses of smp_mb__{before,after}_atomic()

In reply to Andrea Parri
Quoted 5 lines · Andrea Parri

These barriers only apply to the read-modify-write operations; in particular, they do not apply to the atomic_set() primitive.

Replace the barriers with smp_mb()s.

Quoted 13 lines
Fixes b1fc2839d2f92 ("drm/msm: Implement preemption for A5XX targets")
Cc Rob Clark <[email protected]>
Cc Sean Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jordan Crouse <[email protected]>

Rob, Sean, Jordan: any suggestions to move this patch forward?

Thanx,
Andrea

Quoted 24 lines
---
 drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +2 -2
index 3d62310a535fb..ee0820ee0c664 100644
@@ -39,10 +39,10 @@ static inline void set_preempt_state(struct a5xx_gpu *gpu,
 	 * preemption or in the interrupt handler so barriers are needed
 	 * before...
 	 */
-	smp_mb__before_atomic();
+	smp_mb();
 	atomic_set(&gpu->preempt_state, new);
 	/* ... and after*/
-	smp_mb__after_atomic();
+	smp_mb();
 }
 
 /* Write the most recent wptr for the given ring into the hardware */
Signature · 1 line
2.7.4

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

#5 lore raw

Re: [PATCH 2/5] bio: fix improper use of smp_mb__before_atomic()

In reply to Andrea Parri
Quoted 5 lines · Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_set() primitive.

Replace the barrier with an smp_mb().

Quoted 7 lines
Fixes dac56212e8127 ("bio: skip atomic inc/dec of ->bi_cnt for most use cases")
Cc Jens Axboe <[email protected]>

Jens: any suggestions to move this patch forward?

Thanx,
Andrea

Quoted 20 lines
---
 include/linux/bio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bio.h +1 -1
index e584673c18814..5becbafb84e8a 100644
@@ -224,7 +224,7 @@ static inline void bio_cnt_set(struct bio *bio, unsigned int count)
 {
 	if (count != 1) {
 		bio->bi_flags |= (1 << BIO_REFFED);
-		smp_mb__before_atomic();
+		smp_mb();
 	}
 	atomic_set(&bio->__bi_cnt, count);
 }
Signature · 1 line
2.7.4
#8 lore raw

Re: [PATCH 3/5] sbitmap: fix improper use of smp_mb__before_atomic()

In reply to Andrea Parri
Quoted 5 lines · Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_set() primitive.

Replace the barrier with an smp_mb().

Quoted 8 lines
Fixes 6c0ca7ae292ad ("sbitmap: fix wakeup hang after sbq resize")
Cc Jens Axboe <[email protected]>
Cc Omar Sandoval <[email protected]>

Jens, Omar: any suggestions to move this patch forward?

Thanx,
Andrea

Quoted 20 lines
---
 lib/sbitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sbitmap.c +1 -1
index 155fe38756ecf..4a7fc4915dfc6 100644
@@ -435,7 +435,7 @@ static void sbitmap_queue_update_wake_batch(struct sbitmap_queue *sbq,
 		 * to ensure that the batch size is updated before the wait
 		 * counts.
 		 */
-		smp_mb__before_atomic();
+		smp_mb();
 		for (i = 0; i < SBQ_WAIT_QUEUES; i++)
 			atomic_set(&sbq->ws[i].wait_cnt, 1);
 	}
Signature · 1 line
2.7.4
#14 lore raw

Re: [PATCH 4/5] ceph: fix improper use of smp_mb__before_atomic()

In reply to Yan, Zheng
Quoted 21 lines · Zheng
Quoted 15 lines · Peter Zijlstra

fs/ceph/super.h static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci, · line 544

Quoted 11 lines · Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic64_set() primitive.

Replace the barrier with an smp_mb().

fs/ceph/super.h +0 -1
@@ -541,7 +541,7 @@ static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci,
                                         long long release_count,
                                         long long ordered_count)
 {
-     smp_mb__before_atomic();

same

Quoted 4 lines
        /*
         * XXX: the comment that explain this barrier goes here.
         */
Quoted 2 lines

makes sure operations that setup readdir cache (update page cache and i_size) are strongly ordered with following atomic64_set.

Thanks for the suggestion, Yan.

To be clear: would you like me to integrate your comment and resend? any other suggestions?

Thanx,
Andrea

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
fs/ceph/super.h +1 -0
+     smp_mb();
 
      atomic64_set(&ci->i_complete_seq[0], release_count);
      atomic64_set(&ci->i_complete_seq[1], ordered_count);

}
--
2.7.4

#20 lore raw

Re: [PATCH 5/5] IB/hfi1: Fix improper uses of smp_mb__before_atomic()

In reply to Andrea Parri
Quoted 9 lines · Andrea Parri

Hi Mike,

Quoted 7 lines
Quoted 4 lines

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_read() primitive.

Replace the barrier with an smp_mb().

This is one of a couple of barrier issues that we are currently looking into.

Quoted 7 lines
Quoted 5 lines

See:

[PATCH for-next 6/9] IB/rdmavt: Add new completion inline

We will take a look at this one as well.

Thank you for the reference and for looking into this,

So, I'm planning to just drop this patch; or can I do something to help?

Please let me know.

Thanx,
Andrea

Quoted 2 lines

Andrea

Reviewed-by on v1 2/5
#6 lore raw

Re: [PATCH 2/5] bio: fix improper use of smp_mb__before_atomic()

In reply to Andrea Parri
Quoted 32 lines · Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_set() primitive.

Replace the barrier with an smp_mb().

Fixes dac56212e8127 ("bio: skip atomic inc/dec of ->bi_cnt for most use cases")
Cc Jens Axboe <[email protected]>
---
 include/linux/bio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bio.h +1 -1
index e584673c18814..5becbafb84e8a 100644
@@ -224,7 +224,7 @@ static inline void bio_cnt_set(struct bio *bio, unsigned int count)
 {
 	if (count != 1) {
 		bio->bi_flags |= (1 << BIO_REFFED);
-		smp_mb__before_atomic();
+		smp_mb();
 	}
 	atomic_set(&bio->__bi_cnt, count);
 }
Signature · 1 line
2.7.4

Looks fine,

Thanks,
Ming

Reviewed-by on v1 3/5
#9 lore raw

Re: [PATCH 3/5] sbitmap: fix improper use of smp_mb__before_atomic()

In reply to Andrea Parri
Quoted 33 lines · Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_set() primitive.

Replace the barrier with an smp_mb().

Fixes 6c0ca7ae292ad ("sbitmap: fix wakeup hang after sbq resize")
Cc Jens Axboe <[email protected]>
Cc Omar Sandoval <[email protected]>
---
 lib/sbitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sbitmap.c +1 -1
index 155fe38756ecf..4a7fc4915dfc6 100644
@@ -435,7 +435,7 @@ static void sbitmap_queue_update_wake_batch(struct sbitmap_queue *sbq,
 		 * to ensure that the batch size is updated before the wait
 		 * counts.
 		 */
-		smp_mb__before_atomic();
+		smp_mb();
 		for (i = 0; i < SBQ_WAIT_QUEUES; i++)
 			atomic_set(&sbq->ws[i].wait_cnt, 1);
 	}
Signature · 1 line
2.7.4

sbitmap_queue_update_wake_batch() won't be called in fast path, and the fix is correct too, so:

thanks,
Ming

#10 lore raw

Re: [PATCH 3/5] sbitmap: fix improper use of smp_mb__before_atomic()

Hi Ming,

Quoted 38 lines · Ming Lei
Quoted 33 lines · Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_set() primitive.

Replace the barrier with an smp_mb().

Fixes 6c0ca7ae292ad ("sbitmap: fix wakeup hang after sbq resize")
Cc Jens Axboe <[email protected]>
Cc Omar Sandoval <[email protected]>
---
 lib/sbitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sbitmap.c +1 -1
index 155fe38756ecf..4a7fc4915dfc6 100644
@@ -435,7 +435,7 @@ static void sbitmap_queue_update_wake_batch(struct sbitmap_queue *sbq,
 		 * to ensure that the batch size is updated before the wait
 		 * counts.
 		 */
-		smp_mb__before_atomic();
+		smp_mb();
 		for (i = 0; i < SBQ_WAIT_QUEUES; i++)
 			atomic_set(&sbq->ws[i].wait_cnt, 1);
 	}
Signature · 1 line
2.7.4

sbitmap_queue_update_wake_batch() won't be called in fast path, and the fix is correct too, so:

Quoted 1 line

Thank you for the review(s),

Andrea

Quoted 2 lines

thanks,
Ming

#15 lore raw

Re: [PATCH 4/5] ceph: fix improper use of smp_mb__before_atomic()

In reply to Andrea Parri
Quoted 22 lines · Andrea Parri
Quoted 21 lines · Zheng
Quoted 19 lines · Peter Zijlstra

fs/ceph/super.h static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci, · line 544

Quoted 11 lines · Andrea Parri

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic64_set() primitive.

Replace the barrier with an smp_mb().

fs/ceph/super.h +0 -1
@@ -541,7 +541,7 @@ static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci,
                                          long long release_count,
                                          long long ordered_count)
  {
-     smp_mb__before_atomic();

same

         /*
          * XXX: the comment that explain this barrier goes here.
          */
Quoted 8 lines
Quoted 2 lines

makes sure operations that setup readdir cache (update page cache and i_size) are strongly ordered with following atomic64_set.

Thanks for the suggestion, Yan.

To be clear: would you like me to integrate your comment and resend? any other suggestions?

Yes, please

Regards
Yan, Zheng

Quoted 13 lines

Thanx,
Andrea

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
fs/ceph/super.h +1 -0
+     smp_mb();
 
       atomic64_set(&ci->i_complete_seq[0], release_count);
       atomic64_set(&ci->i_complete_seq[1], ordered_count);

}
--
2.7.4

#16 lore raw

Re: [PATCH 4/5] ceph: fix improper use of smp_mb__before_atomic()

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
        /*
         * XXX: the comment that explain this barrier goes here.
         */

makes sure operations that setup readdir cache (update page cache and i_size) are strongly ordered with following atomic64_set.

Quoted 7 lines
Quoted 5 lines

Thanks for the suggestion, Yan.

To be clear: would you like me to integrate your comment and resend? any other suggestions?

Yes, please

Will do: I'll let the merge window close and send v2 on top of -rc1.

Thanks,
Andrea

#21 lore raw

Re: [PATCH 5/5] IB/hfi1: Fix improper uses of smp_mb__before_atomic()

In reply to Andrea Parri
Quoted 14 lines · Andrea Parri
Quoted 13 lines · Andrea Parri

Hi Mike,

Quoted 11 lines
Quoted 4 lines

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_read() primitive.

Replace the barrier with an smp_mb().

This is one of a couple of barrier issues that we are currently looking into.

See:

[PATCH for-next 6/9] IB/rdmavt: Add new completion inline

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

We will take a look at this one as well.

Thank you for the reference and for looking into this,

So, I'm planning to just drop this patch; or can I do something to help?

Please let me know.

Mike was looking into this, and I've got a handful of patches from him to review. He's unavailable for a while but if it's not included in the patches I've got we'll get something out shortly. So yes I think we can hold off on this patch for now. Thanks.

-Denny

#22 lore raw

Re: [PATCH 5/5] IB/hfi1: Fix improper uses of smp_mb__before_atomic()

Quoted 19 lines · Dennis Dalessandro
Quoted 18 lines · Andrea Parri
Quoted 16 lines · Andrea Parri

Hi Mike,

Quoted 5 lines
Quoted 4 lines

This barrier only applies to the read-modify-write operations; in particular, it does not apply to the atomic_read() primitive.

Replace the barrier with an smp_mb().

Quoted 7 lines

This is one of a couple of barrier issues that we are currently looking into.

See:

[PATCH for-next 6/9] IB/rdmavt: Add new completion inline

We will take a look at this one as well.

Thank you for the reference and for looking into this,

Quoted 8 lines
Quoted 3 lines

So, I'm planning to just drop this patch; or can I do something to help?

Please let me know.

Mike was looking into this, and I've got a handful of patches from him to review. He's unavailable for a while but if it's not included in the patches I've got we'll get something out shortly. So yes I think we can hold off on this patch for now. Thanks.

Thank you for the confirmation, Dennis. I'll hold off on this one.

Andrea