Commit 2c68f6dc authored by Jens Axboe's avatar Jens Axboe

block: shrink struct bio down to 2 cache lines again

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: default avatarJens Axboe <axboe@fb.com>
parent b7c44ed9
...@@ -306,17 +306,17 @@ static inline void bio_cnt_set(struct bio *bio, unsigned int count) ...@@ -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) 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) 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) 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 { enum bip_flags {
......
...@@ -46,14 +46,14 @@ struct bvec_iter { ...@@ -46,14 +46,14 @@ struct bvec_iter {
struct bio { struct bio {
struct bio *bi_next; /* request queue link */ struct bio *bi_next; /* request queue link */
struct block_device *bi_bdev; struct block_device *bi_bdev;
unsigned long bi_flags; /* status, command, etc */ unsigned int bi_flags; /* status, command, etc */
int bi_error;
unsigned long bi_rw; /* bottom bits READ/WRITE, unsigned long bi_rw; /* bottom bits READ/WRITE,
* top bits priority * top bits priority
*/ */
struct bvec_iter bi_iter; struct bvec_iter bi_iter;
int bi_error;
/* Number of segments in this BIO after /* Number of segments in this BIO after
* physical address coalescing is performed. * physical address coalescing is performed.
*/ */
...@@ -134,7 +134,7 @@ struct bio { ...@@ -134,7 +134,7 @@ struct bio {
*/ */
#define BIO_POOL_BITS (4) #define BIO_POOL_BITS (4)
#define BIO_POOL_NONE ((1UL << BIO_POOL_BITS) - 1) #define BIO_POOL_NONE ((1UL << BIO_POOL_BITS) - 1)
#define BIO_POOL_OFFSET (BITS_PER_LONG - BIO_POOL_BITS) #define BIO_POOL_OFFSET (32 - BIO_POOL_BITS)
#define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET) #define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET)
#define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET) #define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment