allow preemption in recursive migrate_disable call
PATCH 1/1 allow preemption in recursive migrate_disable call
Quoted 1 line
From
a7259c360b6c8b873f5fcf6d5eed0ae78534a6c5Mon Sep 17 00:00:00 2001
From: Nicholas Mc Guire <[email protected]>
Date: Wed, 20 Nov 2013 07:22:09 +0800
Subject: [PATCH] allow preemption in recursive migrate_disable call
Minor cleanup in migrate_disable/migrate_enable. The recursive case does not need to disable preemption as it is "pinned" to the current cpu any way so it is safe to preempt it.
No functional change to migrate_disable/enable
--- kernel/sched/core.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
kernel/sched/core.c +2 -4
@@ -2418,13 +2418,12 @@ void migrate_disable(void) }#endif -preempt_disable ();if (p->migrate_disable) { p->migrate_disable++; -preempt_enable ();return ; } +preempt_disable ();preempt_lazy_disable ();pin_current_cpu (); p->migrate_disable =1 ;
@@ -2454,13 +2453,12 @@ void migrate_enable(void)#endif WARN_ON_ONCE (p->migrate_disable <=0 ); -preempt_disable ();if (migrate_disable_count (p) >1 ) { p->migrate_disable--; -preempt_enable ();return ; } +preempt_disable ();if (unlikely (migrate_disabled_updated (p))) {/* * Undo whatever update_migrate_disable() did, also see there
Signature · 1 line
1.7.3.4
Quoted 40 lines · Nicholas Mc Guire
From
a7259c360b6c8b873f5fcf6d5eed0ae78534a6c5Mon Sep 17 00:00:00 2001
From: Nicholas Mc Guire <[email protected]>
Date: Wed, 20 Nov 2013 07:22:09 +0800
Subject: [PATCH] allow preemption in recursivemigrate_disablecallMinor cleanup in migrate_disable/migrate_enable. The recursive case does not need to disable preemption as it is "pinned" to the current cpu any way so it is safe to preempt it.
No functional change to migrate_disable/enable
Signed-off-by Nicholas Mc Guire <[email protected]>--- kernel/sched/core.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)kernel/sched/core.c +1
-3@@ -2418,13 +2418,12 @@ void migrate_disable(void) }#endif -preempt_disable ();if (p->migrate_disable) { p->migrate_disable++; -preempt_enable ();return ; } +preempt_disable ();preempt_lazy_disable ();pin_current_cpu (); p->migrate_disable =1 ;@@ -2454,13 +2453,12 @@ void migrate_enable(void)#endif WARN_ON_ONCE (p->migrate_disable <=0 ); -preempt_disable ();
kernel/sched/core.c void migrate_enable(void) · line 2464
Quoted 10 lines
kernel/sched/core.c +1
-1if (migrate_disable_count (p) >1 ) { p->migrate_disable--; -preempt_enable ();return ; } +preempt_disable ();if (unlikely (migrate_disabled_updated (p))) {/* * Undo whatever update_migrate_disable() did, also see there
Is there a reason one uses p->migrate_disable and the other uses migrate_disable_count(p) ?
Other than that,
Quoted 47 lines · * Peter Zijlstra | 2013-11-21 11:19:13 [+0100]:
Quoted 46 lines · Nicholas Mc Guire
From
a7259c360b6c8b873f5fcf6d5eed0ae78534a6c5Mon Sep 17 00:00:00 2001
From: Nicholas Mc Guire <[email protected]>
Date: Wed, 20 Nov 2013 07:22:09 +0800
Subject: [PATCH] allow preemption in recursivemigrate_disablecallMinor cleanup in migrate_disable/migrate_enable. The recursive case does not need to disable preemption as it is "pinned" to the current cpu any way so it is safe to preempt it.
No functional change to migrate_disable/enable
Signed-off-by Nicholas Mc Guire <[email protected]>--- kernel/sched/core.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)kernel/sched/core.c +1
-4@@ -2418,13 +2418,12 @@ void migrate_disable(void) }#endif -preempt_disable ();if (p->migrate_disable) { p->migrate_disable++; -preempt_enable ();return ; } +preempt_disable ();preempt_lazy_disable ();pin_current_cpu (); p->migrate_disable =1 ;@@ -2454,13 +2453,12 @@ void migrate_enable(void)#endif WARN_ON_ONCE (p->migrate_disable <=0 ); -preempt_disable ();if (migrate_disable_count (p) >1 ) { p->migrate_disable--; -preempt_enable ();return ; }
Quoted 7 lines
kernel/sched/core.c void migrate_enable(void) · line 2464
Quoted 4 lines
kernel/sched/core.c +1
-0+preempt_disable ();if (unlikely (migrate_disabled_updated (p))) {/* * Undo whatever update_migrate_disable() did, also see there Is there a reason one uses
p->migrate_disableand the other usesmigrate_disable_count(p)?
After staring at code I would say migrate_disable() needs to ignore MIGRATE_DISABLE_SET_AFFIN in order to complete. In the migrate_disable() case it simply doesn't matter if it is set and it can't be set for the 0 case.
I was a little worried because the preempt_disable() also protects counter during add/substract operations but since there can only be one task at a time doing this, there should be no problem.
Quoted 3 lines
Other than that,
Acked-by Peter Zijlstra <[email protected]>
Sebastian
Quoted 47 lines · Peter Zijlstra
Quoted 46 lines · Nicholas Mc Guire
From
a7259c360b6c8b873f5fcf6d5eed0ae78534a6c5Mon Sep 17 00:00:00 2001
From: Nicholas Mc Guire <[email protected]>
Date: Wed, 20 Nov 2013 07:22:09 +0800
Subject: [PATCH] allow preemption in recursivemigrate_disablecallMinor cleanup in migrate_disable/migrate_enable. The recursive case does not need to disable preemption as it is "pinned" to the current cpu any way so it is safe to preempt it.
No functional change to migrate_disable/enable
Signed-off-by Nicholas Mc Guire <[email protected]>--- kernel/sched/core.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)kernel/sched/core.c +1
-4@@ -2418,13 +2418,12 @@ void migrate_disable(void) }#endif -preempt_disable ();if (p->migrate_disable) { p->migrate_disable++; -preempt_enable ();return ; } +preempt_disable ();preempt_lazy_disable ();pin_current_cpu (); p->migrate_disable =1 ;@@ -2454,13 +2453,12 @@ void migrate_enable(void)#endif WARN_ON_ONCE (p->migrate_disable <=0 ); -preempt_disable ();if (migrate_disable_count (p) >1 ) { p->migrate_disable--; -preempt_enable ();return ; }
Quoted 8 lines
kernel/sched/core.c void migrate_enable(void) · line 2464
Quoted 4 lines
kernel/sched/core.c +1
-0+preempt_disable ();if (unlikely (migrate_disabled_updated (p))) {/* * Undo whatever update_migrate_disable() did, also see there Is there a reason one uses
p->migrate_disableand the other usesmigrate_disable_count(p)?
in the update case incrementting is fine with or without MIGRATE_DISABLE_SET_AFFIN set, in the migrate_enable case though if the nesting level were actuall 1 and MIGRATE_DISABLE_SET_AFFIN were set we would end up in the wrong branch (1<<30)+1 > 1.
thx!
hofrat
Quoted 5 lines · * Nicholas Mc Guire | 2013-11-20 01:33:33 [+0100]:
Minor cleanup in migrate_disable/migrate_enable. The recursive case does not need to disable preemption as it is "pinned" to the current cpu any way so it is safe to preempt it.
No functional change to migrate_disable/enable
applied but I dropped this line^
Quoted 2 lines
Signed-off-by Nicholas Mc Guire <[email protected]>
Sebastian