summary refs log tree commit diff
path: root/arch/s390/lib
diff options
context:
space:
mode:
authorVineet Gupta <Vineet.Gupta1@synopsys.com>2021-08-05 12:14:08 -0700
committerArnd Bergmann <arnd@arndb.de>2021-08-14 13:07:42 +0200
commit8f76f9c46952659dd925c21c3f62a0d05a3f3e71 (patch)
tree804e531533b24f68c2841facdd8a6aef88997b19 /arch/s390/lib
parenta71bfc0079762b4d3cb36dcc5fe6c23c806cfc8c (diff)
downloadlinux-8f76f9c46952659dd925c21c3f62a0d05a3f3e71.tar.gz
bitops/non-atomic: make @nr unsigned to avoid any DIV
signed math causes generation of costlier instructions such as DIV when
they could be done by barrerl shifter.

Worse part is this is not caught by things like bloat-o-meter since
instruction length / symbols are typically same size.

e.g.

stock (signed math)
__________________

919b4614 <test_taint>:
919b4614:	div	r2,r0,0x20
                ^^^
919b4618:	add2	r2,0x920f6050,r2
919b4620:	ld_s	r2,[r2,0]
919b4622:	lsr	r0,r2,r0
919b4626:	j_s.d	[blink]
919b4628:	bmsk_s	r0,r0,0
919b462a:	nop_s

(patched) unsigned math
__________________

919b4614 <test_taint>:
919b4614:	lsr	r2,r0,0x5  @nr/32
                ^^^
919b4618:	add2	r2,0x920f6050,r2
919b4620:	ld_s	r2,[r2,0]
919b4622:	lsr	r0,r2,r0     #test_bit()
919b4626:	j_s.d	[blink]
919b4628:	bmsk_s	r0,r0,0
919b462a:	nop_s

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/s390/lib')
0 files changed, 0 insertions, 0 deletions