block: shrink struct bio down to 2 cache lines again
authorJens Axboe <axboe@fb.com>
Tue, 28 Jul 2015 19:14:32 +0000 (13:14 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 29 Jul 2015 14:55:25 +0000 (08:55 -0600)
Commit bcf2843b3f8f added ->bi_error to cleanup the error passing
for struct bio, but that ended up adding 4 bytes and a 4 byte hole
to the size of struct bio. For a clean config, that bumped it from
128 bytes, to 136 bytes, on x86-64.

The ->bi_flags member is currently an unsigned long, but it fits
easily within an int. Change it to an unsigned int, adjust the
the pool offset code, and move ->bi_error into the new hole. Then
we end up with a 128 byte bio again.

Change the bio flag set/clear to use cmpxchg to ensure we don't
lose any flags when manipulating them.

Signed-off-by: Jens Axboe <axboe@fb.com>
include/linux/bio.h
include/linux/blk_types.h

index 986e6e1..b7892a1 100644 (file)
@@ -306,17 +306,17 @@ static inline void bio_cnt_set(struct bio *bio, unsigned int count)
 
 static inline bool bio_flagged(struct bio *bio, unsigned int bit)
 {
-       return (bio->bi_flags & (1UL << bit)) != 0;
+       return (bio->bi_flags & (1U << bit)) != 0;
 }
 
 static inline void bio_set_flag(struct bio *bio, unsigned int bit)
 {
-       bio->bi_flags |= (1UL << bit);
+       bio->bi_flags |= (1U << bit);
 }
 
 static inline void bio_clear_flag(struct bio *bio, unsigned int bit)
 {
-       bio->bi_flags &= ~(1UL << bit);
+       bio->bi_flags &= ~(1U << bit);
 }
 
 enum bip_flags {
Simple merge