linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Song Chen <chensong_2000@189.cn>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	bsegall@google.com, mgorman@suse.de, bristot@redhat.com,
	vschneid@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernel/sched/core: adjust rt_priority accordingly when prio is changed
Date: Wed, 1 Feb 2023 10:56:03 -0500	[thread overview]
Message-ID: <20230201105603.1d377866@gandalf.local.home> (raw)
In-Reply-To: <1675245680-2811-1-git-send-email-chensong_2000@189.cn>

On Wed,  1 Feb 2023 18:01:20 +0800
Song Chen <chensong_2000@189.cn> wrote:

> When a high priority process is acquiring a rtmutex which is held by a
> low priority process, the latter's priority will be boosted up by calling
> rt_mutex_setprio->__setscheduler_prio.
> 
> However, p->prio is changed but p->rt_priority is not, as a result, the
> equation between prio and rt_priority is broken, which is:
> 
> 	prio = MAX_RT_PRIO - 1 - rt_priority
> 
> It's confusing to the user when it calls sched_getparam, which only
> returns rt_priority.

If it is boosted, then that's an internal implementation and not the real
priority of the task. It should not be exposed to a user interface. In
fact, there's discussion of implementing a "proxy" algorithm which will
make what the "priority" of a task is even more complicated when acquiring
mutexes.


> 
> This patch addresses this issue by adjusting rt_priority according to
> the new value of prio, what's more, it also returns normal_prio for
> CFS processes instead of just a zero.

The comment above sched_getparam() is:

/**
 * sys_sched_getparam - get the RT priority of a thread
 * @pid: the pid in question.
 * @param: structure containing the RT priority.
 *
 * Return: On success, 0 and the RT priority is in @param. Otherwise, an error
 * code.
 */

So returning the nice value is incorrect. If anything, perhaps it should
return -EINVAL if the task is not an RT task?

-- Steve

> 
> Signed-off-by: Song Chen <chensong_2000@189.cn>
> ---

      reply	other threads:[~2023-02-01 15:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 10:01 [PATCH] kernel/sched/core: adjust rt_priority accordingly when prio is changed Song Chen
2023-02-01 15:56 ` Steven Rostedt [this message]

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=20230201105603.1d377866@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=chensong_2000@189.cn \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).