Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1004808ybt; Fri, 19 Jun 2020 21:19:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZkltGFsMPwIxEr7KEo6fRAlUIKp73irTGNmuqrsPrfjwhbiCsdUqZ6WlVlTDb2yXcpOIH X-Received: by 2002:a50:8fa1:: with SMTP id y30mr6253035edy.86.1592626741479; Fri, 19 Jun 2020 21:19:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592626741; cv=none; d=google.com; s=arc-20160816; b=TIg5NKJtPgk/n4fETFnppBM4B/XmJCGUI8WVY8Ys3tdTzAURT+Fql93sJI03uFSJNS g1A6adTrxsg4L6ZsiiutQCjvw9lQKxrsXq5F619W+KMJ6MWertZYyNNiEqYdOhcLRx5K X06Fls68gOLXjt5mc0ccZ+LZUYcknUTA2lqEIJfjhAPMC3y1rG6stzgX262oC66krw93 PWpLiEMILWNsenAiNZxNGSQwrcOjyuw3D3EaP+EahmPEtJ3zyHimTmhFbw+rh+y3ApFY eNCp1vjCY557BAs6yXWJy0mnBk7jvZxXHIRnuq5iUUXG2kBuxOuRTwEhRoINIwye1nbR 2Kjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=13ZJQzrfJj7+YLK0QljS5Z5b2OI+ht2N1tTNhzsfu/g=; b=gWJHjIh/f/K1mMZnRspUq2zfjUmYMWJJCocWGOKsJ3MM0vZVXsNTtdUy7nwpk39bqN 90rYa1+ryFuBRHb2XeNzUMix1C7PbAxXWC9qshy+x/TW30pQ2hz2pDtSxPeQeEkxEXk2 P9MgbXWJlHuc3AG9BW3bop7ljySnf897CJkKCytqBJoAhMzhwkKnzf4k7SUZ3jIEL8mS 0oRi8ofiEXuw+gSGW0zACtT6lnFX9icVsgR7uS/tFt8edS7aXxX032m2R+HIdrE3Dl5Z SHqzQVXCHvJZawhRX2hgXOC3nkBTzxwHmJw8KMRAhfCLdINzE8G3w+z09VeJ3basHPiK aamg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="oAa/oi+m"; 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 d17si5069664ejw.42.2020.06.19.21.18.39; Fri, 19 Jun 2020 21:19:01 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="oAa/oi+m"; 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 S2387691AbgFSRp3 (ORCPT + 99 others); Fri, 19 Jun 2020 13:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731681AbgFSRp2 (ORCPT ); Fri, 19 Jun 2020 13:45:28 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB95EC06174E for ; Fri, 19 Jun 2020 10:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; 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=13ZJQzrfJj7+YLK0QljS5Z5b2OI+ht2N1tTNhzsfu/g=; b=oAa/oi+mt7/J7uNq9VlNs9miJG Rz+2LCWRkHlWLwMABa/upa6/LXowJwXqTfxTUlkuSpubB7gPn5UWVAAjZ2rol7vk/Ioj9w29cBdZq eeADyCdxRcjAk9Ya5jppcFeSPaAuhHUHxU5O3FhnWJK6Rqtd3ty+F447oTrXXiXE7A4VJ9MRihxgb qPqMYNrv3yvPrjp9LC3bpiI0HZNA7COs8x7steq+w8QqOdgevYnUUqfZeYdO7IUnSdHL0vxfo3hsC ZK5HTda6ViymwBaTrODD6l5M1+Yn80goPJPisNM+W+l2IuigvBdAHDIFeBqCBG1xwb+OUYJYy4swr m1kANaDA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jmL4j-0006Q6-BZ; Fri, 19 Jun 2020 17:45:13 +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 0DB1B307159; Fri, 19 Jun 2020 19:45:11 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E23B421390E42; Fri, 19 Jun 2020 19:45:10 +0200 (CEST) Date: Fri, 19 Jun 2020 19:45:10 +0200 From: Peter Zijlstra To: Qais Yousef Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Patrick Bellasi , Chris Redpath , Lukasz Luba , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] sched/uclamp: Protect uclamp fast path code with static key Message-ID: <20200619174510.GB576888@hirez.programming.kicks-ass.net> References: <20200618195525.7889-1-qais.yousef@arm.com> <20200618195525.7889-3-qais.yousef@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200618195525.7889-3-qais.yousef@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 18, 2020 at 08:55:25PM +0100, Qais Yousef wrote: > +/* > + * This static key is used to reduce the uclamp overhead in the fast path. It > + * only disables the call to uclamp_rq_{inc, dec}() in enqueue/dequeue_task(). > + * > + * This allows users to continue to enable uclamp in their kernel config with > + * minimum uclamp overhead in the fast path. > + * > + * As soon as userspace modifies any of the uclamp knobs, the static key is > + * disabled, since we have an actual users that make use of uclamp > + * functionality. > + * > + * The knobs that would disable this static key are: > + * > + * * A task modifying its uclamp value with sched_setattr(). > + * * An admin modifying the sysctl_sched_uclamp_{min, max} via procfs. > + * * An admin modifying the cgroup cpu.uclamp.{min, max} > + */ > +DEFINE_STATIC_KEY_TRUE(sched_uclamp_unused); Maybe call the thing: 'sched_uclamp_users', instead? > + if (static_branch_unlikely(&sched_uclamp_unused)) > + static_branch_disable(&sched_uclamp_unused); > + if (static_branch_unlikely(&sched_uclamp_unused)) > + static_branch_disable(&sched_uclamp_unused); > + if (static_branch_unlikely(&sched_uclamp_unused)) > + static_branch_disable(&sched_uclamp_unused); That's an anti-pattern... just static_branch_disable(), or _enable() with a 'better' name is sufficient.