Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp7846168ybc; Fri, 29 Nov 2019 02:01:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwUDh5ufcbprFrc6+d+yI9UxPAC6o8GpIhP1gDEs6krouRD/SvJL8lRli2301DC0Z2CjqMG X-Received: by 2002:a50:ef17:: with SMTP id m23mr43741669eds.81.1575021666961; Fri, 29 Nov 2019 02:01:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575021666; cv=none; d=google.com; s=arc-20160816; b=r8CMvtDYisiQxzBV2+W30pXOoPhmJYw27i1lMVu0TN/kTdNFx6eAHq46xy3VfSuPvN rjRA4GeREPQwYZkTGrX64bksEmcGv6c8jfq3mhiZ7JM/DHvyGuVpFu84G2lI/nhWOq/N LVITJCQBGjr9nQWOqe0srMfwvIcFSpCXBgc4H41rM+8g+GkYvGFkjCEZxEJLRpRSZd7i dTBbPyOH47McbKV+TeOuRqfFVxAI4UFEQ25X7JhjxuQbC+e3J2yJM01zaE8yxv3a/Q+J Ng083uR2uh1HLY2uU3H9n1fdPCrrSEgNV6fvIh3o1U2zGDbtxzloV9pUguapZwE91dwp 5PUA== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=Km20po5TZdNC5CKCBapxRVgMQMG0j3i2BmSxTqdN0ko=; b=I5Eaqz0Yh3l2o2Ai+xXnBbCxBqEmLS5O9vPt6T2iwfRdRjrXrhiM6C4qQNJRX8y4q7 O30jyktH2iUcADoh8AlGLr9r0eHCUET96auW6Bj1P6gOV8X+bEN8pqzdr2H+cdlUmZI0 cvNA23GO1IajNPUvMQfm51d8O28UW+9HP4w6ORmMLM1nh4f97E9hGma8czCgIxqNjpUA jURy/HDMJpGe5y1lORWNH56jl0OhsNqlxut8G2mhzA4r8p5tUaKfJaUfVO38auIQNBi7 m7BL1sy09ZU+Q0WNVtZ8TEefg0k7Gj6/qIPFdm1mZXPFHBtuwAmjxWCS/WlIYtBEPVrU Zvnw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc12si5894336edb.12.2019.11.29.02.00.42; Fri, 29 Nov 2019 02:01:06 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726780AbfK2J72 (ORCPT + 99 others); Fri, 29 Nov 2019 04:59:28 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:48463 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726143AbfK2J72 (ORCPT ); Fri, 29 Nov 2019 04:59:28 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iad3K-0002Qp-P6; Fri, 29 Nov 2019 10:59:06 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 449691C2116; Fri, 29 Nov 2019 10:59:06 +0100 (CET) Date: Fri, 29 Nov 2019 09:59:06 -0000 From: "tip-bot2 for Zhenzhong Duan" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/clock: Use static_branch_likely() with sched_clock_running Cc: Zhenzhong Duan , "Steven Rostedt (VMware)" , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , bsegall@google.com, dietmar.eggemann@arm.com, juri.lelli@redhat.com, mgorman@suse.de, vincent.guittot@linaro.org, Ingo Molnar , x86 , LKML In-Reply-To: <1574843848-26825-1-git-send-email-zhenzhong.duan@oracle.com> References: <1574843848-26825-1-git-send-email-zhenzhong.duan@oracle.com> MIME-Version: 1.0 Message-ID: <157502154611.21853.4555592493571232440.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/urgent branch of tip: Commit-ID: c5105d764e0214bcc4c6d40d7ba231d01b2e9dda Gitweb: https://git.kernel.org/tip/c5105d764e0214bcc4c6d40d7ba231d01b2e9dda Author: Zhenzhong Duan AuthorDate: Wed, 27 Nov 2019 16:37:28 +08:00 Committer: Ingo Molnar CommitterDate: Fri, 29 Nov 2019 08:10:54 +01:00 sched/clock: Use static_branch_likely() with sched_clock_running sched_clock_running is enabled early at bootup stage and never disabled. So hint that to the compiler by using static_branch_likely() rather than static_branch_unlikely(). The branch probability mis-annotation was introduced in the original commit that converted the plain sched_clock_running flag to a static key: 46457ea464f5 ("sched/clock: Use static key for sched_clock_running") Steve further notes: | Looks like the confusion was the moving of the "!": | | - if (unlikely(!sched_clock_running)) | + if (!static_branch_unlikely(&sched_clock_running)) | | Where, it was unlikely that !sched_clock_running would be true, but | because the "!" was moved outside the "unlikely()" it makes the test | "likely()". That is, if we added an intermediate step, it would have | been: | | if (!likely(sched_clock_running)) | | which would have prevented the mistake that this patch fixes. [ mingo: Edited the changelog. ] Signed-off-by: Zhenzhong Duan Reviewed-by: Steven Rostedt (VMware) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: bsegall@google.com Cc: dietmar.eggemann@arm.com Cc: juri.lelli@redhat.com Cc: mgorman@suse.de Cc: vincent.guittot@linaro.org Link: https://lkml.kernel.org/r/1574843848-26825-1-git-send-email-zhenzhong.duan@oracle.com Signed-off-by: Ingo Molnar --- kernel/sched/clock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index 1152259..12bca64 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -370,7 +370,7 @@ u64 sched_clock_cpu(int cpu) if (sched_clock_stable()) return sched_clock() + __sched_clock_offset; - if (!static_branch_unlikely(&sched_clock_running)) + if (!static_branch_likely(&sched_clock_running)) return sched_clock(); preempt_disable_notrace(); @@ -393,7 +393,7 @@ void sched_clock_tick(void) if (sched_clock_stable()) return; - if (!static_branch_unlikely(&sched_clock_running)) + if (!static_branch_likely(&sched_clock_running)) return; lockdep_assert_irqs_disabled(); @@ -460,7 +460,7 @@ void __init sched_clock_init(void) u64 sched_clock_cpu(int cpu) { - if (!static_branch_unlikely(&sched_clock_running)) + if (!static_branch_likely(&sched_clock_running)) return 0; return sched_clock();