It is running now under 2.0.0 on my computer, but the relevent code is
unchanged in 2.0.27, so the patch should apply cleanly. In a wildly
inacurate test of a heavily write-dependent application, the system
time improved by an apparent 5-10%.
comments are appreciated.
--- fs/buffer.c.original Tue Apr 1 21:15:32 1997
+++ fs/buffer.c Tue Apr 1 21:20:52 1997
@@ -1023,21 +1023,29 @@
* to be IRQ-safe here (but note that interrupts only _add_ to the
* reuse_list, never take away. So we don't need to worry about the
* reuse_list magically emptying).
+ *
+ * Changed the code to copy out the list at the beginning instead of
+ * locking it for every entry. This could be made into a while loop, but
+ * that doesn't seem to have much purpose, since this code is called
+ * every time we want a buffer.
*/
static inline void recover_reusable_buffer_heads(void)
{
if (reuse_list) {
+ struct buffer_head *head;
struct buffer_head *bh;
unsigned long flags;
save_flags(flags);
- do {
- cli();
- bh = reuse_list;
- reuse_list = bh->b_next_free;
- restore_flags(flags);
+ cli();
+ head = reuse_list;
+ reuse_list = NULL;
+ restore_flags(flags);
+ while (head) {
+ bh = head;
+ head = bh->b_next_free;
put_unused_buffer_head(bh);
- } while (reuse_list);
+ }
}
}