Re: [PATCH v4 2/2] sched: Skip priority checks with SCHED_FLAG_KEEP_PARAMS

From: Dietmar Eggemann
Date: Thu Jul 29 2021 - 13:31:22 EST


On 26/07/2021 15:56, Quentin Perret wrote:
> On Thursday 22 Jul 2021 at 10:47:33 (+0200), Dietmar Eggemann wrote:

[...]

>>> @@ -7393,6 +7403,8 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
>>> rcu_read_unlock();
>>>
>>> if (likely(p)) {
>>> + if (attr.sched_flags & SCHED_FLAG_KEEP_PARAMS)
>>> + get_params(p, &attr);
>>
>> SCHED_FLAG_KEEP_PARAMS is handled here but SCHED_FLAG_KEEP_POLICY
>> outside (before) the `if (likely(p))`?
>
> Because I need to dereference p while SCHED_FLAG_KEEP_POLICY doesn't :)

Ah, true. Looked weird though.
But then the SCHED_FLAG_KEEP_POLICY condition can be placed closer to
the SCHED_FLAG_KEEP_PARAMS condition. We don't have to set
SETPARAM_POLICY if p == NULL.

>>> retval = sched_setattr(p, &attr);
>>> put_task_struct(p);
>>> }

[...]