remove unlikelys
Subsystems (2)
Ingo,
The differences between v1 and v2 is that I only included the non controversial patches. I also modified the change log of pre_schedule_rt to include the annotated branch profiler output.
I just did a force push, so please use ssh, or verify that only these three patches are present.
Thanks,
-- Steve
Please pull the latest annotate-branch/cleanups tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
annotate-branch/cleanups
Steven Rostedt (3):
sched: remove unlikely in pre_schedule_rt
sched: remove unlikelys from sched_move_task
mm: remove unlikelys for unlock in rmap.c
----
kernel/sched.c | 4 ++-- kernel/sched_rt.c | 2 +- mm/rmap.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-)
PATCH v2 1/3 sched: remove unlikely in pre_schedule_rt
From: Steven Rostedt <[email protected]>
Impact: clean up
The annotated branch profiler shows that the unlikely used by pre_schedule_rt is always incorrect. This makes sense because in sched.c we have:
if (prev->sched_class->pre_schedule) prev->sched_class->pre_schedule(rq, prev);
And we are saying that prev is unlikely to be an rt task. This looks more like a likely candidate to me.
Here's the annotated branch profiler output:
correct incorrect % Function File Line ------- --------- - -------- ---- ----
0 4244 100 pre_schedule_rt sched_rt.c 1263
--- kernel/sched_rt.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched_rt.c +1 -1
@@ -1260,7 +1260,7 @@ static int pull_rt_task(struct rq *this_rq)static void pre_schedule_rt (struct rq *rq,struct task_struct *prev) {/* Try to pull RT tasks here if we lower this rq's prio */ -if (unlikely (rt_task (prev)) && rq->rt.highest_prio > prev->prio) +if (rt_task (prev) && rq->rt.highest_prio > prev->prio)pull_rt_task (rq); }
Signature · 3 lines
1.6.2 --
PATCH v2 2/3 sched: remove unlikelys from sched_move_task
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Impact: clean up
We seem to be moving running tasks more than non running tasks. I guess tasks like to move themselves.
These are also candidates for likely:
correct incorrect % Function File Line
------- --------- - -------- ---- ----
0 10027 100 sched_move_task sched.c 8918
0 10027 100 sched_move_task sched.c 8908--- kernel/sched.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched.c +2 -2
@@ -8905,7 +8905,7 @@ void sched_move_task(struct task_struct *tsk)if (on_rq)dequeue_task (rq, tsk,0 ); -if (unlikely (running)) +if (running) tsk->sched_class->put_prev_task (rq, tsk);set_task_rq (tsk,task_cpu (tsk));
@@ -8915,7 +8915,7 @@ void sched_move_task(struct task_struct *tsk) tsk->sched_class->moved_group (tsk);#endif -if (unlikely (running)) +if (running) tsk->sched_class->set_curr_task (rq);if (on_rq)enqueue_task (rq, tsk,0 );
Signature · 3 lines
1.6.2 --
PATCH v2 3/3 mm: remove unlikelys for unlock in rmap.c
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Impact: clean up
The annotated branch profiler shows that the rmap calls are likely called with unlock set.
correct incorrect % Function File Line
------- --------- - -------- ---- ----
0 46100 100 try_to_unmap_anon rmap.c 1013
0 46100 100 try_to_unmap_anon rmap.c 1005
0 5763 100 try_to_unmap_file rmap.c 1074
0 5763 100 try_to_unmap_file rmap.c 1069--- mm/rmap.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
mm/rmap.c +4 -4
@@ -1002,7 +1002,7 @@ static int try_to_unmap_anon(struct page *page, int unlock, int migration)unsigned int mlocked =0 ;int ret =SWAP_AGAIN ; -if (MLOCK_PAGES &&unlikely (unlock)) +if (MLOCK_PAGES && unlock) ret =SWAP_SUCCESS ;/* default for try_to_munlock() */ anon_vma =page_lock_anon_vma (page);
@@ -1010,7 +1010,7 @@ static int try_to_unmap_anon(struct page *page, int unlock, int migration)return ret;list_for_each_entry (vma, &anon_vma->head, anon_vma_node) { -if (MLOCK_PAGES &&unlikely (unlock)) { +if (MLOCK_PAGES && unlock) {if (!((vma->vm_flags &VM_LOCKED ) &&page_mapped_in_vma (page, vma)))continue ;/* must visit all unlocked vmas */
@@ -1066,12 +1066,12 @@ static int try_to_unmap_file(struct page *page, int unlock, int migration)unsigned int mapcount;unsigned int mlocked =0 ; -if (MLOCK_PAGES &&unlikely (unlock)) +if (MLOCK_PAGES && unlock) ret =SWAP_SUCCESS ;/* default for try_to_munlock() */ spin_lock (&mapping->i_mmap_lock); vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) { -if (MLOCK_PAGES &&unlikely (unlock)) { +if (MLOCK_PAGES && unlock) {if (!((vma->vm_flags &VM_LOCKED ) &&page_mapped_in_vma (page, vma)))continue ;/* must visit all vmas */
Signature · 3 lines
1.6.2 --
Quoted 3 lines · Steven Rostedt
I just did a force push, so please use ssh, or verify that only these three patches are present.
Here's the HEAD SHA1:
79210dd022b4d7f6f75aeb7d508a3f75fabaae4c
-- Steve
Quoted 9 lines · Steven Rostedt
Ingo,
The differences between v1 and v2 is that I only included the non controversial patches. I also modified the change log of
pre_schedule_rtto include the annotated branch profiler output.mm: remove unlikelys for unlock in
rmap.cmm/rmap.c | 8 ++++----
the rmap.c thing looks uncontroversial to me, but an MM person should still have a look and Ack it.
Ingo