From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753487AbdK1AFZ (ORCPT ); Mon, 27 Nov 2017 19:05:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49948 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753090AbdK1AFY (ORCPT ); Mon, 27 Nov 2017 19:05:24 -0500 Date: Mon, 27 Nov 2017 19:05:22 -0500 (EST) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Greg KH cc: Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: Re: [PATCH] schedule: use unlikely() In-Reply-To: <20171125085644.GA1843@kroah.com> Message-ID: References: <20171125085644.GA1843@kroah.com> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 28 Nov 2017 00:05:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). Mikulas