All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andrea Righi" <arighi@nvidia.com>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH 04/15] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS
Date: Tue, 28 Jul 2026 16:03:52 +0000	[thread overview]
Message-ID: <20260728160352.D52571F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260728154425.1549660-5-arighi@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Using SCHED_FLAG_KEEP_PARAMS with a new SCHED_DEADLINE policy on a non-deadline task causes a permanent deadline bandwidth leak in the root domain.
--

--- Patch [4]: [PATCH 04/15] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS ---
commit 7456fab35f0046cf8daada3381577cde13d7dbe1
Author: Andrea Righi <arighi@nvidia.com>

sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS

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 commit sets DEQUEUE_CLASS only when SCHED_FLAG_KEEP_PARAMS allows
the class to change.

> 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) {

[Severity: High]
This is a pre-existing issue and was not introduced by the patch under review,
but does using SCHED_FLAG_KEEP_PARAMS with a new SCHED_DEADLINE policy on a
non-deadline task cause a permanent deadline bandwidth leak in the root
domain?

When a user with CAP_SYS_NICE calls sched_setattr() with
attr.sched_policy = SCHED_DEADLINE and SCHED_FLAG_KEEP_PARAMS on a
non-deadline task, sys_sched_setattr() fetches the current parameters:

sys_sched_setattr()
    if (attr.sched_flags & SCHED_FLAG_KEEP_PARAMS)
        get_params(p, &attr, 0);

This can replace attr.sched_runtime with the task's current fair slice while
leaving attr.sched_period user-provided, constructing a valid deadline ratio.

Earlier in __sched_setscheduler(), this requested bandwidth is validated and
permanently added to the global root domain accounting via __dl_add() inside
sched_dl_overflow():

    if ((dl_policy(policy) || dl_task(p)) && sched_dl_overflow(p, policy, attr)) {

However, because SCHED_FLAG_KEEP_PARAMS is set, the parameter and class
transition is skipped further down inside the scoped_guard block:

    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);
    }

Since the task remains non-deadline and p->dl.dl_bw remains 0, when the task
eventually exits, it will subtract its dl_bw (0) instead of the allocated
bandwidth, leaving the globally added bandwidth permanently leaked.

Is there a way to prevent sched_dl_overflow() from allocating bandwidth if we
know SCHED_FLAG_KEEP_PARAMS will skip the parameter updates?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260728154425.1549660-1-arighi@nvidia.com?part=4

  reply	other threads:[~2026-07-28 16:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 15:43 [PATCHSET v10 sched_ext/for-7.3] sched: Make proxy execution compatible with sched_ext Andrea Righi
2026-07-28 15:43 ` [PATCH 01/15] sched/core: Avoid false migration warning for proxy donors Andrea Righi
2026-07-28 15:43 ` [PATCH 02/15] sched: Make NOHZ CFS bandwidth checks follow proxy donor Andrea Righi
2026-07-28 15:43 ` [PATCH 03/15] sched: Add helper to block retained proxy donors Andrea Righi
2026-07-28 15:43 ` [PATCH 04/15] sched: Skip class callbacks with SCHED_FLAG_KEEP_PARAMS Andrea Righi
2026-07-28 16:03   ` sashiko-bot [this message]
2026-07-28 15:43 ` [PATCH 05/15] sched: Add prepare_switch() class callback Andrea Righi
2026-07-28 15:43 ` [PATCH 06/15] sched: Add sched_ext hooks for proxy execution Andrea Righi
2026-07-28 15:43 ` [PATCH 07/15] sched_ext: Block proxy donors across scheduler transitions Andrea Righi
2026-07-28 15:43 ` [PATCH 08/15] sched_ext: Fix ops.running/stopping() pairing for proxy-exec donors Andrea Righi
2026-07-28 15:43 ` [PATCH 09/15] sched_ext: Generalize the reject DSQ reenqueue path Andrea Righi
2026-07-28 16:00   ` sashiko-bot
2026-07-28 15:43 ` [PATCH 10/15] sched_ext: Handle proxy-exec races in remote DSQ transfers Andrea Righi
2026-07-28 15:43 ` [PATCH 11/15] sched_ext: Split curr|donor references properly Andrea Righi
2026-07-28 16:25   ` sashiko-bot
2026-07-28 15:43 ` [PATCH 12/15] sched_ext: Delegate proxy donor admission to BPF schedulers Andrea Righi
2026-07-28 15:43 ` [PATCH 13/15] sched_ext: Add selftest for blocked donor admission Andrea Righi
2026-07-28 15:43 ` [PATCH 14/15] sched_ext: scx_qmap: Add proxy execution support Andrea Righi
2026-07-28 15:43 ` [PATCH 15/15] sched: Allow enabling proxy exec with sched_ext Andrea Righi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260728160352.D52571F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sched-ext@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.