|
@@ -81,11 +81,14 @@ struct buffer_head {
|
|
|
/*
|
|
|
* macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
|
|
|
* and buffer_foo() functions.
|
|
|
+ * To avoid reset buffer flags that are already set, because that causes
|
|
|
+ * a costly cache line transition, check the flag first.
|
|
|
*/
|
|
|
#define BUFFER_FNS(bit, name) \
|
|
|
static __always_inline void set_buffer_##name(struct buffer_head *bh) \
|
|
|
{ \
|
|
|
- set_bit(BH_##bit, &(bh)->b_state); \
|
|
|
+ if (!test_bit(BH_##bit, &(bh)->b_state)) \
|
|
|
+ set_bit(BH_##bit, &(bh)->b_state); \
|
|
|
} \
|
|
|
static __always_inline void clear_buffer_##name(struct buffer_head *bh) \
|
|
|
{ \
|