[PATCH RESEND] bufferhead: Force inlining of put_bh and get_bh
From: Denys Vlasenko
Date: Sun Jun 05 2016 - 13:09:53 EST
With both gcc 4.7.2 and 4.9.2, sometimes gcc mysteriously doesn't inline
very small functions we expect to be inlined. See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66122
With this .config:
http://busybox.net/~vda/kernel_config_OPTIMIZE_INLINING_and_Os,
get_bh() gets deinlined 32 times, put_bh() gets deinlined 18 times
with gcc-4.7.2, with the following disassembly:
<get_bh>:
55 push %rbp
48 89 e5 mov %rsp,%rbp
f0 ff 47 60 lock incl 0x60(%rdi)
5d pop %rbp
c3 retq
<put_bh>:
55 push %rbp
48 89 e5 mov %rsp,%rbp
f0 ff 4f 60 lock decl 0x60(%rdi)
5d pop %rbp
c3 retq
This patch fixes this via s/inline/__always_inline/.
This decreases vmlinux by about 5 kbytes.
text data bss dec hex filename
88197239 19905240 36421632 144524111 89d434f vmlinux.before
88192119 19905240 36421632 144518991 89d2f4f vmlinux
Signed-off-by: Denys Vlasenko <dvlasenk@xxxxxxxxxx>
CC: Christoph Hellwig <hch@xxxxxxxxxxxxx>
CC: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
CC: linux-kernel@xxxxxxxxxxxxxxx
---
include/linux/buffer_head.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 50ccd04..04a4e2d 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -270,12 +270,12 @@ static inline void attach_page_buffers(struct page *page,
set_page_private(page, (unsigned long)head);
}
-static inline void get_bh(struct buffer_head *bh)
+static __always_inline void get_bh(struct buffer_head *bh)
{
atomic_inc(&bh->b_count);
}
-static inline void put_bh(struct buffer_head *bh)
+static __always_inline void put_bh(struct buffer_head *bh)
{
smp_mb__before_atomic();
atomic_dec(&bh->b_count);
--
1.8.1.4