Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1943060imu; Tue, 6 Nov 2018 06:46:31 -0800 (PST) X-Google-Smtp-Source: AJdET5eRSXv2JYl2Ra4WLTSxDH/dHHvfIhKHkIBp78SOjoBTKXsB+MqJVdn0Opx1DF3LvtySsZMv X-Received: by 2002:a17:902:9698:: with SMTP id n24-v6mr27474791plp.9.1541515591930; Tue, 06 Nov 2018 06:46:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541515591; cv=none; d=google.com; s=arc-20160816; b=u6k9I0lVYNtXSlGbwdjl+J8pqu2fKvMhtYmcPQHQm6k9/iPjEVi1anYMdAFUEbXjSq jFGSYSEvknye+qbgrj4Fs2zbTsjRDFH6Sw9HYQy3YFotQ7heR6HGgxtrfwTgNS6O0LTa i/u5l6IeaB3l1souBhNb3eqBUUmxRq8P40pI+k7HBAd26t5C0SuGxMc73+N0xfsVPkka 1AS4vk+8U1OH648ysnHXbCxWQk8dQi4mwTqkHF60x+g/8EP/HNahwU0yDcGHGHg2OoUU FcJ4wtpWmQpX+LHZq47PD6bYTVdwh2X9M2nXCo06O11GMc2SiSdgG4la6IyKYEtpC0tN KjwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6NXd9qwMyRlbaHtea73bJTHJH7mHB9FPKqKUB8aptUE=; b=fCBZZusyOZC+j5BuXo5tZXGwchVl20Kaf+zSoT0jbc/u1sqtcoj5cLL3ViRWI2kHZA KtFv86K6WW7s+XpFaReMokd+OjStzHbstbWRTSobjfW1HkDjBBE7DSkIU5lzZ5jXc1nL FTRlveuWDjAoQ/Fp9b8jsqKijC51hrlrtEQR2S7SiyfQqJnEQylC+gI9MIe2AfdJHQLW CfFtC2gHc6Y06BzYNUrAmg/rIA3gbmgzpRH1WOQnxAfRa1dynCePRPMd7qEdwaP06tem C2BxXIt7Js9ZEhZSOopZfT/xD7juvGyq0VdY4EnySBwSHVte5pHcRz+oqiL3jQzlAhKP msaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=smP6Twdj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i63si21584141pge.515.2018.11.06.06.46.08; Tue, 06 Nov 2018 06:46:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=smP6Twdj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730725AbeKGAJX (ORCPT + 99 others); Tue, 6 Nov 2018 19:09:23 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:45525 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729642AbeKGAJX (ORCPT ); Tue, 6 Nov 2018 19:09:23 -0500 Received: by mail-qk1-f193.google.com with SMTP id d135so18486668qkc.12 for ; Tue, 06 Nov 2018 06:43:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=6NXd9qwMyRlbaHtea73bJTHJH7mHB9FPKqKUB8aptUE=; b=smP6Twdj6W2ehiTrm2WMualq7rTvxtN77grJAXzoN4TYzvBHihLVLU7YMjDT+7ttaM YQNsfcP1CIMMgRKlpkoKTfonbj4XKK13hca6FcS4D1bCw20+o8EWI+qB3bt9APskekGT 010QAI5RgeRUtcSRfy4SxClCHTUBUj18oVMkEuWCvg4WUV9d11f2vv1MgMhIPExsqFkH k5QdajDAcFlMkoZiPORw0YzMm/3aczdJROyoXhsdYLcosCncNh5i2lSOdQ7Y3d5YzKND 5Peyw8rTbd7vmEbIQZxgMRS5LIcelPcuKYLn4s8Dcnb62dNUJm9CiMXv8BQhTqDsY9Fi xWIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6NXd9qwMyRlbaHtea73bJTHJH7mHB9FPKqKUB8aptUE=; b=EHySLBvJJWovwoAQUCs4QrAx0b1tQnf3QjKtG+17K7t1rteRRZOrnwBkPBpIB9J0CM ZJgia4+81gP0Xk3cDo+uaWmGE+YIHHjRBE4JYtQynm3GLa9PEbivQ1ck8q/zyF/1hGFJ ycrAt/akQAxA+AgFPG35MHWgxN1lk/tvPmFvLZpTR/8DfzxnsdVgRgDF34uR6cVn97Zr Mk4+wYlepubarSoSIWTE0VEFHOKCHT4aY+6jMt6JNsoOg7RzHuc1gJnrVhdiD7glaF9B RG2PLRzRLphiISYv5dkyHVk70uU4RdCD4tZwOBfD1gz8AGZS5RcgCYEFq/qKlMzVUgpQ RkuQ== X-Gm-Message-State: AGRZ1gIFtd38pbs7RANLKEPrb6UMuoBmmRs7vp3Isr9BseQvGyv9ZSwj 9Ba7EtienftC+l6nG4zkTZ4QK+8LSESf+D5FkrY= X-Received: by 2002:a37:3892:: with SMTP id f140mr10261801qka.214.1541515430574; Tue, 06 Nov 2018 06:43:50 -0800 (PST) MIME-Version: 1.0 References: <20181106134630.29591-1-smuchun@gmail.com> In-Reply-To: From: Muchun Song Date: Tue, 6 Nov 2018 22:43:39 +0800 Message-ID: Subject: Re: [PATCH] driver core: Add branch prediction hints in really_probe() To: rafael@kernel.org Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rafael, If we want the driver core to test driver remove functions, we can enable CONFIG_DEBUG_TEST_DRIVER_REMOVE. This option is just for testing it. So, in most cases, the option is disabled and the if condition is false. So I think we can add an unlikely() to it. Rafael J. Wysocki =E4=BA=8E2018=E5=B9=B411=E6=9C=886=E6= =97=A5=E5=91=A8=E4=BA=8C =E4=B8=8B=E5=8D=8810:30=E5=86=99=E9=81=93=EF=BC=9A > > On Tue, Nov 6, 2018 at 2:47 PM Muchun Song wrote: > > > > If condition is false in most cases. So, add an unlikely() to the if > > condition, so that the optimizer assumes that the condition is false. > > > > Signed-off-by: Muchun Song > > Have you measured the practical impact of this patch in any way? > > > --- > > drivers/base/dd.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/base/dd.c b/drivers/base/dd.c > > index 169412ee4ae8..8eba453c4e5d 100644 > > --- a/drivers/base/dd.c > > +++ b/drivers/base/dd.c > > @@ -450,7 +450,7 @@ static int really_probe(struct device *dev, struct = device_driver *drv) > > bool test_remove =3D IS_ENABLED(CONFIG_DEBUG_TEST_DRIVER_REMOVE= ) && > > !drv->suppress_bind_attrs; > > > > - if (defer_all_probes) { > > + if (unlikely(defer_all_probes)) { > > /* > > * Value of defer_all_probes can be set only by > > * device_defer_all_probes_enable() which, in turn, wil= l call > > @@ -508,7 +508,7 @@ static int really_probe(struct device *dev, struct = device_driver *drv) > > goto probe_failed; > > } > > > > - if (test_remove) { > > + if (unlikely(test_remove)) { > > test_remove =3D false; > > > > if (dev->bus->remove) > > -- > > 2.17.1 > >