Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5678660imm; Wed, 12 Sep 2018 09:26:28 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda7Sl0Od7E3iXHGP/PfQqn0dxsRlIlLWCq5I93qVcP34g5vZHRAAloKnHkSro6qS5lC0iQ8 X-Received: by 2002:a17:902:848d:: with SMTP id c13-v6mr3222506plo.194.1536769588077; Wed, 12 Sep 2018 09:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536769588; cv=none; d=google.com; s=arc-20160816; b=MNCiuw8yQnuc9Dgr2Eu1Qija9tkz32srYg+aD4O63Lq1J/JYNsEQjrh26NcHV8wcMh Y3uLForbilX9WLAAl6SSEs9OyTjlq1kSqxFhUuGusQp8Hc1m5mGEuI5NYKw7bH4rC72h OFyuhfDln3ohGZfjwFu1dqf4XxNxYrFWhH4dLPiufWIxuIs5AB99gjy/Svq+Jk/DG15F 9qyfNCM1oKSL6xBuAOdm0fG+nhgbAtYyBxaPb/M33BCzCSmu0jHeahJ/sc4BZiPlYaed JGUHulkQxYHCsQqHGZsO2GP+Di5USxZ/z3hSBfrQ/7U+9ziFcAbl0HUCchrWiN/O7mVa DmvQ== 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=7Lks6pZ72TXPOV0M611gEvH/TdS6H5aMizLe3D2jQtc=; b=i81HgQ62wbvuaWPq7GSRzKfk3r3fNU+rwqSCJdSqQNe9lr8HayMF+mx35MTFdpWsKF Fa46f6PQeo0jj4P6s/kiwcks/qSxaIEPRZiOdS/Mtx2gA5L2NPS0XIZLB/FsSnom1Daa XM++yyUZnwS7YZ8Q4esFJfIMN3F4ls1u7PJ0q0Jkr25IMyhHkrTYyPAwtMUj/cnuqhVV p4+YC0tEGmi36o8PaRVc+jBkXhRkil8vjYz+Xvv2sgKyJl6uvHFH3LGlVeDIW5oX4oCq rG2Ljp32yveWHE3SiMHkNru7Qa1hrKV45KtUEAbjAkSwRmIcQfu4QK1TJZUthjj18UP0 ITzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=BZhQR3DP; 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 u1-v6si1490766pfc.337.2018.09.12.09.26.04; Wed, 12 Sep 2018 09:26:28 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=BZhQR3DP; 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 S1727686AbeILV35 (ORCPT + 99 others); Wed, 12 Sep 2018 17:29:57 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52880 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726798AbeILV35 (ORCPT ); Wed, 12 Sep 2018 17:29:57 -0400 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: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=7Lks6pZ72TXPOV0M611gEvH/TdS6H5aMizLe3D2jQtc=; b=BZhQR3DPq8sdNB/kbsCmisU/l 20J14vxl1BvzJNCbX+j5Nv3xHKN7Kd0+HfHltZaH+9roS8aBZ1V0K5T0ESvQULH8/B/5yoKDD7WRr JzAXwJmwY4kPIOcVgDOBNs0xKV4l3S/23OAcsjUW3TXcatDg3SDNPrpJfecD8CDe0HthPSW6mdt3r fgQuci1socdBHs1VptR7AHAxi2RFKnPZ2exfDxBqJXth42J5WOQWt3cBlwkWyZo70oSEesg4kG+fW jNCO9OgilE18fTva0gaeTHaAndVvlgloV2FPAfFlIi4EjsIZOodK5ipatsG3nwkUo5eY++mnnXC2M BrMmdNxGw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g07wL-0001gK-F2; Wed, 12 Sep 2018 16:24:29 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 85DA5202C1A09; Wed, 12 Sep 2018 18:24:27 +0200 (CEST) Date: Wed, 12 Sep 2018 18:24:27 +0200 From: Peter Zijlstra To: Patrick Bellasi 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: <20180912162427.GA24106@hirez.programming.kicks-ass.net> References: <20180828135324.21976-1-patrick.bellasi@arm.com> <20180828135324.21976-3-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180828135324.21976-3-patrick.bellasi@arm.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 28, 2018 at 02:53:10PM +0100, Patrick Bellasi wrote: > static inline int __setscheduler_uclamp(struct task_struct *p, > const struct sched_attr *attr) But large for inline now. > { > + 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. > > + mutex_lock(&uclamp_mutex); > > + /* Find a valid group_id for each required clamp value */ > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) { > + 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"); AFAICT this is an unpriv part of the syscall; and you can spam the log without limits. Not good. > + 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; > + } > + > + result = uclamp_group_find(UCLAMP_MAX, attr->sched_util_max); > + if (result == -ENOSPC) { > + pr_err(UCLAMP_ENOSPC_FMT, "MAX"); > + goto done; > + } > + group_id[UCLAMP_MAX] = result; > + } > + > + /* Update each required clamp group */ > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) { > + uc_se = &p->uclamp[UCLAMP_MIN]; > + uclamp_group_get(UCLAMP_MIN, group_id[UCLAMP_MIN], > + uc_se, attr->sched_util_min); > + } > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) { > + uc_se = &p->uclamp[UCLAMP_MAX]; > + uclamp_group_get(UCLAMP_MAX, group_id[UCLAMP_MAX], > + uc_se, attr->sched_util_max); > + } > + > +done: > + mutex_unlock(&uclamp_mutex); > + > + return result; > +}