* [PATCH RT] dont calculate hweight in update_migrate_disable
@ 2014-03-24 12:18 Nicholas Mc Guire
2014-03-24 14:18 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Nicholas Mc Guire @ 2014-03-24 12:18 UTC (permalink / raw)
To: linux-rt-users
Cc: linux-kernel, rostedt, tglx, Sebastian Andrzej Siewior,
Peter Zijlstra
Hi !
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.
Patch is on top of 3.12.13-rt21
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
---
kernel/sched/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index bf93f63..6c07fe9 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2405,7 +2405,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;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RT] dont calculate hweight in update_migrate_disable
2014-03-24 12:18 [PATCH RT] dont calculate hweight in update_migrate_disable Nicholas Mc Guire
@ 2014-03-24 14:18 ` Steven Rostedt
2014-03-28 9:35 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2014-03-24 14:18 UTC (permalink / raw)
To: Nicholas Mc Guire
Cc: linux-rt-users, linux-kernel, tglx, Sebastian Andrzej Siewior,
Peter Zijlstra
On Mon, 24 Mar 2014 13:18:48 +0100
Nicholas Mc Guire <der.herr@hofr.at> wrote:
> Hi !
>
> 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.
>
> Patch is on top of 3.12.13-rt21
>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
-- Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RT] dont calculate hweight in update_migrate_disable
2014-03-24 14:18 ` Steven Rostedt
@ 2014-03-28 9:35 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2014-03-28 9:35 UTC (permalink / raw)
To: Steven Rostedt
Cc: Nicholas Mc Guire, linux-rt-users, linux-kernel, tglx,
Peter Zijlstra
* Steven Rostedt | 2014-03-24 10:18:00 [-0400]:
>On Mon, 24 Mar 2014 13:18:48 +0100
>Nicholas Mc Guire <der.herr@hofr.at> wrote:
>
>> 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
>Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Applied.
>
>-- Steve
Sebastian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-03-28 9:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-24 12:18 [PATCH RT] dont calculate hweight in update_migrate_disable Nicholas Mc Guire
2014-03-24 14:18 ` Steven Rostedt
2014-03-28 9:35 ` Sebastian Andrzej Siewior
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).