Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6170795imu; Mon, 21 Jan 2019 04:28:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN5FRDGmLz53xO6+G+8TlVZ/0ACwKivpDnRNVT/azLx1SZTLU5C6LMysvluLGivNeo7gywbp X-Received: by 2002:a17:902:7e44:: with SMTP id a4mr30015505pln.338.1548073729872; Mon, 21 Jan 2019 04:28:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548073729; cv=none; d=google.com; s=arc-20160816; b=PS0SZRUQZN0O2MTBDbXmrFCXD3zW59XM7Lv01yXvO1jLP3HaHZclHpo9giVYFbwTcm DwzW8dJvtmP+mBCsFKOsyuDQGibM1qE5t89GhsKAmUwDAo9oMZv+zgGkhet/Np6XPKBp Q7dcRu3Qf06+yrMK6XeRfmfNy78ypCyj4qqt+reXpIIuNdY7BnysBJqsmasq7JE7u28O qV4DpT2kpdIgSqrzGBBGzc8bv3M4fA/Kq4IOEBkraOsEElrVWfPhfPVIyT1klY3o7ezo D25J+WUAutNxBgledgYLBk9duq9hoaHWXvOJaA8WsbxvTNYk1ebSRpG6AEZ+Cgu6xiNf mAbw== 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; bh=JUGJKdgdod/OVgHYIchSxwsyvJwfud6SNq6/p0OUyMQ=; b=0VlPio3lr6nWtJLGIU6JYjINfEPMJD+nP7PeOh6nKhY34U1wWVd9YKdCq+vEA9cGnH 8ucxTHtHgEPZrzN9Ej9FsF1RrtPnuDnhu/IrphkAO8H0et2OkVcNSe1V7KCuMksyMCup Fb0bK5dLj5fmrxjVVKePYKmYbgqb0o609xw73qWLCVUiUqfBQuBY0NXZevjk4QETAr/Y GIATuAv2IwaNxhOT9NKxweyHzd+vr+M8dYbY5iU8THj4NdypAlInbNcSQnddlabVDzFo s4hYBT3+1P4acxejOIVtclsaFILTgLn3jPrmrIxvx8DHmR57O6WCNFo+GWWa7Q2GIqGK EaHA== ARC-Authentication-Results: i=1; mx.google.com; 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 l1si12659937pld.324.2019.01.21.04.28.28; Mon, 21 Jan 2019 04:28:49 -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; 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 S1728478AbfAUM1Y (ORCPT + 99 others); Mon, 21 Jan 2019 07:27:24 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:32970 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728011AbfAUM1Y (ORCPT ); Mon, 21 Jan 2019 07:27:24 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 624BD80D; Mon, 21 Jan 2019 04:27:23 -0800 (PST) Received: from e110439-lin (e110439-lin.cambridge.arm.com [10.1.194.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6DAB53F614; Mon, 21 Jan 2019 04:27:20 -0800 (PST) Date: Mon, 21 Jan 2019 12:27:10 +0000 From: Patrick Bellasi To: Peter Zijlstra 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: <20190121122659.if6f4ubw2wgblxwi@e110439-lin> References: <20190115101513.2822-1-patrick.bellasi@arm.com> <20190115101513.2822-4-patrick.bellasi@arm.com> <20190121101508.GH27931@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190121101508.GH27931@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ? We cannot use less then an unsigned int for the fields above... am I missing something? > 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 ? -- #include Patrick Bellasi