summaryrefslogtreecommitdiff
path: root/kernel/sched
diff options
context:
space:
mode:
authorNicholas Mc Guire <der.herr@hofr.at>2014-03-24 12:18:48 (GMT)
committerScott Wood <scottwood@freescale.com>2015-02-13 22:20:38 (GMT)
commitf5e9815f9b16593fb920676cd159f9e8f342e804 (patch)
treefe916c15494a063fd65d370c39dc19ee38fcc465 /kernel/sched
parent5548232be0d297a23436de5de936855316bb02bb (diff)
downloadlinux-fsl-qoriq-f5e9815f9b16593fb920676cd159f9e8f342e804.tar.xz
sched: dont calculate hweight in update_migrate_disable()
Proposal for a minor optimization in update_migrate_disable - its only a few instructions saved but those are in the hot path of locks so it might be worth it When being scheduled out while migrate_disable > 0 and migrate_disabled_updated is not yet set we end up here (kernel/sched/core.c): static inline void update_migrate_disable(struct task_struct *p) { ... mask = tsk_cpus_allowed(p); if (p->sched_class->set_cpus_allowed) p->sched_class->set_cpus_allowed(p, mask); p->nr_cpus_allowed = cpumask_weight(mask); as we only can get here if migrate_disable > 0 there is no need to calculate the cpumask_weight(mask) as tsk_cpus_allowed in that case will return cpumask_of(task_cpu(p)) which only can have a hamming weight of 1 anyway. So we can simply do: p->nr_cpus_allowed = 1; without changing the behavior. Reviewed-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Diffstat (limited to 'kernel/sched')
-rw-r--r--kernel/sched/core.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 8123f8a..123d2ec 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2394,7 +2394,8 @@ static inline void update_migrate_disable(struct task_struct *p)
if (p->sched_class->set_cpus_allowed)
p->sched_class->set_cpus_allowed(p, mask);
- p->nr_cpus_allowed = cpumask_weight(mask);
+ /* mask==cpumask_of(task_cpu(p)) which has a cpumask_weight==1 */
+ p->nr_cpus_allowed = 1;
/* Let migrate_enable know to fix things back up */
p->migrate_disable |= MIGRATE_DISABLE_SET_AFFIN;