Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4429530pxf; Tue, 16 Mar 2021 13:17:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoCW35MdFxHH5M/DVUjgp9BSCQ7fXqYmsbfHjDbpYzyhJLB+9Y2QTZ3EbYpjXn0qD/WDmU X-Received: by 2002:aa7:c3c4:: with SMTP id l4mr37429454edr.335.1615925822377; Tue, 16 Mar 2021 13:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615925822; cv=none; d=google.com; s=arc-20160816; b=BmOO5HWXh1h9QbCUTur2/C7gvv2uPvb5W/vyHvfBNZu767mgev9Zv47Tkj5TssRgwt vk8cvFfAu4swBHYb71D4f/vKPYBMoql+S+zaQ7CPm+iI33AKISmlkxD/DsnpH9zCBQOa H4QjijkI+rPFBkfS2kBjLbY5PusYxyd6iQRaufUmc0PtSxqneAkxPlCTxbDSD7UvGKHc R4o29NZlin2gZ/5fXrBkYAkar5YCM8nTIptIVi2s2kh3pZRWV1vUCZ55mEl9uFzBxdvr TMjeBGTk1BwerXmmFr2TRU6HLmGV50cYnoiCJWP7f72Rfb5pS6Qp8msBmNnktgMnjsaa dFIA== 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=E5YIclRPnmbAQSlm2dQsPNQY1hHptALuHatvpihSszA=; b=O3h64dmJVpOUag93Df6CW/XmDVdYkuCJLtYEmEmVIH59mNlnxZNIeQlZ8HbXYD4ndj F+LYueCBxblvdQ2tZg6h5x4xgiozhpifsdiHYtNl5a620+W/VtAOXg9BnMUJe/cHRA9i b1TqdDWAiModRqV+olgAj0vqBajb1BQdoZJHiOdnouFTB/+5UBvy5QkOnVGAPtZFytb8 uK32CTv2/NffpX2bFHa61D4CZEfgdGxnWVUnTGc82BdGtljaRLrAO78zR1cFw84Y8q1D irfBgSF13JkUQZPTbtmxL57D28cFRxbtjPfUGyipFHhhO7GStktkEMrb91cdI2xSN7fv gjGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QEfHV44C; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r18si14500374edw.69.2021.03.16.13.16.40; Tue, 16 Mar 2021 13:17:02 -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=@kernel.org header.s=k20201202 header.b=QEfHV44C; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230398AbhCPNFf (ORCPT + 99 others); Tue, 16 Mar 2021 09:05:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:41852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234502AbhCPNFR (ORCPT ); Tue, 16 Mar 2021 09:05:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0805A6505D; Tue, 16 Mar 2021 13:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615899917; bh=kor5HI4uVqpM15xlGlMQ3Vb/ab3YDAFb7vluRdukJEA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QEfHV44CdBP9Wq/ZcwBuFrlMhC8E88KuYYgwc+gWTmic4oiu/zFhQFfmWENNcPx1n wCod6XSv6D0MCq1SfWyMCj26ZFqQsIrr4XXeH6NFLxpymFS2+cJx9qsrIHBpKwyaHa C1pKYok//XXWRIZNRZT6NZ/6XJXhe7ZwnMRVEYYqjyGy9zbWsFlNyu3C5Wv+Jc0R+u /r8FCGLZIY8rzRPRpQ0uWtfkpEPAZWFS68Ri+eh0jhDsIEkrr9L0S1ih/oh6PDTJ2R k41D5fxz3adrRoKq1Tbf3yY1Be+WRR61U9+vMrSFDJYZRzDqoohzAdgy8QvPbJYR5Y sXOFFQE1yd8iw== Date: Tue, 16 Mar 2021 14:05:14 +0100 From: Frederic Weisbecker To: Peter Zijlstra 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: <20210316130514.GB639918@lothringen> 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 16, 2021 at 01:28:01PM +0100, Peter Zijlstra wrote: > 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 ;-) Good point! I'll check the asm diff to see if that really does what we want. I expect it will. Thanks. > > 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) > { > >