Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp449639pxy; Wed, 5 May 2021 06:14:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKJ791XV8QVcXpzmUlwDrcBZldTlPf3YutEv4b5tRq/sVKknPLYdzSBqrvdMUvPxrdJNRY X-Received: by 2002:a05:6402:518f:: with SMTP id q15mr2508485edd.345.1620220496720; Wed, 05 May 2021 06:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620220496; cv=none; d=google.com; s=arc-20160816; b=VO4SkVEl49b2Aip+/PbkAQAi43qXQydO8Hi+dovnvx0rEdBjwzNII+I8POXzwhfsC7 0ahXFlKa+/tuygdkgwEft1IfWUfi/nPz3lIDFJFGYpEK2TFmlNx8u6JSKdeX/L8Hs4rV QM3QYYqLwJfgyRYRHxjbmeuoSP9cxVsJPN6wwZHisB64Hx/3Hzzo4VMaLxt9u1gklenF geHbegIndkMVO/W73s9mUpZQ3BbPAlBgXPDgRP3SGOEAznh3EkGO7RO/50o6KPD24xPk RxnlGUu1r8w/mV92H02Q41Zk9e+PdZi2fbt6bPK8I1p+tGhVgw9rl78EHgNKqDbIJU+4 NV0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=KWgKWqcKojvFWbBx5RMnNkzYaoIBCP6fm8wSr7RLIXA=; b=mBfMndeCsu+9+5hRwadvwqCrYlrXZEuCp997IzcG36dxEavEwYHVtT6ThThCSrw8qz PjDfAQ5FdVyHlvAMOWscg9R1nscfLGHVk0lttPBsLPGAiyZlUfGC9RCRe1yWFUpRHppT mlTkUWDQ4K8cL9JPqI27KVCjkA7GuHYA0oN+56HBs3GGyp7lU5gUn0lzpK78//M4ZasJ fQQGWkQ+sAHxwKh1ksOjoJV3wGL5SOKGlbw+fSGp6Dko2odmIoXCEZ+46cX1/iFjXvfS tPc/tjKvTBqNRw7T5IjP+pcUhq1G/A3gPxQFt1ZYYfX2tTj1e2f3oflfmLcJRgjTmFVd rDng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=GktqExQR; 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 gz1si5284453ejc.342.2021.05.05.06.14.32; Wed, 05 May 2021 06:14:56 -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=casper.20170209 header.b=GktqExQR; 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 S233035AbhEELW0 (ORCPT + 99 others); Wed, 5 May 2021 07:22:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232968AbhEELV7 (ORCPT ); Wed, 5 May 2021 07:21:59 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7C6C06174A; Wed, 5 May 2021 04:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=KWgKWqcKojvFWbBx5RMnNkzYaoIBCP6fm8wSr7RLIXA=; b=GktqExQRzr2dMR18KU8kv1UkCy /GAGq46ttPtITvgL+tv9Q4xq0qQp+3k5lt0nQxgvPQOsAgizCCYJkZ4A6qWQz6kw3t7+wJfk9Z2sS lT8DcRimaJyxOSJpOHr2JOjEAT3oDNLM1E3mlAMtGU7yW6wqTH1bZNX7GhtERQDgBya+1vHQsFwZt zXEPCeg8R4A5xHKYZObXPTyGcm8HhGejoQPra/o4gL59Py69lPz5+qE1kWC2XTxnwYT/PecTK8MuR /NlgflUkwQcL2++3ga+qxCtoL3ArWMstWDSX7eoJbrQC9OOG3e3gvyIzlX/xrDmgdypsPyDkv2Orp mjzPCsLA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1leFXn-000FRD-EV; Wed, 05 May 2021 11:18:44 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 9891B300312; Wed, 5 May 2021 13:18:16 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id EF566299E9868; Wed, 5 May 2021 13:18:14 +0200 (CEST) Message-ID: <20210505111525.248028369@infradead.org> User-Agent: quilt/0.66 Date: Wed, 05 May 2021 12:59:45 +0200 From: Peter Zijlstra To: tglx@linutronix.de, mingo@kernel.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, bsingharora@gmail.com, pbonzini@redhat.com, maz@kernel.org Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, peterz@infradead.org, riel@surriel.com, hannes@cmpxchg.org Subject: [PATCH 5/6] delayacct: Add static_branch in scheduler hooks References: <20210505105940.190490250@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cheaper when delayacct is disabled. Signed-off-by: Peter Zijlstra (Intel) --- include/linux/delayacct.h | 8 ++++++++ kernel/delayacct.c | 3 +++ 2 files changed, 11 insertions(+) --- a/include/linux/delayacct.h +++ b/include/linux/delayacct.h @@ -58,8 +58,10 @@ struct task_delay_info { #include #include +#include #ifdef CONFIG_TASK_DELAY_ACCT +DECLARE_STATIC_KEY_TRUE(delayacct_key); extern int delayacct_on; /* Delay accounting turned on/off */ extern struct kmem_cache *delayacct_cache; extern void delayacct_init(void); @@ -114,6 +116,9 @@ static inline void delayacct_tsk_free(st static inline void delayacct_blkio_start(void) { + if (!static_branch_likely(&delayacct_key)) + return; + delayacct_set_flag(DELAYACCT_PF_BLKIO); if (current->delays) __delayacct_blkio_start(); @@ -121,6 +126,9 @@ static inline void delayacct_blkio_start static inline void delayacct_blkio_end(struct task_struct *p) { + if (!static_branch_likely(&delayacct_key)) + return; + if (p->delays) __delayacct_blkio_end(p); delayacct_clear_flag(DELAYACCT_PF_BLKIO); --- a/kernel/delayacct.c +++ b/kernel/delayacct.c @@ -14,6 +14,7 @@ #include #include +DEFINE_STATIC_KEY_TRUE(delayacct_key); int delayacct_on __read_mostly = 1; /* Delay accounting turned on/off */ struct kmem_cache *delayacct_cache; @@ -28,6 +29,8 @@ void delayacct_init(void) { delayacct_cache = KMEM_CACHE(task_delay_info, SLAB_PANIC|SLAB_ACCOUNT); delayacct_tsk_init(&init_task); + if (!delayacct_on) + static_branch_disable(&delayacct_key); } void __delayacct_tsk_init(struct task_struct *tsk)