From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3A60C433E9 for ; Tue, 16 Mar 2021 12:29:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62AD96503C for ; Tue, 16 Mar 2021 12:29:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231511AbhCPM2r (ORCPT ); Tue, 16 Mar 2021 08:28:47 -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) {