From: Aleksey Makarov <amakarov@ru.mvista.com>
To: rml@ximian.com
Cc: ext-rt-dev@mvista.com, linux-kernel@vger.kernel.org
Subject: [BUG] MAX_RT_PRIO != MAX_USER_RT_PRIO
Date: Thu, 21 Oct 2004 22:07:29 +0400 [thread overview]
Message-ID: <200410212207.29923.amakarov@ru.mvista.com> (raw)
Hi,
After debugging some strange memory corruptions in
SMP kernel I discovered this bug.
First, some excerpts from linux 2.6.9:
Documentation/sched-coding.txt:60:
--8<-------------------------------8<----------------
MAX_PRIO
The maximum priority of the system, stored in the task as task->prio.
Lower priorities are higher. Normal (non-RT) priorities range from
MAX_RT_PRIO to (MAX_PRIO - 1).
MAX_RT_PRIO
The maximum real-time priority of the system. Valid RT priorities
range from 0 to (MAX_RT_PRIO - 1).
MAX_USER_RT_PRIO
The maximum real-time priority that is exported to user-space. Should
always be equal to or less than MAX_RT_PRIO. Setting it less allows
kernel threads to have higher priorities than any user-space task.
--8<-------------------------------8<----------------
kernel/sched.c:4130:
--8<-------------------------------8<----------------
_setscheduler(p, SCHED_FIFO, MAX_RT_PRIO-1);
--8<-------------------------------8<----------------
kernel/sched.c:3169
--8<-------------------------------8<----------------
static void __setscheduler(struct task_struct *p, int policy, int prio)
{
BUG_ON(p->array);
p->policy = policy;
p->rt_priority = prio;
if (policy != SCHED_NORMAL)
p->prio = MAX_USER_RT_PRIO-1 - p->rt_priority;
else
p->prio = p->static_prio;
}
--8<-------------------------------8<----------------
Let MAX_RT_PRIO = 120, MAX_USER_RT_PRIO = 100, CONFIG_SMP = y.
Then, after __setscheduler() call in kernel/sched.c:4130,
value of p->prio will be -20.
p->prio is used, for example, in kernel/sched.c:707:
_set_bit(p->prio, array->bitmap);
So, instead of setting a bit in bitmap array of struct prio,
it changes the nr_active field.
Aleksey Makarov
reply other threads:[~2004-10-21 18:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200410212207.29923.amakarov@ru.mvista.com \
--to=amakarov@ru.mvista.com \
--cc=ext-rt-dev@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rml@ximian.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
all inboxes | Powered by JetHome®