RE: [PATCH] USB: core: remove CONFIG_USB_DEBUG usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Greg Kroah-Hartman
...
> > ...
> > >  	/* Check that the pipe's type matches the endpoint's type */
> > >  	if (usb_pipetype(urb->pipe) != pipetypes[xfertype])
> >
> > It looks as though it ought to be possible to make that check:
> > 	if (unlikely(xfertype != urb->pipe->valid_xfertype))
> 
> You should almost never use unlikely() on your own, in a driver, as the
> compiler should make better code without it.  If you can provide numbers
> showing that this is faster, that would be great, otherwise I'll leave
> it alone.

The compiler has no information available to choose which side of the
conditional to statically predict as true.
At runtime the cpu's branch history might contain the information if the
code path has been executed recently.

Mispredicting branches can have a measurable performance penalty.
One of the reasons the netburst P4 were so bad is that it was (IIRC)
almost 40 clocks, and a lot of non-benchmark code has a lot of branches
that don't get statically predicted correctly and are in long linear
code paths.

Even on a simple cpu where a predicted taken branch takes 1 extra clock
and a mispredicted branch 3 extra clocks getting all the branches correctly
statically predicted can make a significant difference.

Even adding unlikely() isn't necessarily enough to force gcc to generate
correctly statically predicted code. With the following:
	if (unlikely(...)) {
		asm volatile ("# unlikely\n");
		continue;
	}
Without the asm statement gcc won't generate a branch down the file
to a jump back to teh top of the loop.

The netdev people now just how much it matters.
	
	David



--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux