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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 17 Feb 2015 10:06:07 +0000
From:	David Laight <David.Laight@...LAB.COM>
To:	'Greg KH' <gregkh@...uxfoundation.org>,
	Peter Hung <hpeter@...il.com>
CC:	"johan@...nel.org" <johan@...nel.org>,
	"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"tom_tsai@...tek.com.tw" <tom_tsai@...tek.com.tw>,
	"peter_hong@...tek.com.tw" <peter_hong@...tek.com.tw>,
	Peter Hung <hpeter+linux_kernel@...il.com>
Subject: RE: [PATCH V6 03/10] USB: f81232: implement RX bulk-in ep

From: Greg KH
> > +	for (i = 0 ; i < urb->actual_length ; i += 2) {
> > +		tty_flag = TTY_NORMAL;
> > +
> > +		if (unlikely(data[i+0] & UART_LSR_BRK_ERROR_BITS)) {
> 
> Never use unlikely() unless you can prove that it actually matters if
> you use it.  Hint, it's almost impossible to prove, so don't use it, the
> compiler and processor look-ahead is almost smarter than we are.

That just isn't true.

The compiler cannot know the actual control flow - so cannot correctly
arrange the code so that the branches are statically predicted
correctly for the required path (usually the most common path).

There are a lot of places where a few extra clocks for a mispredicted
branch don't really matter, and even in very hot paths where it does
matter it can be quite difficult to get the compiler to optimise the
branches 'correctly' - you can need to add asm comments in order to
generate non-empty code blocks.

In addition unlikely() is also a note to the human reader.

I did a lot of work adding likely/unlikely to some code in order
to minimise the 'worst case' code path. I got there, but some
parts were initially non-intuitive.

	david

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ