Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6192474imu; Mon, 21 Jan 2019 04:53:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN6HwKFWWvYCSISJocz0fiIflndNRxVtbV9jeBNPGQi1hnDFv0oZNB6CJGTHL2TsGa3diYFQ X-Received: by 2002:a62:cf02:: with SMTP id b2mr30615016pfg.183.1548075183902; Mon, 21 Jan 2019 04:53:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548075183; cv=none; d=google.com; s=arc-20160816; b=a1T/rw28MTFYx5hVPMOMYf1njV99WTVb3bS9S8ZvTMXilGv/pn6J5pEMhGuTRwUSqc CRI3er5WPQMlrCOZ9YgHIpzkBKdeGUxCQAn9o4N1D8CxQlUIv7ezkT828bA8mk98Gz4B 1Y5m+afbNnKpA7Gn6bxxLFth0FCDix13jGywDQ17fW3X8JGcPsM6hXO9rQJitoYMlRRb Y8ZDFP+wWhZWdGQDY4/R953ovAFVUgk7jAkcdNDvVNqOgiSb2zEb5oyZfBpoK3KJsjHx OMRac8bM78ZbFmXdBOsUvvY18+yuNHRz+8Vi9zKbcXL8q8LPTMu1v+wShy0W66Zh57US xtPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=40LtdF75kj72Y8+CkoBmhdcWUTk8s4S5td/po7h0f9g=; b=lATud5nFENHz87Xlj8TEo1b9zGUYNPW9bQMDth/IbtxmR41wGGswVbErkyDsHmlsBd D30tQHLsOQod/0b7xPi08rb2bSw2N1fXsRiLFR3d5pcZRBh7TuK/TX7rIVjdjJz+gio1 4SiZzT3Z2e0mopeJS5dOwnMPO/0Eijxwy5H4DhEdH6t+LfCNnkppkB4ExI479mk8y7pB D8PscUXGpyjAiaAstkgE+xDTmBCfP4R4y+kCyCFx+TKS9rHNcYz1ap5RSKWUH4uBJWWA RI658RotYXB/wFh7wZTo0SDAFjZW2L6Vs+E2H+fexuJc/MHYQVKy/nWgCwnhpeCRKx5W 7Nsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=IueQTxVQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x64si12407879pfb.120.2019.01.21.04.52.42; Mon, 21 Jan 2019 04:53:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=IueQTxVQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728678AbfAUMvi (ORCPT + 99 others); Mon, 21 Jan 2019 07:51:38 -0500 Received: from merlin.infradead.org ([205.233.59.134]:49644 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728162AbfAUMvi (ORCPT ); Mon, 21 Jan 2019 07:51:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=40LtdF75kj72Y8+CkoBmhdcWUTk8s4S5td/po7h0f9g=; b=IueQTxVQlRfmyC3kFHMmAS/P1 D/J+fyyk07alK8ls5REqklkc6k4ku32YspFmkqFrpjAW8GCpAzvLNsFxRxDBCsuRgAbrZDq9kp/j3 F+ojYEeEOqvG/X7It63++rAOmy68/GtJkDEqOF3h5vLJMWw8KVr8gLop8LQACd6LioC3A+X6m6M2B BVZnNNERaTcEyaWvsBfg/QpF32KWL4O7onVrO5vXNYebfCLHEKbg8H6nHrkBAGZLnQPhJDMshg0eY KEZswwO12chIuHXo7WHReGFStwI7kDSIomyMQLnYS15E8wGbY0+6LNagsMyKfeO1M+aHblope2tnS IX61Sf3Ig==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1glZ2x-0003jR-SV; Mon, 21 Jan 2019 12:51:24 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1C43A2846CE22; Mon, 21 Jan 2019 13:51:20 +0100 (CET) Date: Mon, 21 Jan 2019 13:51:20 +0100 From: Peter Zijlstra To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-api@vger.kernel.org, Ingo Molnar , Tejun Heo , "Rafael J . Wysocki" , Vincent Guittot , Viresh Kumar , Paul Turner , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan Subject: Re: [PATCH v6 03/16] sched/core: uclamp: Map TASK's clamp values into CPU's clamp buckets Message-ID: <20190121125120.GB17749@hirez.programming.kicks-ass.net> References: <20190115101513.2822-1-patrick.bellasi@arm.com> <20190115101513.2822-4-patrick.bellasi@arm.com> <20190121101508.GH27931@hirez.programming.kicks-ass.net> <20190121122659.if6f4ubw2wgblxwi@e110439-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190121122659.if6f4ubw2wgblxwi@e110439-lin> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 21, 2019 at 12:27:10PM +0000, Patrick Bellasi wrote: > On 21-Jan 11:15, Peter Zijlstra wrote: > > On Tue, Jan 15, 2019 at 10:15:00AM +0000, Patrick Bellasi wrote: > > > +/* > > > + * Number of utilization clamp buckets. > > > + * > > > + * The first clamp bucket (bucket_id=0) is used to track non clamped tasks, i.e. > > > + * util_{min,max} (0,SCHED_CAPACITY_SCALE). Thus we allocate one more bucket in > > > + * addition to the compile time configured number. > > > + */ > > > +#define UCLAMP_BUCKETS (CONFIG_UCLAMP_BUCKETS_COUNT + 1) > > > + > > > +/* > > > + * Utilization clamp bucket > > > + * @value: clamp value tracked by a clamp bucket > > > + * @bucket_id: the bucket index used by the fast-path > > > + * @mapped: the bucket index is valid > > > + * > > > + * A utilization clamp bucket maps a: > > > + * clamp value (value), i.e. > > > + * util_{min,max} value requested from userspace > > > + * to a: > > > + * clamp bucket index (bucket_id), i.e. > > > + * index of the per-cpu RUNNABLE tasks refcounting array > > > + * > > > + * The mapped bit is set whenever a task has been mapped on a clamp bucket for > > > + * the first time. When this bit is set, any: > > > + * uclamp_bucket_inc() - for a new clamp value > > > + * is matched by a: > > > + * uclamp_bucket_dec() - for the old clamp value > > > + */ > > > +struct uclamp_se { > > > + unsigned int value : bits_per(SCHED_CAPACITY_SCALE); > > > + unsigned int bucket_id : bits_per(UCLAMP_BUCKETS); > > > + unsigned int mapped : 1; > > > +}; > > > > Do we want something like: > > > > BUILD_BUG_ON(sizeof(struct uclamp_se) == sizeof(unsigned int)); > > Mmm... isn't "!=" what you mean ? Quite. > We cannot use less then an unsigned int for the fields above... am I > missing something? I wanted to ensure we don't accidentally use more. > > And/or put a limit on CONFIG_UCLAMP_BUCKETS_COUNT that guarantees that ? > > The number of buckets is currently KConfig limited to a max of 20, which gives: > > UCLAMP_BUCKETS: 21 => 5bits > > Thus, even on 32 bit targets and assuming 21bits for an "extended" > SCHED_CAPACITY_SCALE range we should always fit into an unsigned int > and have at least 6 bits for flags. > > Are you afraid of some compiler magic related to bitfields packing ? Nah, I missed the Kconfig limit and was afraid that some weird configs would end up with massively huge structures.