Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp774793ybv; Thu, 20 Feb 2020 07:06:05 -0800 (PST) X-Google-Smtp-Source: APXvYqyZYpD/EsXb79D9pHjPOcviRHYfzEuAxN4t9hnh9pRHwgPfLq1ZDnonqHCEEP7CmoMLXFd0 X-Received: by 2002:aca:4f96:: with SMTP id d144mr2416484oib.172.1582211165461; Thu, 20 Feb 2020 07:06:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582211165; cv=none; d=google.com; s=arc-20160816; b=wOFXZpjCn7DccNib8/sttLqO0lq482oTxjnATulkLXcqGAC9mzkmWUeW0HJueg78aD Bg+bNwVRyK+U2gtHFzFA70iCgidaOWFEkhr9oWzm5+HZZuQ5W79YQ583WdaecjNkkLlo WIvfF3zay7KzUxBeRPcBi/SYYfBwY3Yedm5VKJfCL06SL69hprpBvWfLbARGegM4HK6o VaUkC7KOvj6ClMtjZWMUJ4LnXkeggfFYQytkSHPA98deAqw7UaX1Aw+RHA2N5N35W0Us cbdVCnL75s6QVfQsyciRZCHTE/vCWNrCgQob1Z3BvRnFHq+r8JY1OzUvdGjgbx9p9O+W f/tA== 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=sdgUR64dKzaqVmmod+QlpdJ1aY7pTfRDJJUUPluvr1s=; b=AK7m7CV3m+AAeSsgF3UORKn5KVsQ3T2FpdL6c1ICTxchVP56MPCuPM9ySw8nAcC8Ar +UxJk/VxwPTYrFhtnTOH5j/BzQN4fUS7XUqmvX7hr5TNIjWmgGD6wuinw6QWkoygeN3T y3z8NWEqkA5/Ydlsy1xCkCbGYO0LTjhXQrbEc/WOO49Kx7XusUogurOQ+/rqm4GZw0dW Pu7FbxaytVI0jS90cJ4xGUEUp77zmgud9skOZ0P0AVRPN/cjXDubaueTYej6AJDxbsfp wFHYzz6YODUfD9yfD9FAAAsYMgD0kf15VRQCqAkO5TcG2jmjCv4RZKC5jZyNuFmfkXJY 3JWQ== 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 v21si1702864otj.282.2020.02.20.07.05.52; Thu, 20 Feb 2020 07:06:05 -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 S1728406AbgBTPDt (ORCPT + 99 others); Thu, 20 Feb 2020 10:03:49 -0500 Received: from foss.arm.com ([217.140.110.172]:44526 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728134AbgBTPDt (ORCPT ); Thu, 20 Feb 2020 10:03:49 -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 F291D31B; Thu, 20 Feb 2020 07:03:48 -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 1E0993F703; Thu, 20 Feb 2020 07:03:47 -0800 (PST) Date: Thu, 20 Feb 2020 15:03:44 +0000 From: Qais Yousef To: chris hyser Cc: Parth Shah , vincent.guittot@linaro.org, patrick.bellasi@matbug.net, valentin.schneider@arm.com, dhaval.giani@oracle.com, dietmar.eggemann@arm.com, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, pavel@ucw.cz, qperret@qperret.net, David.Laight@ACULAB.COM, pjt@google.com, tj@kernel.org Subject: Re: [PATCH v3 0/3] Introduce per-task latency_nice for scheduler hints Message-ID: <20200220150343.dvweamfnk257pg7z@e107158-lin.cambridge.arm.com> References: <20200116120230.16759-1-parth@linux.ibm.com> <8ed0f40c-eeb4-c487-5420-a8eb185b5cdd@linux.ibm.com> <971909ed-d4e0-6afa-d20b-365ede5a195e@linux.ibm.com> <8e984496-e89b-d96c-d84e-2be7f0958ea4@oracle.com> <1e216d18-7ec0-4a0d-e124-b730d6e03e6f@oracle.com> <7429e0ae-41ff-e9c4-dd65-3ef1919f5f50@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/20/20 09:30, chris hyser wrote: > > The below diff works out well enough in-order to align permission checks > > with NICE. > > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index 2bfcff5623f9..ef4a397c9170 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -4878,6 +4878,10 @@ static int __sched_setscheduler(struct task_struct *p, > > return -EINVAL; > > if (attr->sched_latency_nice < MIN_LATENCY_NICE) > > return -EINVAL; > > + /* Use the same security checks as NICE */ > > + if (attr->sched_latency_nice < p->latency_nice && > > + !can_nice(p, attr->sched_latency_nice)) > > + return -EPERM; > > } > > > > if (pi) > > > > With the above in effect, > > A non-root user can only increase the value upto +19, and once increased > > cannot be decreased. e.g., a user once sets the value latency_nice = 19, > > the same user cannot set the value latency_nice = 18. This is the same > > effect as with NICE. > > > > Is such permission checks required? > > > > Unlike NICE, we are going to use latency_nice for scheduler hints only, and > > so won't it make more sense to allow a user to increase/decrease the values > > of their owned tasks? > > Whether called a hint or not, it is a trade-off to reduce latency of select > tasks at the expense of the throughput of the other tasks in the the system. Does it actually affect the throughput of the other tasks? I thought this will allow the scheduler to reduce latencies, for instance, when selecting which cpu it should land on. I can't see how this could hurt other tasks. Can you expand on the scenario you have in mind please? > If any of the other tasks belong to other users, you would presumably > require permission. AFAIU security_task_setscheduler() will only allow a change if the task is changing its own attribute value or has SYS_CAP_NICE. If you're able to change the attribute of another task, then its not only latency_nice that's broken here. Thanks -- Qais Yousef