sched/core: Remove wakeup_gran with single call calc_delta_fair
PATCH 1/1 sched/core: Remove wakeup_gran with single call calc_delta_fair
This patch removes function wakeup_gran and its call by calling directly calc_delta_fair function with sysctl_sched_wakeup_granularity and se as arguments.
--- kernel/sched/fair.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-)
kernel/sched/fair.c +16 -22
@@ -4927,27 +4927,6 @@ migrate_task_rq_fair(struct task_struct *p, int next_cpu) }#endif /* CONFIG_SMP */ -static unsigned long -wakeup_gran (struct sched_entity *curr,struct sched_entity *se) -{ -unsigned long gran = sysctl_sched_wakeup_granularity; - -/* -* Since its curr running now, convert the gran from real-time -* to virtual-time in his units. -* -* By using 'se' instead of 'curr' we penalize light tasks, so -* they get preempted easier. That is, if 'se' < 'curr' then -* the resulting gran will be larger, therefore penalizing the -* lighter, if otoh 'se' > 'curr' then the resulting gran will -* be smaller, again penalizing the lighter task. -* -* This is especially important for buddies when the leftmost -* task is higher priority than the buddy. -*/ -return calc_delta_fair (gran, se); -} -/* * Should 'se' preempt 'curr'. *
@@ -4970,7 +4949,22 @@ wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se)if (vdiff <=0 )return -1 ; - gran =wakeup_gran (curr, se); +/* +* Since its curr running now, convert the gran from real-time +* to virtual-time in his units. +* +* By using 'se' instead of 'curr' we penalize light tasks, so +* they get preempted easier. That is, if 'se' < 'curr' then +* the resulting gran will be larger, therefore penalizing the +* lighter, if otoh 'se' > 'curr' then the resulting gran will +* be smaller, again penalizing the lighter task. +* +* This is especially important for buddies when the leftmost +* task is higher priority than the buddy. +*/ + + gran =calc_delta_fair (sysctl_sched_wakeup_granularity, se); +if (vdiff > gran)return 1 ;
Signature · 1 line
1.9.1
Peter Zijlstra
maintainerQuoted 2 lines · Abel Vesa
This patch removes function
wakeup_granand its call by calling directlycalc_delta_fairfunction withsysctl_sched_wakeup_granularityand se as arguments.
But why?
Quoted 5 lines · Peter Zijlstra
Quoted 2 lines · Abel Vesa
This patch removes function
wakeup_granand its call by calling directlycalc_delta_fairfunction withsysctl_sched_wakeup_granularityand se as arguments.But why?
I was thinking that maybe reducing another function call would be a better idea. I don't see what's the point of calling a 'wakeup_gran' just to declare 'gran' as local variable and then
call calc_delta_fair instead of calling directly calc_delta_fair. Plus, I think it seems more
readable to me. Of course, I might be wrong.
Quoted 10 lines · Abel Vesa
On Tue, Apr 7, 2015 at 1:30 PM, Peter Zijlstra <[email protected]
Quoted 8 lines
wrote:
Quoted 4 lines · Abel Vesa
This patch removes function
wakeup_granand its call by calling directlycalc_delta_fairfunction withsysctl_sched_wakeup_granularityand se as arguments.But why?
Quoted 7 lines
I was thinking that maybe reducing another function call would be a better idea.
I don't see what's the point of calling a 'wakeup_gran' just to declare 'gran' as local variable and then
callcalc_delta_fairinstead of calling directlycalc_delta_fair. Plus, I think it seems more
readable to me. Of course, I might be wrong.
I expected it be inlined by gcc, but that didn't happen with gcc-4.8.3.
-Mike
Quoted 19 lines · Mike Galbraith
Quoted 10 lines · Abel Vesa
On Tue, Apr 7, 2015 at 1:30 PM, Peter Zijlstra <[email protected]
Quoted 8 lines
wrote:
Quoted 4 lines · Abel Vesa
This patch removes function
wakeup_granand its call by calling directlycalc_delta_fairfunction withsysctl_sched_wakeup_granularityand se as arguments.But why?
Quoted 7 lines
I was thinking that maybe reducing another function call would be a better idea.
I don't see what's the point of calling a 'wakeup_gran' just to declare 'gran' as local variable and then
callcalc_delta_fairinstead of calling directlycalc_delta_fair. Plus, I think it seems more
readable to me. Of course, I might be wrong.
Quoted 3 lines
I expected it be inlined by gcc, but that didn't happen with gcc-4.8.3.
-Mike
well, I really don't know what to say but I got curious too and I compiled it with:
gcc (Ubuntu/Linaro 4.6.4-6ubuntu2) 4.6.4
and then did a objdump and got this:
0000010c <wakeup_preempt_entity>:
10c: e92d4038 push {r3, r4, r5, lr}
110: e1c123d0 ldrd r2, [r1, #48] ; 0x30
114: e1c043d0 ldrd r4, [r0, #48] ; 0x30
118: e0544002 subs r4, r4, r2
11c: e0c55003 sbc r5, r5, r3
120: e3540001 cmp r4, #1
124: e2d53000 sbcs r3, r5, #0
128: ba00000b blt 15c <wakeup_preempt_entity+0x50>
12c: e5912000 ldr r2, [r1]
130: e59f3040 ldr r3, [pc, #64] ; 178
<wakeup_preempt_entity+0x6c>
134: e3520b01 cmp r2, #1024 ; 0x400
138: e5930000 ldr r0, [r3]
13c: 1a000008 bne 164 <wakeup_preempt_entity+0x58>
140: e1a02000 mov r2, r0
144: e3a03000 mov r3, #0
148: e1520004 cmp r2, r4
14c: e0d31005 sbcs r1, r3, r5
150: a3a00000 movge r0, #0
154: b3a00001 movlt r0, #1
158: e8bd8038 pop {r3, r4, r5, pc}
15c: e3e00000 mvn r0, #0
160: e8bd8038 pop {r3, r4, r5, pc}
164: e1a03001 mov r3, r1
168: e3a02b01 mov r2, #1024 ; 0x400
16c: e3a01000 mov r1, #0
170: ebffffa2 bl 0 <__calc_delta>
174: eafffff1 b 140 <wakeup_preempt_entity+0x34>
178: 00000000 .word 0x000000000000017c <sched_slice>:
.....
Now ofcourse, I'm not an ARM assembly language expert but I don't think there is
any kind of branch instruction to something called 'wakeup_gran' , so I guess Peter was right, at least this version of gcc says so.