[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ee0ac345-e3b0-52ea-d70e-0048b2296e67@redhat.com>
Date: Tue, 5 Sep 2023 18:17:26 +0200
From: Daniel Bristot de Oliveira <bristot@...hat.com>
To: Peter Zijlstra <peterz@...radead.org>,
Daniel Bristot de Oliveira <bristot@...nel.org>
Cc: Ingo Molnar <mingo@...hat.com>, Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Valentin Schneider <vschneid@...hat.com>,
linux-kernel@...r.kernel.org,
Luca Abeni <luca.abeni@...tannapisa.it>,
Tommaso Cucinotta <tommaso.cucinotta@...tannapisa.it>,
Thomas Gleixner <tglx@...utronix.de>,
Joel Fernandes <joel@...lfernandes.org>,
Vineeth Pillai <vineeth@...byteword.org>,
Shuah Khan <skhan@...uxfoundation.org>,
Phil Auld <pauld@...hat.com>
Subject: Re: [PATCH v4 7/7] sched/fair: Fair server interface
On 9/5/23 15:55, Peter Zijlstra wrote:
> On Thu, Aug 31, 2023 at 10:28:58PM +0200, Daniel Bristot de Oliveira wrote:
>> +static ssize_t
>> +sched_fair_server_runtime_write(struct file *filp, const char __user *ubuf,
>> + size_t cnt, loff_t *ppos)
>> +{
>> + long cpu = (long) ((struct seq_file *) filp->private_data)->private;
>> + struct rq *rq = cpu_rq(cpu);
>> + unsigned long flags;
>> + u64 runtime;
>> + int err;
>> +
>> + err = kstrtoull_from_user(ubuf, cnt, 10, &runtime);
>> + if (err)
>> + return err;
>> +
>> + raw_spin_rq_lock_irqsave(rq, flags);
>> + if (runtime > rq->fair_server.dl_period)
>> + err = -EINVAL;
>> + else
>> + rq->fair_server.dl_runtime = runtime;
>> + raw_spin_rq_unlock_irqrestore(rq, flags);
>> +
>> + if (err)
>> + return err;
>> +
>> + *ppos += cnt;
>> + return cnt;
>> +}
>
>> +static ssize_t
>> +sched_fair_server_period_write(struct file *filp, const char __user *ubuf,
>> + size_t cnt, loff_t *ppos)
>> +{
>> + long cpu = (long) ((struct seq_file *) filp->private_data)->private;
>> + struct rq *rq = cpu_rq(cpu);
>> + unsigned long flags;
>> + u64 period;
>> + int err;
>> +
>> + err = kstrtoull_from_user(ubuf, cnt, 10, &period);
>> + if (err)
>> + return err;
>> +
>> + if (period < fair_server_period_min || period > fair_server_period_max)
>> + return -EINVAL;
>> +
>> + raw_spin_rq_lock_irqsave(rq, flags);
>> + if (period < rq->fair_server.dl_runtime)
>> + err = -EINVAL;
>> + else
>> + rq->fair_server.dl_period = period;
>> + raw_spin_rq_unlock_irqrestore(rq, flags);
>> +
>> + if (err)
>> + return err;
>> +
>> + *ppos += cnt;
>> + return cnt;
>> +}
>
>> +static ssize_t
>> +sched_fair_server_defer_write(struct file *filp, const char __user *ubuf,
>> + size_t cnt, loff_t *ppos)
>> +{
>> + long cpu = (long) ((struct seq_file *) filp->private_data)->private;
>> + struct rq *rq = cpu_rq(cpu);
>> + unsigned long flags;
>> + u64 defer;
>> + int err;
>> +
>> + err = kstrtoull_from_user(ubuf, cnt, 10, &defer);
>> + if (err)
>> + return err;
>> +
>> + if (defer < 0 || defer > 1)
>> + return -EINVAL;
>> +
>> + raw_spin_rq_lock_irqsave(rq, flags);
>> + rq->fair_server_defer = defer;
>> + raw_spin_rq_unlock_irqrestore(rq, flags);
>> +
>> + *ppos += cnt;
>> + return cnt;
>> +}
>
> Surely we can write a single function that does all of that with less
> duplication?
I agree, I will use your code as starting point for that...
>
> Additionally, should not the deadline parameters be vetted by access
> control before being accepted ?
like security_task_getscheduler(p)? But we have no p...
I checked rt throttling, but it seems that it does not check. Do you have
a pointer?
-- Daniel
Powered by blists - more mailing lists