Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp504606imm; Fri, 14 Sep 2018 01:48:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaF5ioPSsdI2DdYwnR1ZkAZi3bLC2992v8xhOmjTKj7FUNAeEO+/EmaD0kYcVaoAzwo322n X-Received: by 2002:a17:902:49:: with SMTP id 67-v6mr11303277pla.206.1536914928908; Fri, 14 Sep 2018 01:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536914928; cv=none; d=google.com; s=arc-20160816; b=EZGXe4XSF/sZ8hXySrE31c63P67lr7HQNEJCTWIeGOeFAdbK9ntW0vjOSrRfVaYfti SP0FFjrIGD5/g0sCmS0/ew82rFXDFsdP+aA8JDFUlbqWu63zUhAuengOPbTqvoxvQHpp ZYNvuNmEhZNgjVxBbBOT1cF83pVNT6a5ygZHS51CaZx+XHzBq3mJ5i1PdxNSedbQ152E jrqLMSoKohHz+BC9K+F+Ai03jstN64FgSe7lHIfywdzbOkqmGsRShWqgKUXoGT70UiHb I1XY5mXbB1SdHf+aA3jsgMTLLU2+n6TIQPFoixvd0V0t9rlH8X4bXLByLaMDdyTKSEJB iPSw== 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=z8rYCVLP9CAlYOja+9UOo0evRvDGwcN+rsfW6s5HIN8=; b=ypmEgAt1mOclmVRQ1jUbJQf4K6kCyPtWjtpkWoEZTyg2sWd6QWVDc8tACNqEz9ghZJ KfjjzmeTrx+86cOfnuxYCEdPni0Z4iOQa8xRrB/A4a19CRKZ7ze5Q16LGTJn8P4IdPXC rm6PCEA0h7iOdqKtLISQHx2dmKMSCACIgiCMQCfApJjwGFJ33WmdttBqp6zjF6ZzK0+F fM6R3n/ppMifcFGvfCt87jui16DauwqIaRLKj6ZwdUrBQCYiV3dJbdP9ev/FsoZq5OPA vp6gpCmHf0JKpcEKBfTmD5O4iIYUHfw9u79Jv10SImxUs7i7+vGDeuG+kIf+CAiQUGst xNbQ== 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 i186-v6si6110396pge.414.2018.09.14.01.48.33; Fri, 14 Sep 2018 01:48:48 -0700 (PDT) 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 S1728007AbeINOAj (ORCPT + 99 others); Fri, 14 Sep 2018 10:00:39 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58306 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726618AbeINOAj (ORCPT ); Fri, 14 Sep 2018 10:00:39 -0400 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 31A4D18A; Fri, 14 Sep 2018 01:47:10 -0700 (PDT) Received: from e110439-lin (e110439-lin.emea.arm.com [10.4.12.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 629B33F703; Fri, 14 Sep 2018 01:47:07 -0700 (PDT) Date: Fri, 14 Sep 2018 09:47:04 +0100 From: Patrick Bellasi To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Tejun Heo , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Paul Turner , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan Subject: Re: [PATCH v4 02/16] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups Message-ID: <20180914084704.GL1413@e110439-lin> References: <20180828135324.21976-1-patrick.bellasi@arm.com> <20180828135324.21976-3-patrick.bellasi@arm.com> <20180912162427.GA24106@hirez.programming.kicks-ass.net> <20180912174209.GI1413@e110439-lin> <20180913192034.GA24082@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180913192034.GA24082@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13-Sep 21:20, Peter Zijlstra wrote: > On Wed, Sep 12, 2018 at 06:42:09PM +0100, Patrick Bellasi wrote: > > On 12-Sep 18:24, Peter Zijlstra wrote: > > > On Tue, Aug 28, 2018 at 02:53:10PM +0100, Patrick Bellasi wrote: > > > > > { > > > > + int group_id[UCLAMP_CNT] = { UCLAMP_NOT_VALID }; > > > > + int lower_bound, upper_bound; > > > > + struct uclamp_se *uc_se; > > > > + int result = 0; > > > > > > I think the thing would become much more readable if you set > > > lower/upper_bound right here. > > > Actually it could also make sense to have them before the mutex ;) > > Indeed. > > + upper_bound = (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) > + ? attr->sched_util_max > + : p->uclamp[UCLAMP_MAX].value; > + > + if (upper_bound == UCLAMP_NOT_VALID) > + upper_bound = SCHED_CAPACITY_SCALE; > + if (attr->sched_util_min > upper_bound) { > + result = -EINVAL; > + goto done; > + } > + > + result = uclamp_group_find(UCLAMP_MIN, attr->sched_util_min); > + if (result == -ENOSPC) { > + pr_err(UCLAMP_ENOSPC_FMT, "MIN"); > + goto done; > + } > + group_id[UCLAMP_MIN] = result; > + } > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) { > + lower_bound = (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) > + ? attr->sched_util_min > + : p->uclamp[UCLAMP_MIN].value; > + > + if (lower_bound == UCLAMP_NOT_VALID) > + lower_bound = 0; > + if (attr->sched_util_max < lower_bound || > + attr->sched_util_max > SCHED_CAPACITY_SCALE) { > + result = -EINVAL; > + goto done; > + } > > That would end up soething like: > > unsigned int lower_bound = p->uclamp[UCLAMP_MIN].value; > unsigned int upper_bound = p->uclamp[UCLAMP_MAX].value; > > if (sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) > lower_bound = attr->sched_util_min; > > if (sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) > upper_bound = attr->sched_util_max; > > if (lower_bound > upper_bound || > upper_bound > SCHED_CAPACITY_MAX) > return -EINVAL; > > mutex_lock(...); Yes... much cleaner, thanks. -- #include Patrick Bellasi