[lkml]   [2015]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH V6 03/10] USB: f81232: implement RX bulk-in ep
On Tue, Feb 17, 2015 at 10:06:07AM +0000, David Laight wrote:
> 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.

Yes, but remember that old patch that Andi did to actually check to see
if unlikely/likely mattered and was placed correctly? Turns out that
90% of the usages were wrong. So humans are horrible at using these
markings, so I will not accept them unless you can _prove_ it matters in
the code.

For a urb callback, that's not an issue at all, the usb callback is so
slow that you will almost never make a difference, sorry.

So again, don't do it in driver code unless you can prove it.


greg k-h

 \ /
  Last update: 2015-02-17 16:01    [W:0.033 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site