lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Sun,  5 Jun 2016 19:09:34 +0200
From:	Denys Vlasenko <dvlasenk@...hat.com>
To:	Ingo Molnar <mingo@...nel.org>
Cc:	Denys Vlasenko <dvlasenk@...hat.com>,
	Christoph Hellwig <hch@...radead.org>,
	Al Viro <viro@...iv.linux.org.uk>, linux-kernel@...r.kernel.org
Subject: [PATCH RESEND] bufferhead: Force inlining of put_bh and get_bh

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@...hat.com>
CC: Christoph Hellwig <hch@...radead.org>
CC: Al Viro <viro@...iv.linux.org.uk>
CC: linux-kernel@...r.kernel.org
---
 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ