Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp621377pxx; Thu, 29 Oct 2020 10:19:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0OQwWkP9RpNf6JE+hh15G+Fdc2SUzewKZv0eFlHeHmzppmIiWTPSfOAhaf0PF5Qx+Nkf+ X-Received: by 2002:a17:906:6156:: with SMTP id p22mr4905684ejl.64.1603991989858; Thu, 29 Oct 2020 10:19:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603991989; cv=none; d=google.com; s=arc-20160816; b=WqnvxcsniydoketPvoKCroCzSHz0pVEX49pKnk8nybg771QX8Xmk+Ch1P6me315xP9 UQNSKsd5JmFCsg7EMynErAfM0g/mg+5WJbKxxStuUmrNdlVMBC8CHugQejZ0nW2DIQWY tNTeSbb+KxzuF3ZI8ALJwhoTAkueXZUl4xoGCR/UElqsICfYnim7iVMliDg5OhM3Yf5S O29iC4+9XXHrFZPsjzn5hF3nweC7B8mXWCZc0Prn8AiKP+EKcy/CAp7YzQlK+pughcrv C694uuYN+YWUX35es9mOAyq60jrMyeSouVAiqzx0cm13+qPpyghUzz0w59MLuI3NUSL+ C1Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=TGaZ176pQv2T1yoS0+iot3gPEtoVFH+mQKa/MIx50B4=; b=Av0RQWmDbbK2S3RbM1L2j5zvc1/ibX00hi3nzLKbfI2QKeX0pXXEgrP0JrJ2E98S2S jCVXYMXZ7UPa5r/3OYeN+/494yCtg1vRd2EXphsDGtkUAY9nP7PJbfbDb8dX27LfzXOv rZI2uEGRuMaQ/X4CGkWUSrar0Ggsdd2rUe6s5tu3wWeUFXx4HjsHjaYZnUXSjOj/b3bT 3FOogM3wpDsnxTCUhNG6gXjSQxLUZWtnDy0YiKUQkfy3ZEZL38j944Bari9R6SyIaXuT LekHeqIFKrfOviUa6HY1QApE1UJ9FsKVXRvY5UYsvCQAcJuknmo9qLUKJihnLm395SWT t3wQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n6si2477698edi.165.2020.10.29.10.19.27; Thu, 29 Oct 2020 10:19:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727183AbgJ2RRm (ORCPT + 99 others); Thu, 29 Oct 2020 13:17:42 -0400 Received: from foss.arm.com ([217.140.110.172]:41192 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgJ2RRl (ORCPT ); Thu, 29 Oct 2020 13:17:41 -0400 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 019A8139F; Thu, 29 Oct 2020 10:17:41 -0700 (PDT) Received: from e107158-lin (e107158-lin.cambridge.arm.com [10.1.194.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 362453F66E; Thu, 29 Oct 2020 10:17:40 -0700 (PDT) Date: Thu, 29 Oct 2020 17:17:37 +0000 From: Qais Yousef To: Dietmar Eggemann Cc: Yun Hsiang , peterz@infradead.org, linux-kernel@vger.kernel.org, patrick.bellasi@matbug.net Subject: Re: [PATCH v3 1/1] sched/uclamp: add SCHED_FLAG_UTIL_CLAMP_RESET flag to reset uclamp Message-ID: <20201029171737.aoums2h2mpst3hp3@e107158-lin> References: <20201025073632.720393-1-hsiang023167@gmail.com> <20201029110818.alrviwwljxnegmip@e107158-lin> <20201029130243.GA897607@ubuntu> <20201029130649.h4wm2ak5j7zkgb3s@e107158-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/29/20 16:50, Dietmar Eggemann wrote: > On 29/10/2020 14:06, Qais Yousef wrote: > > On 10/29/20 21:02, Yun Hsiang wrote: > >> Hi Qais, > >> > >> On Thu, Oct 29, 2020 at 11:08:18AM +0000, Qais Yousef wrote: > >>> Hi Yun > >>> > >>> Sorry for chipping in late. > >>> > >>> On 10/25/20 15:36, Yun Hsiang wrote: > > [...] > > >>>> #define SCHED_FLAG_UTIL_CLAMP (SCHED_FLAG_UTIL_CLAMP_MIN | \ > >>>> - SCHED_FLAG_UTIL_CLAMP_MAX) > >>>> + SCHED_FLAG_UTIL_CLAMP_MAX | \ > >>>> + SCHED_FLAG_UTIL_CLAMP_RESET) > >>> > >>> Is it safe to change this define in a uapi header without a potential > >>> consequence? > > AFAICS, there're 3 occurrences, besides the one in > __setscheduler_uclamp(), in which we use SCHED_FLAG_UTIL_CLAMP. > > 1) call uclamp_validate() in __sched_setscheduler() > > 2) jump to 'change' label in __sched_setscheduler() > > 3) check that the uattr->size is SCHED_ATTR_SIZE_VER1 in > sched_copy_attr() > > 2) and 3) require SCHED_FLAG_UTIL_CLAMP_RESET to be part of > SCHED_FLAG_UTIL_CLAMP but IMHO 1) needs this change: > > @@ -1413,8 +1413,14 @@ int sysctl_sched_uclamp_handler(struct ctl_table > *table, int write, > 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; > + unsigned int lower_bound, upper_bound; > + > + /* Do not check uclamp attributes values in reset case. */ > + if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_RESET) > + return 0; > + > + lower_bound = p->uclamp_req[UCLAMP_MIN].value; > + upper_bound = p->uclamp_req[UCLAMP_MAX].value; > > if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) > lower_bound = attr->sched_util_min; > > Otherwise a bogus sa.sched_util_min or sa.sched_util_max with > SCHED_FLAG_UTIL_CLAMP_RESET could return -EINVAL. I haven't checked the details of this implementation but I interpret that you agree it's better to leave the define in the uapi header intact. > >>> FWIW I still have concerns about this approach. We're doing a reset to control > >>> cgroup behavior, I don't see any correlation between the two. Besides the > >>> difference between RESET and setting uclamp_min=0 without RESET is not obvious > >>> nor intuitive for someone who didn't look at the code. > >>> > >>> I propose something like the below which is more explicit about what is being > >>> requested and delivered here. And if we decide to deprecate this behavior, > >>> it'd be much easier to just ignore this flag. > >>> > >>> You must set this flag with your uclamp request to retain the cgroup > >>> inheritance behavior. If the flag is not set, we automatically clear it. > >> > >> I think this behavior may not meet android requirement. Becasue in > >> android there is group like top-app. And we want to boost the > >> group by setting group uclamp_min. If group inheritance is explicit, we > >> need to set this flag for all the tasks in top-app. This might be > >> costly. > > > > You will not have to set it for every task. It's on by default like it works > > now. This behavior doesn't change. > > > > But if you change the uclamp value of a task but still want it to continue to > > inherit the cgroup values if it's attached to one, you must set this flag when > > changing the uclamp value. > > I'm not really fond of this idea because: > > (1) explicit cgroup(-behavior) related settings through a per-task user > interface. But this is what we're doing whether it's called RESET or something else here. Ie: cgroup behavior is the purpose of this change. > (2) uclamp reset makes already sense in the !CONFIG_UCLAMP_TASK_GROUP > case. A task can reset its uclamp values here as well, and then > 'inheriting' the system defaults again. Already mentioned in > https://lkml.kernel.org/r/87362ihxvw.derkling@matbug.net Yes and no. Generic RESET yes makes sense in general. But not for the intended use case here which depends on CONFIG_UCLAMP_TASK_GROUP. And not in practice since only RT tasks have a difference default value that this RESET makes sense to implement for. But there's no real requirement for that yet. The requirement is to control cgroup. We're inventing the RESET flag to handle the cgroup case. So it not making sense for !CONFIG_UCLAMP_TASK_GROUP is the correct outcome. In my view, I see a contradiction between what we're implementing and what's required. This subtlety is confusing. It could be just me maybe.. Anyway I won't argue further if you really prefer the RESET way :-) Thanks -- Qais Yousef