Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1059683ybl; Tue, 3 Dec 2019 00:40:22 -0800 (PST) X-Google-Smtp-Source: APXvYqz9SNlfbDkbyxKjCrGz5Gb2Na7Fk1x2hgyS6ABHNOwqD0Ywy4F9cIHntHqioTuuJefHDq3C X-Received: by 2002:aca:ecd3:: with SMTP id k202mr2690738oih.71.1575362422448; Tue, 03 Dec 2019 00:40:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575362422; cv=none; d=google.com; s=arc-20160816; b=QHPpYVcexjDdB+79q8RGt/nhbOi5yXTPtcijXdsXi38Ef1KYWTiWUE3dZkscM909Gj pMHdbEf5mkUOjW09/XiLX9SLxnfg1PL771sngWUfclOGDBmJ7FKrf6xdxv/do+GPc4TT J5CmUslNJmjiAPoe39GZuoJ9SZieA6AN9elmTUROD+bVLvpYlhdNmGuRvS6RXyGAYtYM zOPRtdokBeL4QZvHCYELapVcLHZEVucqVHzIALc3w3H7S77WexwrF7kLgrtursiuCC7r f+Q0x8RrVtB4L4LPuFxXEVp1c/byHSFu4KFiot8QjqFFhB3iiGYbdIoJT2KQ+d/p1PFO nk/g== 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=Vzl7xE1zff6cVLYlSwDySvXwmr9Mx+g0HT3Mfna5weA=; b=1GRf69uIqqSNg5IxgP0fYBfCSYIspyay0fg+wRnxKEc/ofCk0t1ABS7haorrtFFjUh oC2NjbBOj8Yf4Zgl+2J9h3mGvjGCJZclyriW5fav2PMtQlZSUqDpZpq95hIKWLSjseGs ++mvef3o4K4MvQ8OSzkzoQ+zE+eHBIBvBEAwZ8dglt7gNXBQXRhMUafwNB8E5yIms/M6 ipna8scSt9SmX6sFSzj8saA4YRSJjWrjkYUv5iz6wnKIsEwN6ko/5fRI4R0nbZOcJxlT rB5+cEUxygyn/ePGIychEUysK0oHUUUBQqFbkPcOyJU7Y6HNT5xcb5RCVc4cEtFmfUJe r71Q== 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 m23si1003165oie.180.2019.12.03.00.40.05; Tue, 03 Dec 2019 00:40:22 -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 S1726190AbfLCIjV (ORCPT + 99 others); Tue, 3 Dec 2019 03:39:21 -0500 Received: from foss.arm.com ([217.140.110.172]:39002 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbfLCIjV (ORCPT ); Tue, 3 Dec 2019 03:39:21 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A954C30E; Tue, 3 Dec 2019 00:39:20 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4EFAD3F68E; Tue, 3 Dec 2019 00:42:27 -0800 (PST) Date: Tue, 3 Dec 2019 08:39:16 +0000 From: Qais Yousef To: Parth Shah Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, patrick.bellasi@matbug.net, valentin.schneider@arm.com, pavel@ucw.cz, dhaval.giani@oracle.com, qperret@qperret.net, David.Laight@ACULAB.COM, morten.rasmussen@arm.com, pjt@google.com, tj@kernel.org, dietmar.eggemann@arm.com, viresh.kumar@linaro.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org Subject: Re: [RFC 3/3] Allow sched_{get,set}attr to change latency_tolerance of the task Message-ID: <20191203083915.yahl2qd3wnnkqxxs@e107158-lin.cambridge.arm.com> References: <20191125094618.30298-1-parth@linux.ibm.com> <20191125094618.30298-4-parth@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191125094618.30298-4-parth@linux.ibm.com> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/25/19 15:16, Parth Shah wrote: > Introduce the latency_tolerance attribute to sched_attr and provide a > mechanism to change the value with the use of sched_setattr/sched_getattr > syscall. > > Also add new flag "SCHED_FLAG_LATENCY_TOLERANCE" to hint the change in > latency_tolerance of the task on every sched_setattr syscall. > > Signed-off-by: Parth Shah > --- > include/uapi/linux/sched.h | 4 +++- > include/uapi/linux/sched/types.h | 2 ++ > kernel/sched/core.c | 15 +++++++++++++++ > kernel/sched/sched.h | 1 + > 4 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/include/uapi/linux/sched.h b/include/uapi/linux/sched.h > index b3105ac1381a..73db430d11b6 100644 > --- a/include/uapi/linux/sched.h > +++ b/include/uapi/linux/sched.h > @@ -71,6 +71,7 @@ struct clone_args { > #define SCHED_FLAG_KEEP_PARAMS 0x10 > #define SCHED_FLAG_UTIL_CLAMP_MIN 0x20 > #define SCHED_FLAG_UTIL_CLAMP_MAX 0x40 > +#define SCHED_FLAG_LATENCY_TOLERANCE 0x80 > > #define SCHED_FLAG_KEEP_ALL (SCHED_FLAG_KEEP_POLICY | \ > SCHED_FLAG_KEEP_PARAMS) > @@ -82,6 +83,7 @@ struct clone_args { > SCHED_FLAG_RECLAIM | \ > SCHED_FLAG_DL_OVERRUN | \ > SCHED_FLAG_KEEP_ALL | \ > - SCHED_FLAG_UTIL_CLAMP) > + SCHED_FLAG_UTIL_CLAMP | \ > + SCHED_FLAG_LATENCY_TOLERANCE) > > #endif /* _UAPI_LINUX_SCHED_H */ > diff --git a/include/uapi/linux/sched/types.h b/include/uapi/linux/sched/types.h > index c852153ddb0d..960774ac0c70 100644 > --- a/include/uapi/linux/sched/types.h > +++ b/include/uapi/linux/sched/types.h > @@ -118,6 +118,8 @@ struct sched_attr { > __u32 sched_util_min; > __u32 sched_util_max; > > + /* latency requirement hints */ > + __s32 sched_latency_tolerance; > }; > > #endif /* _UAPI_LINUX_SCHED_TYPES_H */ > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index ea7abbf5c1bb..dfd36ec14404 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -4695,6 +4695,9 @@ static void __setscheduler_params(struct task_struct *p, > p->rt_priority = attr->sched_priority; > p->normal_prio = normal_prio(p); > set_load_weight(p, true); > + > + /* Change latency tolerance of the task if !SCHED_FLAG_KEEP_PARAMS */ > + p->latency_tolerance = attr->sched_latency_tolerance; > } > > /* Actually do priority change: must hold pi & rq lock. */ > @@ -4852,6 +4855,13 @@ static int __sched_setscheduler(struct task_struct *p, > return retval; > } > > + if (attr->sched_flags & SCHED_FLAG_LATENCY_TOLERANCE) { > + if (attr->sched_latency_tolerance > MAX_LATENCY_TOLERANCE) > + return -EINVAL; > + if (attr->sched_latency_tolerance < MIN_LATENCY_TOLERANCE) > + return -EINVAL; > + } > + > if (pi) > cpuset_read_lock(); > > @@ -4886,6 +4896,9 @@ static int __sched_setscheduler(struct task_struct *p, > goto change; > if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP) > goto change; > + if (attr->sched_flags & SCHED_FLAG_LATENCY_TOLERANCE && > + attr->sched_latency_tolerance != p->latency_tolerance) > + goto change; > > p->sched_reset_on_fork = reset_on_fork; > retval = 0; > @@ -5392,6 +5405,8 @@ SYSCALL_DEFINE4(sched_getattr, pid_t, pid, struct sched_attr __user *, uattr, > else > kattr.sched_nice = task_nice(p); > > + kattr.sched_latency_tolerance = p->latency_tolerance; > + > #ifdef CONFIG_UCLAMP_TASK > kattr.sched_util_min = p->uclamp_req[UCLAMP_MIN].value; > kattr.sched_util_max = p->uclamp_req[UCLAMP_MAX].value; > diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h > index 0db2c1b3361e..bb181175954b 100644 > --- a/kernel/sched/sched.h > +++ b/kernel/sched/sched.h > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include nit: keep in alphabatical order. The series looks good to me except for the 2 minor nits. Thanks for taking care of this! Reviewed-by: Qais Yousef Cheers -- Qais Yousef > #include > #include > #include > -- > 2.17.2 >