Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
d0c451f8
Commit
d0c451f8
authored
Mar 05, 2003
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
0da6b746
76e3413d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
25 deletions
+43
-25
include/linux/sched.h
include/linux/sched.h
+1
-1
kernel/fork.c
kernel/fork.c
+1
-1
kernel/sched.c
kernel/sched.c
+41
-23
No files found.
include/linux/sched.h
View file @
d0c451f8
...
@@ -328,7 +328,7 @@ struct task_struct {
...
@@ -328,7 +328,7 @@ struct task_struct {
prio_array_t
*
array
;
prio_array_t
*
array
;
unsigned
long
sleep_avg
;
unsigned
long
sleep_avg
;
unsigned
long
sleep_timestamp
;
unsigned
long
last_run
;
unsigned
long
policy
;
unsigned
long
policy
;
unsigned
long
cpus_allowed
;
unsigned
long
cpus_allowed
;
...
...
kernel/fork.c
View file @
d0c451f8
...
@@ -916,7 +916,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
...
@@ -916,7 +916,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
*/
*/
p
->
first_time_slice
=
1
;
p
->
first_time_slice
=
1
;
current
->
time_slice
>>=
1
;
current
->
time_slice
>>=
1
;
p
->
sleep_timestamp
=
jiffies
;
p
->
last_run
=
jiffies
;
if
(
!
current
->
time_slice
)
{
if
(
!
current
->
time_slice
)
{
/*
/*
* This case is rare, it happens when the parent has only
* This case is rare, it happens when the parent has only
...
...
kernel/sched.c
View file @
d0c451f8
...
@@ -54,20 +54,19 @@
...
@@ -54,20 +54,19 @@
/*
/*
* These are the 'tuning knobs' of the scheduler:
* These are the 'tuning knobs' of the scheduler:
*
*
* Minimum timeslice is 10 msecs, default timeslice is 1
5
0 msecs,
* Minimum timeslice is 10 msecs, default timeslice is 1
0
0 msecs,
* maximum timeslice is
3
00 msecs. Timeslices get refilled after
* maximum timeslice is
2
00 msecs. Timeslices get refilled after
* they expire.
* they expire.
*/
*/
#define MIN_TIMESLICE ( 10 * HZ / 1000)
#define MIN_TIMESLICE ( 10 * HZ / 1000)
#define MAX_TIMESLICE (
3
00 * HZ / 1000)
#define MAX_TIMESLICE (
2
00 * HZ / 1000)
#define CHILD_PENALTY
95
#define CHILD_PENALTY
50
#define PARENT_PENALTY 100
#define PARENT_PENALTY 100
#define EXIT_WEIGHT 3
#define EXIT_WEIGHT 3
#define PRIO_BONUS_RATIO 25
#define PRIO_BONUS_RATIO 25
#define INTERACTIVE_DELTA 2
#define INTERACTIVE_DELTA 2
#define MAX_SLEEP_AVG (2*HZ)
#define MAX_SLEEP_AVG (10*HZ)
#define STARVATION_LIMIT (2*HZ)
#define STARVATION_LIMIT (10*HZ)
#define NODE_THRESHOLD 125
/*
/*
* If a task is 'interactive' then we reinsert it in the active
* If a task is 'interactive' then we reinsert it in the active
...
@@ -323,16 +322,21 @@ static inline int effective_prio(task_t *p)
...
@@ -323,16 +322,21 @@ static inline int effective_prio(task_t *p)
* Also update all the scheduling statistics stuff. (sleep average
* Also update all the scheduling statistics stuff. (sleep average
* calculation, priority modifiers, etc.)
* calculation, priority modifiers, etc.)
*/
*/
static
inline
void
__activate_task
(
task_t
*
p
,
runqueue_t
*
rq
)
{
enqueue_task
(
p
,
rq
->
active
);
rq
->
nr_running
++
;
}
static
inline
void
activate_task
(
task_t
*
p
,
runqueue_t
*
rq
)
static
inline
void
activate_task
(
task_t
*
p
,
runqueue_t
*
rq
)
{
{
unsigned
long
sleep_time
=
jiffies
-
p
->
sleep_timestamp
;
unsigned
long
sleep_time
=
jiffies
-
p
->
last_run
;
prio_array_t
*
array
=
rq
->
active
;
if
(
!
rt_task
(
p
)
&&
sleep_time
)
{
if
(
!
rt_task
(
p
)
&&
sleep_time
)
{
/*
/*
* This code gives a bonus to interactive tasks. We update
* This code gives a bonus to interactive tasks. We update
* an 'average sleep time' value here, based on
* an 'average sleep time' value here, based on
*
sleep_timestamp
. The more time a task spends sleeping,
*
->last_run
. The more time a task spends sleeping,
* the higher the average gets - and the higher the priority
* the higher the average gets - and the higher the priority
* boost gets as well.
* boost gets as well.
*/
*/
...
@@ -345,11 +349,9 @@ static inline void activate_task(task_t *p, runqueue_t *rq)
...
@@ -345,11 +349,9 @@ static inline void activate_task(task_t *p, runqueue_t *rq)
if
(
!
in_interrupt
())
if
(
!
in_interrupt
())
current
->
sleep_avg
=
ticks
;
current
->
sleep_avg
=
ticks
;
}
}
p
->
prio
=
effective_prio
(
p
);
p
->
prio
=
effective_prio
(
p
);
}
}
enqueue_task
(
p
,
array
);
__activate_task
(
p
,
rq
);
nr_running_inc
(
rq
);
}
}
/*
/*
...
@@ -486,10 +488,13 @@ static int try_to_wake_up(task_t * p, unsigned int state, int sync)
...
@@ -486,10 +488,13 @@ static int try_to_wake_up(task_t * p, unsigned int state, int sync)
}
}
if
(
old_state
==
TASK_UNINTERRUPTIBLE
)
if
(
old_state
==
TASK_UNINTERRUPTIBLE
)
rq
->
nr_uninterruptible
--
;
rq
->
nr_uninterruptible
--
;
if
(
sync
)
__activate_task
(
p
,
rq
);
else
{
activate_task
(
p
,
rq
);
activate_task
(
p
,
rq
);
if
(
p
->
prio
<
rq
->
curr
->
prio
)
if
(
p
->
prio
<
rq
->
curr
->
prio
)
resched_task
(
rq
->
curr
);
resched_task
(
rq
->
curr
);
}
success
=
1
;
success
=
1
;
}
}
p
->
state
=
TASK_RUNNING
;
p
->
state
=
TASK_RUNNING
;
...
@@ -532,8 +537,16 @@ void wake_up_forked_process(task_t * p)
...
@@ -532,8 +537,16 @@ void wake_up_forked_process(task_t * p)
p
->
prio
=
effective_prio
(
p
);
p
->
prio
=
effective_prio
(
p
);
}
}
set_task_cpu
(
p
,
smp_processor_id
());
set_task_cpu
(
p
,
smp_processor_id
());
activate_task
(
p
,
rq
);
if
(
unlikely
(
!
current
->
array
))
__activate_task
(
p
,
rq
);
else
{
p
->
prio
=
current
->
prio
;
list_add_tail
(
&
p
->
run_list
,
&
current
->
run_list
);
p
->
array
=
current
->
array
;
p
->
array
->
nr_active
++
;
rq
->
nr_running
++
;
}
task_rq_unlock
(
rq
,
&
flags
);
task_rq_unlock
(
rq
,
&
flags
);
}
}
...
@@ -960,6 +973,11 @@ static inline void pull_task(runqueue_t *src_rq, prio_array_t *src_array, task_t
...
@@ -960,6 +973,11 @@ static inline void pull_task(runqueue_t *src_rq, prio_array_t *src_array, task_t
*/
*/
if
(
p
->
prio
<
this_rq
->
curr
->
prio
)
if
(
p
->
prio
<
this_rq
->
curr
->
prio
)
set_need_resched
();
set_need_resched
();
else
{
if
(
p
->
prio
==
this_rq
->
curr
->
prio
&&
p
->
time_slice
>
this_rq
->
curr
->
time_slice
)
set_need_resched
();
}
}
}
/*
/*
...
@@ -1023,7 +1041,7 @@ static void load_balance(runqueue_t *this_rq, int idle)
...
@@ -1023,7 +1041,7 @@ static void load_balance(runqueue_t *this_rq, int idle)
*/
*/
#define CAN_MIGRATE_TASK(p,rq,this_cpu) \
#define CAN_MIGRATE_TASK(p,rq,this_cpu) \
((jiffies - (p)->
sleep_timestamp
> cache_decay_ticks) && \
((jiffies - (p)->
last_run
> cache_decay_ticks) && \
!task_running(rq, p) && \
!task_running(rq, p) && \
((p)->cpus_allowed & (1UL << (this_cpu))))
((p)->cpus_allowed & (1UL << (this_cpu))))
...
@@ -1083,9 +1101,9 @@ DEFINE_PER_CPU(struct kernel_stat, kstat) = { { 0 } };
...
@@ -1083,9 +1101,9 @@ DEFINE_PER_CPU(struct kernel_stat, kstat) = { { 0 } };
* increasing number of running tasks:
* increasing number of running tasks:
*/
*/
#define EXPIRED_STARVING(rq) \
#define EXPIRED_STARVING(rq) \
((rq)->expired_timestamp && \
(
STARVATION_LIMIT && (
(rq)->expired_timestamp && \
(jiffies - (rq)->expired_timestamp >= \
(jiffies - (rq)->expired_timestamp >= \
STARVATION_LIMIT * ((rq)->nr_running) + 1))
STARVATION_LIMIT * ((rq)->nr_running) + 1))
)
/*
/*
* This function gets called by the timer code, with HZ frequency.
* This function gets called by the timer code, with HZ frequency.
...
@@ -1208,7 +1226,7 @@ asmlinkage void schedule(void)
...
@@ -1208,7 +1226,7 @@ asmlinkage void schedule(void)
rq
=
this_rq
();
rq
=
this_rq
();
release_kernel_lock
(
prev
);
release_kernel_lock
(
prev
);
prev
->
sleep_timestamp
=
jiffies
;
prev
->
last_run
=
jiffies
;
spin_lock_irq
(
&
rq
->
lock
);
spin_lock_irq
(
&
rq
->
lock
);
/*
/*
...
@@ -1708,7 +1726,7 @@ static int setscheduler(pid_t pid, int policy, struct sched_param *param)
...
@@ -1708,7 +1726,7 @@ static int setscheduler(pid_t pid, int policy, struct sched_param *param)
else
else
p
->
prio
=
p
->
static_prio
;
p
->
prio
=
p
->
static_prio
;
if
(
array
)
if
(
array
)
activate_task
(
p
,
task_rq
(
p
));
__
activate_task
(
p
,
task_rq
(
p
));
out_unlock:
out_unlock:
task_rq_unlock
(
rq
,
&
flags
);
task_rq_unlock
(
rq
,
&
flags
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment