Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4376150pxf; Tue, 16 Mar 2021 11:52:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCK0ZjYd/RRu4X4t6+dQz2PWJAdyNvhzamAQ1u79fkpWXK4/OPEC5Wt4fQ06C1MRgDXq+z X-Received: by 2002:a05:6402:c1:: with SMTP id i1mr37340732edu.315.1615920762155; Tue, 16 Mar 2021 11:52:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615920762; cv=none; d=google.com; s=arc-20160816; b=px/N1xulcHZuF+seWCiKHpKX6+3jH+s/E2rddGVxtqQEjCSdZWdwTYfWEVoLjmRxxn 8EcR+N0QY1tT+GdiLE8d4C+hwqZ047oFJ0aOfXuNfDuZ5/6O0IiVDD4HVY4HJaxUqzE3 8dBaXqJEzaaLGzObJ6aPKcZ7D9gRIS0tE90SjIiu19ZR+EOkYKFrAbeP59n1zVIe+k5i IBk7XcYazPFzK2BGH5kaB6bDK27RcLtCGdB3P+fKyibI1WSAT6z2JOePWmhng51YRtI/ p+MDj/2tf7yi9bg04XXBcmcm1/m9HAekGbURF6pYly1f0LQBhiY8hskJOpTse+bJFKTh it/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hwHlWbWTEczqDkBikUULbYZy11mMgXktJCLbUnZWv88=; b=0oG7pNj8/5TkC4B4lICwzqaYOiibhj6cqlpJ4spX3c12EPc/0aa/HmXXPP7j6U7dfC PkZuSgPWDYVHPsSm5YweTowwBXrIBwzUITOWH4syZ/ZtNvJSRTMchmk+xKexFf6KwE8O 6jMv/yDIITq0t9MTHRc7qRZA+wqB9BIrtX2gNrdtBnH6cvHhiQzqeEWsYrZ1a4uMgLKi 1CIiK8WnLV1stSBAxh2qLupqp3dR0qbA5qxInjddOoJjOxpyveQ+0wxUjP2gNbdnKtBE 9K9fNIeLRcucm/zBY7LwV87e1pFosBKqW5Jpm6wTdJlzQGvf9jMLlUYyZycLvwMMTf4a VMJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=QQ2CNxaC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y23si14911975ejp.249.2021.03.16.11.52.19; Tue, 16 Mar 2021 11:52:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=QQ2CNxaC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231481AbhCPM2k (ORCPT + 99 others); Tue, 16 Mar 2021 08:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231480AbhCPM2T (ORCPT ); Tue, 16 Mar 2021 08:28:19 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DDD4C06174A for ; Tue, 16 Mar 2021 05:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=hwHlWbWTEczqDkBikUULbYZy11mMgXktJCLbUnZWv88=; b=QQ2CNxaCMQej97kooYigwHt5/u FTm4LYOJrMWENwmvyYrcvxVn6FOpE5NrUvITEFqllBWkgEdfx9VJHQnyrkhlyAqIGf/k3cobmG9NO Zoq//bujk0NHqBWeficotFHNyJuoIAbNvVYdJz3T3v8w2fOUuwKznxsbNiXxAeQg1M8BKQQRHu/aV DPfgzG76yCGYi5sn/wRgswq9UhqAyY658nYWA22XQChe1fOnhq6vDBlvSlRdrISIw7e9bF0pPmJz4 m8qaJ+SlVyEG0NFqUaph3CWUMLeJn1WJHOKoSIcqY6BCufqryIxcA/yWlbCR7+L6Sb7uJ94Dq1OS5 DiwPHFGA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lM8nq-000hpa-C8; Tue, 16 Mar 2021 12:28:02 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 818843012DF; Tue, 16 Mar 2021 13:28:01 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 31E1C20B05D7A; Tue, 16 Mar 2021 13:28:01 +0100 (CET) Date: Tue, 16 Mar 2021 13:28:01 +0100 From: Peter Zijlstra To: Frederic Weisbecker Cc: Thomas Gleixner , LKML , "Rafael J . Wysocki" , Ti Zhou , Yunfeng Ye , "Paul E . McKenney" , Marcelo Tosatti , Ingo Molnar Subject: Re: [PATCH 02/10] tick/nohz: Add tick_nohz_full_this_cpu() Message-ID: References: <20210311123708.23501-1-frederic@kernel.org> <20210311123708.23501-3-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210311123708.23501-3-frederic@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 11, 2021 at 01:37:00PM +0100, Frederic Weisbecker wrote: > Optimize further the check for local full dynticks CPU. Testing directly > tick_nohz_full_cpu(smp_processor_id()) is suboptimal because the > compiler first fetches the CPU number and only then processes the > static key. > > It's best to evaluate the static branch before anything. Or you do tricky things like this ;-) diff --git a/include/linux/tick.h b/include/linux/tick.h index 7340613c7eff..bd4a6b055b80 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -185,13 +185,12 @@ static inline bool tick_nohz_full_enabled(void) return tick_nohz_full_running; } -static inline bool tick_nohz_full_cpu(int cpu) -{ - if (!tick_nohz_full_enabled()) - return false; - - return cpumask_test_cpu(cpu, tick_nohz_full_mask); -} +#define tick_nohz_full_cpu(_cpu) ({ \ + bool __ret = false; \ + if (tick_nohz_full_enabled()) \ + __ret = cpumask_test_cpu((_cpu), tick_nohz_full_mask); \ + __ret; \ +}) static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask) {