* [PATCH 0/2] sched: Fix SCHED_FLAG_KEEP_PARAMS side effects
@ 2026-07-30 5:50 Andrea Righi
2026-07-30 5:50 ` [PATCH 1/2] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS Andrea Righi
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Andrea Righi @ 2026-07-30 5:50 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, K Prateek Nayak, Tejun Heo, Patrick Bellasi,
linux-kernel
SCHED_FLAG_KEEP_PARAMS allows sched_setattr() to update generic task
attributes while retaining the task's existing scheduling parameters and
class.
Two paths in __sched_setscheduler() still act on the requested policy
before the guarded parameter update. One marks the operation as a class
change and invokes class transition callbacks even though the class remains
unchanged. The other performs deadline admission control and can account
bandwidth for a non-deadline task that never enters the deadline class.
Prevent both side effects when SCHED_FLAG_KEEP_PARAMS is set.
Andrea Righi (2):
sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS
sched/deadline: Skip bandwidth accounting with SCHED_FLAG_KEEP_PARAMS
kernel/sched/syscalls.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
base-commit: bafb78898eb70fcaa979608a2d7ae9bad86124a1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS
2026-07-30 5:50 [PATCH 0/2] sched: Fix SCHED_FLAG_KEEP_PARAMS side effects Andrea Righi
@ 2026-07-30 5:50 ` Andrea Righi
2026-07-30 7:29 ` K Prateek Nayak
2026-07-30 5:56 ` [PATCH 2/2] sched/deadline: Skip bandwidth accounting " Andrea Righi
2026-07-30 9:32 ` [PATCH 0/2] sched: Fix SCHED_FLAG_KEEP_PARAMS side effects Peter Zijlstra
2 siblings, 1 reply; 9+ messages in thread
From: Andrea Righi @ 2026-07-30 5:50 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, K Prateek Nayak, Tejun Heo, Patrick Bellasi,
linux-kernel
SCHED_FLAG_KEEP_PARAMS suppresses scheduler parameter and class changes,
but __sched_setscheduler() can still set DEQUEUE_CLASS when the class
computed from the requested policy differs from the task's current
class.
This causes the switching_from(), switched_from(), switching_to() and
switched_to() callbacks to run even though p->sched_class remains
unchanged.
Set DEQUEUE_CLASS only when the sched class is allowed to change.
Fixes: 637b0682821b ("sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern")
Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
kernel/sched/syscalls.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
index b215b0ead9a60..903b47f5d0b74 100644
--- a/kernel/sched/syscalls.c
+++ b/kernel/sched/syscalls.c
@@ -675,7 +675,8 @@ int __sched_setscheduler(struct task_struct *p,
prev_class = p->sched_class;
next_class = __setscheduler_class(policy, newprio);
- if (prev_class != next_class)
+ if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) &&
+ prev_class != next_class)
queue_flags |= DEQUEUE_CLASS;
scoped_guard (sched_change, p, queue_flags) {
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] sched/deadline: Skip bandwidth accounting with SCHED_FLAG_KEEP_PARAMS
2026-07-30 5:50 [PATCH 0/2] sched: Fix SCHED_FLAG_KEEP_PARAMS side effects Andrea Righi
2026-07-30 5:50 ` [PATCH 1/2] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS Andrea Righi
@ 2026-07-30 5:56 ` Andrea Righi
2026-07-30 10:04 ` Peter Zijlstra
2026-07-30 9:32 ` [PATCH 0/2] sched: Fix SCHED_FLAG_KEEP_PARAMS side effects Peter Zijlstra
2 siblings, 1 reply; 9+ messages in thread
From: Andrea Righi @ 2026-07-30 5:56 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, K Prateek Nayak, Tejun Heo, Patrick Bellasi,
linux-kernel
A sched_setattr() invocation targeting a non-deadline task can specify
SCHED_DEADLINE together with SCHED_FLAG_KEEP_PARAMS. The flag prevents
__sched_setscheduler() from applying the requested parameters or class,
but deadline admission runs before the guarded update and immediately
accounts the requested bandwidth in the root domain. Repeating the
invocation can therefore consume bandwidth without creating a deadline
task capable of releasing it.
Skip deadline bandwidth admission when SCHED_FLAG_KEEP_PARAMS is set,
since neither the deadline policy nor its parameters will change.
Fixes: a509a7cd7974 ("sched/uclamp: Extend sched_setattr() to support utilization clamping")
Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
kernel/sched/syscalls.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
index 903b47f5d0b74..e95ed51110fbd 100644
--- a/kernel/sched/syscalls.c
+++ b/kernel/sched/syscalls.c
@@ -650,7 +650,8 @@ int __sched_setscheduler(struct task_struct *p,
* of a SCHED_DEADLINE task) we need to check if enough bandwidth
* is available.
*/
- if ((dl_policy(policy) || dl_task(p)) && sched_dl_overflow(p, policy, attr)) {
+ if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) &&
+ (dl_policy(policy) || dl_task(p)) && sched_dl_overflow(p, policy, attr)) {
retval = -EBUSY;
goto unlock;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS
2026-07-30 5:50 ` [PATCH 1/2] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS Andrea Righi
@ 2026-07-30 7:29 ` K Prateek Nayak
2026-07-30 8:57 ` Andrea Righi
2026-07-30 9:57 ` Peter Zijlstra
0 siblings, 2 replies; 9+ messages in thread
From: K Prateek Nayak @ 2026-07-30 7:29 UTC (permalink / raw)
To: Andrea Righi, Ingo Molnar, Peter Zijlstra, Juri Lelli,
Vincent Guittot
Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, Tejun Heo, Patrick Bellasi, linux-kernel
Hello Andrea,
On 7/30/2026 11:20 AM, Andrea Righi wrote:
> SCHED_FLAG_KEEP_PARAMS suppresses scheduler parameter and class changes,
> but __sched_setscheduler() can still set DEQUEUE_CLASS when the class
> computed from the requested policy differs from the task's current
> class.
>
> This causes the switching_from(), switched_from(), switching_to() and
> switched_to() callbacks to run even though p->sched_class remains
> unchanged.
>
> Set DEQUEUE_CLASS only when the sched class is allowed to change.
>
> Fixes: 637b0682821b ("sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern")
> Signed-off-by: Andrea Righi <arighi@nvidia.com>
> ---
> kernel/sched/syscalls.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
> index b215b0ead9a60..903b47f5d0b74 100644
> --- a/kernel/sched/syscalls.c
> +++ b/kernel/sched/syscalls.c
> @@ -675,7 +675,8 @@ int __sched_setscheduler(struct task_struct *p,
> prev_class = p->sched_class;
> next_class = __setscheduler_class(policy, newprio);
>
> - if (prev_class != next_class)
> + if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) &&
> + prev_class != next_class)
> queue_flags |= DEQUEUE_CLASS;
It seems there also exists a SCHED_FLAG_KEEP_POLICY which should be used
to retain the policy. By a quick look at the syscall path,
SCHED_FLAG_KEEP_PARAMS should just do an equivalent of:
get_params(p, &attr, 0)
and match the some properties of sched_attr with that of the task.
The task is still free to switch classes if the attr->sched_policy
differs given SCHED_FLAG_KEEP_PARAMS and SCHED_FLAG_KEEP_POLICY are two
distinct flags and there is a separate SCHED_FLAG_KEEP_ALL to combines
them both.
I'm having a sneaky suspicion that the bit in sched_change guard below
should actually check for SCHED_FLAG_KEEP_ALL like:
diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
index b215b0ead9a6..baf1fc59069e 100644
--- a/kernel/sched/syscalls.c
+++ b/kernel/sched/syscalls.c
@@ -680,7 +680,7 @@ int __sched_setscheduler(struct task_struct *p,
scoped_guard (sched_change, p, queue_flags) {
- if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS)) {
+ if ((attr->sched_flags & SCHED_FLAG_KEEP_ALL) != SCHED_FLAG_KEEP_ALL) {
__setscheduler_params(p, attr);
p->sched_class = next_class;
p->prio = newprio;
---
>
> scoped_guard (sched_change, p, queue_flags) {
--
Thanks and Regards,
Prateek
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS
2026-07-30 7:29 ` K Prateek Nayak
@ 2026-07-30 8:57 ` Andrea Righi
2026-07-30 9:57 ` Peter Zijlstra
1 sibling, 0 replies; 9+ messages in thread
From: Andrea Righi @ 2026-07-30 8:57 UTC (permalink / raw)
To: K Prateek Nayak
Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, Tejun Heo, Patrick Bellasi, linux-kernel
Hi Prateek,
On Thu, Jul 30, 2026 at 12:59:37PM +0530, K Prateek Nayak wrote:
> Hello Andrea,
>
> On 7/30/2026 11:20 AM, Andrea Righi wrote:
> > SCHED_FLAG_KEEP_PARAMS suppresses scheduler parameter and class changes,
> > but __sched_setscheduler() can still set DEQUEUE_CLASS when the class
> > computed from the requested policy differs from the task's current
> > class.
> >
> > This causes the switching_from(), switched_from(), switching_to() and
> > switched_to() callbacks to run even though p->sched_class remains
> > unchanged.
> >
> > Set DEQUEUE_CLASS only when the sched class is allowed to change.
> >
> > Fixes: 637b0682821b ("sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern")
> > Signed-off-by: Andrea Righi <arighi@nvidia.com>
> > ---
> > kernel/sched/syscalls.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
> > index b215b0ead9a60..903b47f5d0b74 100644
> > --- a/kernel/sched/syscalls.c
> > +++ b/kernel/sched/syscalls.c
> > @@ -675,7 +675,8 @@ int __sched_setscheduler(struct task_struct *p,
> > prev_class = p->sched_class;
> > next_class = __setscheduler_class(policy, newprio);
> >
> > - if (prev_class != next_class)
> > + if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) &&
> > + prev_class != next_class)
> > queue_flags |= DEQUEUE_CLASS;
>
> It seems there also exists a SCHED_FLAG_KEEP_POLICY which should be used
> to retain the policy. By a quick look at the syscall path,
> SCHED_FLAG_KEEP_PARAMS should just do an equivalent of:
>
> get_params(p, &attr, 0)
>
> and match the some properties of sched_attr with that of the task.
I think get_params() only copies the parameters relevant to the task's current
policy. For example, for a fair task it copies sched_nice, but not
sched_priority or the deadline parameters. Allowing an arbitrary cross-class
transition could still apply target-class parameters supplied by the caller
despite KEEP_PARAMS.
>
> The task is still free to switch classes if the attr->sched_policy
> differs given SCHED_FLAG_KEEP_PARAMS and SCHED_FLAG_KEEP_POLICY are two
> distinct flags and there is a separate SCHED_FLAG_KEEP_ALL to combines
> them both.
>
> I'm having a sneaky suspicion that the bit in sched_change guard below
> should actually check for SCHED_FLAG_KEEP_ALL like:
>
> diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
> index b215b0ead9a6..baf1fc59069e 100644
> --- a/kernel/sched/syscalls.c
> +++ b/kernel/sched/syscalls.c
> @@ -680,7 +680,7 @@ int __sched_setscheduler(struct task_struct *p,
>
> scoped_guard (sched_change, p, queue_flags) {
>
> - if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS)) {
> + if ((attr->sched_flags & SCHED_FLAG_KEEP_ALL) != SCHED_FLAG_KEEP_ALL) {
Changing this condition to SCHED_FLAG_KEEP_ALL would execute the full parameter
and class update when only SCHED_FLAG_KEEP_PARAMS is set, enabling the
problematic cross-class case.
IIUC, SCHED_FLAG_KEEP_POLICY is handled independently: the syscall replaces
attr->sched_policy with SETPARAM_POLICY, which is resolved to the task's current
policy under the rq lock. Parameter changes are still allowed in that case, so
the __setscheduler_params() block must run.
For this fix, I think DEQUEUE_CLASS should follow the existing update condition,
so that the class callbacks reflect whether p->sched_class is actually changed.
Thanks,
-Andrea
> __setscheduler_params(p, attr);
> p->sched_class = next_class;
> p->prio = newprio;
> ---
>
> >
> > scoped_guard (sched_change, p, queue_flags) {
>
> --
> Thanks and Regards,
> Prateek
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] sched: Fix SCHED_FLAG_KEEP_PARAMS side effects
2026-07-30 5:50 [PATCH 0/2] sched: Fix SCHED_FLAG_KEEP_PARAMS side effects Andrea Righi
2026-07-30 5:50 ` [PATCH 1/2] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS Andrea Righi
2026-07-30 5:56 ` [PATCH 2/2] sched/deadline: Skip bandwidth accounting " Andrea Righi
@ 2026-07-30 9:32 ` Peter Zijlstra
2026-07-30 9:52 ` Peter Zijlstra
2 siblings, 1 reply; 9+ messages in thread
From: Peter Zijlstra @ 2026-07-30 9:32 UTC (permalink / raw)
To: Andrea Righi
Cc: Ingo Molnar, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider,
K Prateek Nayak, Tejun Heo, Patrick Bellasi, linux-kernel
On Thu, Jul 30, 2026 at 07:50:09AM +0200, Andrea Righi wrote:
> SCHED_FLAG_KEEP_PARAMS allows sched_setattr() to update generic task
> attributes while retaining the task's existing scheduling parameters and
> class.
Well, KEEP_PARAMS is only sensible when the policy is unchanged, but
that isn't in fact enforced.
Do we want something like so to start with?
---
diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
index b215b0ead9a6..48094923a755 100644
--- a/kernel/sched/syscalls.c
+++ b/kernel/sched/syscalls.c
@@ -979,8 +979,11 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
if (!p)
return -ESRCH;
- if (attr.sched_flags & SCHED_FLAG_KEEP_PARAMS)
+ if (attr.sched_flags & SCHED_FLAG_KEEP_PARAMS) {
+ if (attr.sched_policy != p->policy)
+ return -EINVAL;
get_params(p, &attr, 0);
+ }
return sched_setattr(p, &attr);
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] sched: Fix SCHED_FLAG_KEEP_PARAMS side effects
2026-07-30 9:32 ` [PATCH 0/2] sched: Fix SCHED_FLAG_KEEP_PARAMS side effects Peter Zijlstra
@ 2026-07-30 9:52 ` Peter Zijlstra
0 siblings, 0 replies; 9+ messages in thread
From: Peter Zijlstra @ 2026-07-30 9:52 UTC (permalink / raw)
To: Andrea Righi
Cc: Ingo Molnar, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider,
K Prateek Nayak, Tejun Heo, Patrick Bellasi, linux-kernel
On Thu, Jul 30, 2026 at 11:32:24AM +0200, Peter Zijlstra wrote:
> On Thu, Jul 30, 2026 at 07:50:09AM +0200, Andrea Righi wrote:
> > SCHED_FLAG_KEEP_PARAMS allows sched_setattr() to update generic task
> > attributes while retaining the task's existing scheduling parameters and
> > class.
>
> Well, KEEP_PARAMS is only sensible when the policy is unchanged, but
> that isn't in fact enforced.
>
> Do we want something like so to start with?
>
> ---
> diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
> index b215b0ead9a6..48094923a755 100644
> --- a/kernel/sched/syscalls.c
> +++ b/kernel/sched/syscalls.c
> @@ -979,8 +979,11 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
> if (!p)
> return -ESRCH;
>
> - if (attr.sched_flags & SCHED_FLAG_KEEP_PARAMS)
> + if (attr.sched_flags & SCHED_FLAG_KEEP_PARAMS) {
> + if (attr.sched_policy != p->policy)
Ah, it also needs to deal with SETPARAM_POLICY, so something like:
attr.sched_policy != SETPARAM_POLICY && attr.sched_policy != p->policy
I suppose.
> + return -EINVAL;
> get_params(p, &attr, 0);
> + }
>
> return sched_setattr(p, &attr);
> }
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS
2026-07-30 7:29 ` K Prateek Nayak
2026-07-30 8:57 ` Andrea Righi
@ 2026-07-30 9:57 ` Peter Zijlstra
1 sibling, 0 replies; 9+ messages in thread
From: Peter Zijlstra @ 2026-07-30 9:57 UTC (permalink / raw)
To: K Prateek Nayak
Cc: Andrea Righi, Ingo Molnar, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, Tejun Heo, Patrick Bellasi, linux-kernel
On Thu, Jul 30, 2026 at 12:59:37PM +0530, K Prateek Nayak wrote:
> Hello Andrea,
>
> On 7/30/2026 11:20 AM, Andrea Righi wrote:
> > SCHED_FLAG_KEEP_PARAMS suppresses scheduler parameter and class changes,
> > but __sched_setscheduler() can still set DEQUEUE_CLASS when the class
> > computed from the requested policy differs from the task's current
> > class.
> >
> > This causes the switching_from(), switched_from(), switching_to() and
> > switched_to() callbacks to run even though p->sched_class remains
> > unchanged.
> >
> > Set DEQUEUE_CLASS only when the sched class is allowed to change.
> >
> > Fixes: 637b0682821b ("sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern")
> > Signed-off-by: Andrea Righi <arighi@nvidia.com>
> > ---
> > kernel/sched/syscalls.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
> > index b215b0ead9a60..903b47f5d0b74 100644
> > --- a/kernel/sched/syscalls.c
> > +++ b/kernel/sched/syscalls.c
> > @@ -675,7 +675,8 @@ int __sched_setscheduler(struct task_struct *p,
> > prev_class = p->sched_class;
> > next_class = __setscheduler_class(policy, newprio);
> >
> > - if (prev_class != next_class)
> > + if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) &&
> > + prev_class != next_class)
> > queue_flags |= DEQUEUE_CLASS;
>
> It seems there also exists a SCHED_FLAG_KEEP_POLICY which should be used
> to retain the policy. By a quick look at the syscall path,
> SCHED_FLAG_KEEP_PARAMS should just do an equivalent of:
>
> get_params(p, &attr, 0)
>
> and match the some properties of sched_attr with that of the task.
>
> The task is still free to switch classes if the attr->sched_policy
> differs given SCHED_FLAG_KEEP_PARAMS and SCHED_FLAG_KEEP_POLICY are two
> distinct flags and there is a separate SCHED_FLAG_KEEP_ALL to combines
> them both.
>
> I'm having a sneaky suspicion that the bit in sched_change guard below
> should actually check for SCHED_FLAG_KEEP_ALL like:
>
> diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
> index b215b0ead9a6..baf1fc59069e 100644
> --- a/kernel/sched/syscalls.c
> +++ b/kernel/sched/syscalls.c
> @@ -680,7 +680,7 @@ int __sched_setscheduler(struct task_struct *p,
>
> scoped_guard (sched_change, p, queue_flags) {
>
> - if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS)) {
> + if ((attr->sched_flags & SCHED_FLAG_KEEP_ALL) != SCHED_FLAG_KEEP_ALL) {
> __setscheduler_params(p, attr);
> p->sched_class = next_class;
> p->prio = newprio;
Hmm, but if we have KEEP_PARAMS then params are loaded with the current
set and actually re-setting them doesn't matter. So perhaps we should
just remove that conditional entirely?
---
diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
index b215b0ead9a6..1893938c76db 100644
--- a/kernel/sched/syscalls.c
+++ b/kernel/sched/syscalls.c
@@ -680,12 +680,10 @@ int __sched_setscheduler(struct task_struct *p,
scoped_guard (sched_change, p, queue_flags) {
- if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS)) {
- __setscheduler_params(p, attr);
- p->sched_class = next_class;
- p->prio = newprio;
- __setscheduler_dl_pi(newprio, policy, p, scope);
- }
+ __setscheduler_params(p, attr);
+ p->sched_class = next_class;
+ p->prio = newprio;
+ __setscheduler_dl_pi(newprio, policy, p, scope);
__setscheduler_uclamp(p, attr);
if (scope->queued) {
@@ -979,8 +977,11 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
if (!p)
return -ESRCH;
- if (attr.sched_flags & SCHED_FLAG_KEEP_PARAMS)
+ if (attr.sched_flags & SCHED_FLAG_KEEP_PARAMS) {
+ if (attr.sched_policy != SETPARAM_POLICY && attr.sched_policy != p->policy)
+ return -EINVAL;
get_params(p, &attr, 0);
+ }
return sched_setattr(p, &attr);
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] sched/deadline: Skip bandwidth accounting with SCHED_FLAG_KEEP_PARAMS
2026-07-30 5:56 ` [PATCH 2/2] sched/deadline: Skip bandwidth accounting " Andrea Righi
@ 2026-07-30 10:04 ` Peter Zijlstra
0 siblings, 0 replies; 9+ messages in thread
From: Peter Zijlstra @ 2026-07-30 10:04 UTC (permalink / raw)
To: Andrea Righi
Cc: Ingo Molnar, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider,
K Prateek Nayak, Tejun Heo, Patrick Bellasi, linux-kernel
On Thu, Jul 30, 2026 at 07:56:31AM +0200, Andrea Righi wrote:
> A sched_setattr() invocation targeting a non-deadline task can specify
> SCHED_DEADLINE together with SCHED_FLAG_KEEP_PARAMS. The flag prevents
> __sched_setscheduler() from applying the requested parameters or class,
> but deadline admission runs before the guarded update and immediately
> accounts the requested bandwidth in the root domain. Repeating the
> invocation can therefore consume bandwidth without creating a deadline
> task capable of releasing it.
>
> Skip deadline bandwidth admission when SCHED_FLAG_KEEP_PARAMS is set,
> since neither the deadline policy nor its parameters will change.
I'm thinking this should be fixed by simply not allowing KEEP_PARAM when
the policy changes, no?
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-07-30 10:05 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-30 5:50 [PATCH 0/2] sched: Fix SCHED_FLAG_KEEP_PARAMS side effects Andrea Righi
2026-07-30 5:50 ` [PATCH 1/2] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS Andrea Righi
2026-07-30 7:29 ` K Prateek Nayak
2026-07-30 8:57 ` Andrea Righi
2026-07-30 9:57 ` Peter Zijlstra
2026-07-30 5:56 ` [PATCH 2/2] sched/deadline: Skip bandwidth accounting " Andrea Righi
2026-07-30 10:04 ` Peter Zijlstra
2026-07-30 9:32 ` [PATCH 0/2] sched: Fix SCHED_FLAG_KEEP_PARAMS side effects Peter Zijlstra
2026-07-30 9:52 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox