[lkml]   [2017]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] schedule: use unlikely()

On Sat, 25 Nov 2017, Greg KH wrote:

> On Mon, Nov 13, 2017 at 02:00:45PM -0500, Mikulas Patocka wrote:
> > A small patch for schedule(), so that the code goes straght in the common
> > case.
> >
> > Signed-off-by: Mikulas Patocka <>
> Was this a measurable difference? If so, great, please provide the
> numbers and how you tested in the changelog. If it can't be measured,
> then it is not worth it to add these markings

It is much easier to make microoptimizations (such as using likely() and
unlikely()) than to measure their effect.

If a programmer were required to measure performance every time he uses
likely() or unlikely() in his code, he wouldn't use them at all.

> as the CPU/compiler almost always knows better.
> thanks,
> greg k-h

The compiler assumes that pointers are usually not NULL - but in this
case, they are usually NULL. The compiler can't know better (unless
profile feedback is used).


 \ /
  Last update: 2017-11-28 01:06    [W:0.076 / U:0.384 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site