Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3607737yba; Tue, 7 May 2019 04:14:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrxrvgQ1RjylHMiFQ4wGbr41FPVU6Wx0eoE4GieoO9XrXLj7OJbPT3Y4Fq3/eIOtoi2+iG X-Received: by 2002:a63:5a4b:: with SMTP id k11mr38940432pgm.119.1557227698358; Tue, 07 May 2019 04:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557227698; cv=none; d=google.com; s=arc-20160816; b=NZxp/2xOHFtivvllavvQBjHADKOCLVM+E99VLHSEY5e7Vw+GWu/76aCy+omSPv2qBO hQ4Y2GyUtjtnGbTt4uD/RrcEaSbiVMPxyEmFreVziBfojCzNIZb9/yOS7WD1xiKQBsFv KXUFwr+N86xt99X4giCYZU+S/0uML1aCpzzf9r7jShgrry6HSPPXWLT1LEfvNVZpFXV/ CBw/UkWoC1gsmBRfrf6PtRlW6M/fbBbeTb2d6ByyifuWFTDY5eezjwQdlGdSFvnz7bb6 kazDs6MSkkdZ/qdmpT8MvchGoHqbWbImAK3GTacTFFEPI6egVjZuNCx6JVweEhvCmnHD hiEA== 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=TOGwtRHv8s3PMzdZ0BA0g/2LYwEJ+BehAXjxmoLKBEc=; b=dyWhiFf8daMpyBVCveJ5h7gTtSB3dBEN2ituI4j8oGs6j4h+jMkMsFElYeXGL4aaBl qAMEcHFshys9ONJ2t9IQPv6N9sZr/aKeN7yP+EYIpsJ6HZxzPjyXTAlYPqUVvqtRc1A0 oeQVuLqOx3GHlNLOYxHmIM11Kh9wnKNZnjMIfGRWvEwpP1eB2OHtfkbaUpQK3tsAi6pN +TLwm9UaB8jt3GK4k8+ZHAnqae9Rdf8wo6O7pGRzllb51mFfENy+E42Wb6VoAyUwv+At Ujd8RRtNtVraTbv0JxiMQVlsqt2Mt5HJewL7J3Y8+RfSCBc2VgfTwKAS3R97+8sWEIX6 MlRA== 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 r84si7249836pfa.10.2019.05.07.04.14.42; Tue, 07 May 2019 04:14:58 -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 S1726586AbfEGLNx (ORCPT + 99 others); Tue, 7 May 2019 07:13:53 -0400 Received: from foss.arm.com ([217.140.101.70]:51200 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726337AbfEGLNx (ORCPT ); Tue, 7 May 2019 07:13:53 -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 BA8A8374; Tue, 7 May 2019 04:13:52 -0700 (PDT) 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 C1F3D3F5AF; Tue, 7 May 2019 04:13:49 -0700 (PDT) Date: Tue, 7 May 2019 12:13:47 +0100 From: Patrick Bellasi To: Suren Baghdasaryan Cc: LKML , linux-pm@vger.kernel.org, linux-api@vger.kernel.org, Ingo Molnar , Peter Zijlstra , 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 Subject: Re: [PATCH v8 06/16] sched/core: uclamp: Extend sched_setattr() to support utilization clamping Message-ID: <20190507111347.4ivnjwbymsf7i3e6@e110439-lin> References: <20190402104153.25404-1-patrick.bellasi@arm.com> <20190402104153.25404-7-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17-Apr 15:26, Suren Baghdasaryan wrote: > On Tue, Apr 2, 2019 at 3:42 AM Patrick Bellasi wrote: [...] > > Do not allow to change sched class specific params and non class > > specific params (i.e. clamp values) at the same time. This keeps things > > simple and still works for the most common cases since we are usually > > interested in just one of the two actions. > > Sorry, I can't find where you are checking to eliminate the > possibility of simultaneous changes to both sched class specific > params and non class specific params... Am I too tired or they are > indeed missing? No, you right... that limitation has been removed in v8 :) I'll remove the above paragraph in v9, thanks for spotting it. [...] > > +static int uclamp_validate(struct task_struct *p, > > + const struct sched_attr *attr) > > +{ > > + unsigned int lower_bound = p->uclamp_req[UCLAMP_MIN].value; > > + unsigned int upper_bound = p->uclamp_req[UCLAMP_MAX].value; > > + > > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) > > + lower_bound = attr->sched_util_min; > > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) > > + upper_bound = attr->sched_util_max; > > + > > + if (lower_bound > upper_bound) > > + return -EINVAL; > > + if (upper_bound > SCHED_CAPACITY_SCALE) > > + return -EINVAL; > > + > > + return 0; > > +} [...] > > static void uclamp_fork(struct task_struct *p) > > { > > unsigned int clamp_id; > > @@ -1056,6 +1100,13 @@ static void __init init_uclamp(void) > > #else /* CONFIG_UCLAMP_TASK */ > > static inline void uclamp_rq_inc(struct rq *rq, struct task_struct *p) { } > > static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p) { } > > +static inline int uclamp_validate(struct task_struct *p, > > + const struct sched_attr *attr) > > +{ > > + return -ENODEV; > > ENOSYS might be more appropriate? Yep, agree, thanks! > > > +} > > +static void __setscheduler_uclamp(struct task_struct *p, > > + const struct sched_attr *attr) { } > > static inline void uclamp_fork(struct task_struct *p) { } > > static inline void init_uclamp(void) { } > > #endif /* CONFIG_UCLAMP_TASK */ > > @@ -4424,6 +4475,13 @@ static void __setscheduler_params(struct task_struct *p, > > static void __setscheduler(struct rq *rq, struct task_struct *p, > > const struct sched_attr *attr, bool keep_boost) > > { > > + /* > > + * If params can't change scheduling class changes aren't allowed > > + * either. > > + */ > > + if (attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) > > + return; > > + > > __setscheduler_params(p, attr); > > > > /* > > @@ -4561,6 +4619,13 @@ static int __sched_setscheduler(struct task_struct *p, > > return retval; > > } > > > > + /* Update task specific "requested" clamps */ > > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP) { > > + retval = uclamp_validate(p, attr); > > + if (retval) > > + return retval; > > + } > > + > > /* > > * Make sure no PI-waiters arrive (or leave) while we are > > * changing the priority of the task: [...] -- #include Patrick Bellasi