Skip to contentSkip to conversation

block: change to use atomic_inc_return_release()

RFC In review yalin wang 2 participants 3 messages Nov 17, 2015 Block layer

lore
Share & tools
lore

yalin wang

author
#0 lore raw

RFC 1/1 block: change to use atomic_inc_return_release()

Some arch define this atomic_inc_return_release() OP.

---
 block/bio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/bio.c +1 -2
index fbc558b..b251857 100644
@@ -310,8 +310,7 @@ static void bio_chain_endio(struct bio *bio, int error)
 static inline void bio_inc_remaining(struct bio *bio)
 {
 	bio->bi_flags |= (1 << BIO_CHAIN);
-	smp_mb__before_atomic();
-	atomic_inc(&bio->__bi_remaining);
+	atomic_inc_return_release(&bio->__bi_remaining);
 }
 
 /**
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 1 line · yalin wang

Some arch define this atomic_inc_return_release() OP.

That is a very vague commit message, you'll need a whole lot more than that... A commit message is supposed to describe the reason for the change. You provide no reason for the change.

block/bio.c static void bio_chain_endio(struct bio *bio, int error) · line 313

Quoted 11 lines
block/bio.c +1 -2
index fbc558b..b251857 100644
@@ -310,8 +310,7 @@ static void bio_chain_endio(struct bio *bio, int error)
  static inline void bio_inc_remaining(struct bio *bio)
  {
  	bio->bi_flags |= (1 << BIO_CHAIN);
-	smp_mb__before_atomic();
-	atomic_inc(&bio->__bi_remaining);
+	atomic_inc_return_release(&bio->__bi_remaining);

Are these equivalent? Where's the documentation for this primitive? The previous code ensured that we ordered the dec of the remaining count with the update of the flags.

Signature · 1 line
Jens Axboe
author
#2 lore raw
Quoted 8 lines · Jens Axboe
Quoted 1 line · yalin wang

Some arch define this atomic_inc_return_release() OP.

That is a very vague commit message, you'll need a whole lot more than that... A commit message is supposed to describe the reason for the change. You provide no reason for the change.

Quoted 14 lines

block/bio.c static void bio_chain_endio(struct bio *bio, int error) · line 313

Quoted 11 lines
block/bio.c +1 -2
index fbc558b..b251857 100644
@@ -310,8 +310,7 @@ static void bio_chain_endio(struct bio *bio, int error)
 static inline void bio_inc_remaining(struct bio *bio)
 {
 	bio->bi_flags |= (1 << BIO_CHAIN);
-	smp_mb__before_atomic();
-	atomic_inc(&bio->__bi_remaining);
+	atomic_inc_return_release(&bio->__bi_remaining);

Are these equivalent? Where's the documentation for this primitive? The previous code ensured that we ordered the dec of the remaining count with the update of the flags.

i just have a look at ARM64 implementation for this new atomic OP ,
but i don’t find doc in memory-barrier.txt . so i make this RFC for some response, atomic_inc_return_release() should have store_release() class memory barriers . in this example, smp_store_release() memory barrier is not enough ?
just make sure bi_flags update can been seen by other cores before update atomic counter. atomic_inc_return_{release,acquire,relax} OP seems newly add to kernel . But i don’t see much users in code .
Can it be used to replace lots of smp_mb__before_atomic() ?

Thanks