* [PATCH] sched: Remove redundant code from can_migrate_task()
@ 2013-04-10 6:04 Zhang Hang
2013-04-10 10:53 ` [tip:sched/core] sched: Simplify can_migrate_task() tip-bot for Zhang Hang
0 siblings, 1 reply; 2+ messages in thread
From: Zhang Hang @ 2013-04-10 6:04 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra; +Cc: linux-kernel
There is no opportunity to return 1 if tsk_cache_hot is true and the expression
(env->sd->nr_balance_failed > env->sd->cache_nice_tries) is false.
Meanwhile, it's unnecessary to judge whether tsk_cache_hot is true or
false after being filtered by previous judgment.
Signed-off-by: Zhang Hang <bob.zhanghang@huawei.com>
---
kernel/sched/fair.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 7a33e59..4f7e1d0 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3929,11 +3929,8 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
return 1;
}
- if (tsk_cache_hot) {
- schedstat_inc(p, se.statistics.nr_failed_migrations_hot);
- return 0;
- }
- return 1;
+ schedstat_inc(p, se.statistics.nr_failed_migrations_hot);
+ return 0;
}
/*
--
1.7.8.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip:sched/core] sched: Simplify can_migrate_task()
2013-04-10 6:04 [PATCH] sched: Remove redundant code from can_migrate_task() Zhang Hang
@ 2013-04-10 10:53 ` tip-bot for Zhang Hang
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Zhang Hang @ 2013-04-10 10:53 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tglx, bob.zhanghang
Commit-ID: 4e2dcb73aecbde9fe4e3137c9ea35cb6aa6cb286
Gitweb: http://git.kernel.org/tip/4e2dcb73aecbde9fe4e3137c9ea35cb6aa6cb286
Author: Zhang Hang <bob.zhanghang@huawei.com>
AuthorDate: Wed, 10 Apr 2013 14:04:55 +0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 10 Apr 2013 11:15:45 +0200
sched: Simplify can_migrate_task()
At this point tsk_cache_hot is always true, so no need to check it.
Signed-off-by: Zhang Hang <bob.zhanghang@huawei.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/51650107.9040606@huawei.com
[ Also remove unnecessary schedstat #ifdefs. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/fair.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 539760e..bf8ab4f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3921,20 +3921,17 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
tsk_cache_hot = task_hot(p, env->src_rq->clock_task, env->sd);
if (!tsk_cache_hot ||
env->sd->nr_balance_failed > env->sd->cache_nice_tries) {
-#ifdef CONFIG_SCHEDSTATS
+
if (tsk_cache_hot) {
schedstat_inc(env->sd, lb_hot_gained[env->idle]);
schedstat_inc(p, se.statistics.nr_forced_migrations);
}
-#endif
+
return 1;
}
- if (tsk_cache_hot) {
- schedstat_inc(p, se.statistics.nr_failed_migrations_hot);
- return 0;
- }
- return 1;
+ schedstat_inc(p, se.statistics.nr_failed_migrations_hot);
+ return 0;
}
/*
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-10 10:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-10 6:04 [PATCH] sched: Remove redundant code from can_migrate_task() Zhang Hang
2013-04-10 10:53 ` [tip:sched/core] sched: Simplify can_migrate_task() tip-bot for Zhang Hang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).