sched: leave sched_setscheduler earlier if possible.
PATCH 1/1 sched: leave sched_setscheduler earlier if possible.
sched_setscheduler (in sched.c) is called in order of changing the scheduling policy and/or the real-time priority of a task. Thus, if we find out that neither of those are actually being modified, it is possible to return earlier and save the overhead of a full deactivate+activate cycle of the task in question.
Beside that, if we have more than one SCHED_FIFO task with the same priority on the same rq (which means they share the same priority queue) having one of them changing its position in the priority queue because of a sched_setscheduler (as it happens by means of the deactivate+activate) that does not actually change the priority violates POSIX which states, for SCHED_FIFO:
"If a thread whose policy or priority has been modified by pthread_setschedprio() is a running thread or is runnable, the effect on its position in the thread list depends on the direction of the modification, as follows: a. <...> b. If the priority is unchanged, the thread does not change position in the thread list. c. <...>"
(http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_08.html)
--- kernel/sched.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
kernel/sched.c +10 -0
@@ -4998,6 +4998,16 @@ recheck:return -EINVAL ; } +/* +* If not changing anything there's no need to proceed further +*/ +if (unlikely (policy == p->policy && (!rt_policy (policy) || + param->sched_priority == p->rt_priority))) { +__task_rq_unlock (rq); +raw_spin_unlock_irqrestore (&p->pi_lock, flags); +return 0 ; + } +#ifdef CONFIG_RT_GROUP_SCHED if (user) {/*
Signature · 8 lines
1.7.4.1 -- <<This happens because I choose it to happen!>> (Raistlin Majere) ---------------------------------------------------------------------- Dario Faggioli, ReTiS Lab, Scuola Superiore Sant'Anna, Pisa (Italy) http://retis.sssup.it/people/faggioli -- [email protected]
Quoted 19 lines · Dario Faggioli
sched_setscheduler(insched.c) is called in order of changing the scheduling policy and/or the real-time priority of a task. Thus, if we find out that neither of those are actually being modified, it is possible to return earlier and save the overhead of a full deactivate+activate cycle of the task in question.Beside that, if we have more than one
SCHED_FIFOtask with the same priority on the same rq (which means they share the same priority queue) having one of them changing its position in the priority queue because of asched_setscheduler(as it happens by means of the deactivate+activate) that does not actually change the priority violates POSIX which states, forSCHED_FIFO:"If a thread whose policy or priority has been modified by
pthread_setschedprio()is a running thread or is runnable, the effect on its position in the thread list depends on the direction of the modification, as follows: a. <...> b. If the priority is unchanged, the thread does not change position in the thread list. c. <...>"
Quoted 3 lines
(http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_08.html)
Signed-off-by Dario Faggioli <[email protected]>
kernel/sched.c recheck:
Quoted 11 lines
--- kernel/sched.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)kernel/sched.c +0
-0@@ -4998,6 +4998,16 @@ recheck:
Peter, this is why I prefer:
recheck:
over
recheck:
-- Steve
Quoted 19 lines
kernel/sched.c +10
-0return -EINVAL ; } +/* +* If not changing anything there's no need to proceed further +*/ +if (unlikely (policy == p->policy && (!rt_policy (policy) || + param->sched_priority == p->rt_priority))) { +__task_rq_unlock (rq); +raw_spin_unlock_irqrestore (&p->pi_lock, flags); +return 0 ; + } +#ifdef CONFIG_RT_GROUP_SCHED if (user) {/* Signature · 1 line
1.7.4.1
Quoted 8 lines · Steven Rostedt
Review recheck:
Quoted 1 line
(quoted diff) +0
-0@@ -4998,6 +4998,16 @@ recheck:Peter, this is why I prefer:
recheck:
over
recheck:
And you know I prefer to fix the tools ;-)
Quoted 10 lines · Peter Zijlstra
Quoted 8 lines · Steven Rostedt
Review recheck:
Quoted 1 line
(quoted diff) +0
-0@@ -4998,6 +4998,16 @@ recheck:Peter, this is why I prefer:
recheck:
over
recheck:And you know I prefer to fix the tools ;-)
And when the tools are fixed, I'll also prefer
recheck:
over
recheck:
;-)
-- Steve
Quoted 4 lines · Steven Rostedt
Quoted 1 line
And you know I prefer to fix the tools ;-)
And when the tools are fixed, I'll also prefer
So instead of complaining about it, tell people to use:
QUILT_DIFF_OPTS="-F ^[[:alpha:]\$_].*[^:]\$"
Just like you tell them about all your other patch style issues.
Junio, know of any way to make git-diff do the same? The purpose is to skip labels as functions so that people stop doing stupid crap like indenting labels, eg.:
void foo(void)
{
again:
/* do stuff */ if (retry) goto again; }
instead of the normal:
void foo(void)
{
again:
/* do stuff */ if (retry) goto again; }
Quoted 7 lines · Peter Zijlstra
Junio, know of any way to make git-diff do the same? The purpose is to skip labels as functions so that people stop doing stupid crap like indenting labels, eg.:
void foo(void)
{
again:
Perhaps "git help attributes" and look for "funcname"?
Quoted 11 lines · Junio C Hamano
Quoted 7 lines · Peter Zijlstra
Junio, know of any way to make git-diff do the same? The purpose is to skip labels as functions so that people stop doing stupid crap like indenting labels, eg.:
void foo(void)
{
again:Perhaps "git help attributes" and look for "funcname"?
Awesome so the diff.$foo.xfuncname is about what I want, except I seem to need a .gitattributes file per repository.
Is there a way to over-ride the default in a global way so that I can only change ~/.gitconfig and not bother with all various repos I have?
Another question, the built-in patterns consist of multiple regexes, can custom patterns also have multiple?
So what worked for me was:
~/.gitconfig:
[diff "cpp"]
xfuncname = "^[[:alpha:]$_].*[^:]$"
and linux-2.6/.gitattributes:
*.h diff=cpp
*.c diff=cpp
What I tried was:
[diff]
xfuncname = "^[[:alpha:]$_].*[^:]$"
But that didn't seem to work.. I also tried ~/.gitattributes, but again, no joy.
Quoted 22 lines · Peter Zijlstra
Awesome so the diff.$foo.xfuncname is about what I want, except I seem to need a .gitattributes file per repository.
Is there a way to over-ride the default in a global way so that I can only change ~/.gitconfig and not bother with all various repos I have?
Another question, the built-in patterns consist of multiple regexes, can custom patterns also have multiple?
So what worked for me was:
~/.gitconfig:
[diff "cpp"]
xfuncname = "^[[:alpha:]$_].*[^:]$"and linux-2.6/.gitattributes:
*.h diff=cpp
*.c diff=cpp
Quoted 7 lines
What I tried was:
[diff]
xfuncname = "^[[:alpha:]$_].*[^:]$"But that didn't seem to work.. I also tried ~/.gitattributes, but again, no joy.
D0'h, so what worked is:
# cat ~/.gitconfig
[diff "default"]
xfuncname = "^[[:alpha:]$_].*[^:]$"[tip:sched/urgent] sched: Leave sched_setscheduler() earlier if possible, do not disturb SCHED_FIFO tasks
In reply to Dario FaggioliCommit-ID: a51e91981870d013fcfcc08b0117997edbcbc7a7 Gitweb: http://git.kernel.org/tip/a51e91981870d013fcfcc08b0117997edbcbc7a7 Author: Dario Faggioli <[email protected]> AuthorDate: Thu, 24 Mar 2011 14:00:18 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 31 Mar 2011 13:00:34 +0200
sched: Leave sched_setscheduler() earlier if possible, do not disturb SCHED_FIFO tasks
sched_setscheduler() (in sched.c) is called in order of changing the scheduling policy and/or the real-time priority of a task. Thus, if we find out that neither of those are actually being modified, it is possible to return earlier and save the overhead of a full deactivate+activate cycle of the task in question.
Beside that, if we have more than one SCHED_FIFO task with the same priority on the same rq (which means they share the same priority queue) having one of them changing its position in the priority queue because of a sched_setscheduler (as it happens by means of the deactivate+activate) that does not actually change the priority violates POSIX which states, for SCHED_FIFO:
"If a thread whose policy or priority has been modified by
pthread_setschedprio() is a running thread or is runnable, the effect on its position in the thread list depends on the direction of the modification, as follows: a. <...> b. If the priority is unchanged, the thread does not change position in the thread list. c. <...>"
http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_08.html
(ed: And the POSIX specification here does, briefly and somewhat unexpectedly,
match what common sense tells us as well. )
LKML-Reference: <1300971618.3960.82.camel@Palantir>
--- kernel/sched.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
kernel/sched.c +11 -0
@@ -5011,6 +5011,17 @@ recheck:return -EINVAL ; } +/* +* If not changing anything there's no need to proceed further: +*/ +if (unlikely (policy == p->policy && (!rt_policy (policy) || + param->sched_priority == p->rt_priority))) { + +__task_rq_unlock (rq); +raw_spin_unlock_irqrestore (&p->pi_lock, flags); +return 0 ; + } +#ifdef CONFIG_RT_GROUP_SCHED if (user) {/*