Skip to contentSkip to conversation

why don't unlock_buffer call directly clear_and_wake_up_bit?

DISCUSSION shuo chen 2 participants 3 messages Mar 21 – May 19

lore
Share & tools
lore

shuo chen

author
#0 lore raw

The unlock_buffer and clear_and_wake_up_bit call same the three function in the same sequence:
1.clear_bit_unlock
2.smp_mb__after_atomic
3.wake_up_bit

So why don't unlock_buffer write the fllowing:
void unlock_buffer(struct buffer_head *bh)

{
	clear_and_wake_up_bit(BH_Lock,&bh->b_state);
}

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

#1 lore raw
Quoted 10 lines · shuo chen

The unlock_buffer and clear_and_wake_up_bit call same the three function in the same sequence:
1.clear_bit_unlock
2.smp_mb__after_atomic
3.wake_up_bit

So why don't unlock_buffer write the fllowing:
void unlock_buffer(struct buffer_head *bh)

{
	clear_and_wake_up_bit(BH_Lock,&bh->b_state);
}

Probably not the answer you want, but the unlock_buffer() has been written the way it is back in fc9b52cd8f5f4, in 2008.

And the clear_and_wake_up_bit() function has been introduced only in 8236b0ae31c83, in 2018 (10 years later).

So, the root answer to your question is: the function didn't exist to be used back then.

Judging from the commit message at 8236b0ae31c83 I would make the educated guess that they are semantically identical, but I don't have enough knowledge to make such a claim firmly.

Maybe the semantics is the same, order doesn't matter and everyone just missed it. But maybe nobody changed because order changes semantics, I don't know.

---
Sincerely,
Agatha Isabelle Moreira
C Developer | agatha.dev
Sourcehut: https://sr.ht/~devlavender/

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

#2 lore raw
Quoted 7 lines · Agatha Isabelle Moreira

Judging from the commit message at 8236b0ae31c83 I would make the educated guess that they are semantically identical, but I don't have enough knowledge to make such a claim firmly.

Maybe the semantics is the same, order doesn't matter and everyone just missed it. But maybe nobody changed because order changes semantics, I don't know.

Ohhh, I looked at the source right after sending.

The semantics is definetely the same because that's what clear_and_wake_up_bit() does, literally. So yeah, the reason is 100%
sure: the function didn't exist when unlock_buffer() was written.

---
Sincerely,
Agatha Isabelle Moreira
C Developer | agatha.dev
Sourcehut: https://sr.ht/~devlavender/

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies