Skip to contentSkip to conversation

pin_current_cpu: move preempt_enable() outside

PATCH In review Tiejun Chen 2 participants 2 messages Nov 7, 2013 CPU hotplug

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pin_current_cpu: move preempt_enable() outside

It should make better sense than before.

---
 kernel/cpu.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/cpu.c +1 -2
index da6e128..7b1853f 100644
@@ -124,12 +124,11 @@ retry:
 		return;
 	}
 
+	preempt_enable();
 	if (hp->grab_lock) {
-		preempt_enable();
 		hotplug_lock(hp);
 		hotplug_unlock(hp);
 	} else {
-		preempt_enable();
 		/*
 		 * Try to push this task off of this CPU.
 		 */
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 1 line · On Thu, 7 Nov 2013 11:07:30 +0800 Tiejun Chen <[email protected]> wrote:

It should make better sense than before.

But this change log makes no sense.

Quoted 11 lines
---
 kernel/cpu.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/cpu.c +0 -0
index da6e128..7b1853f 100644

kernel/cpu.c retry: · line 128

Quoted 6 lines
kernel/cpu.c +1 -1
@@ -124,12 +124,11 @@ retry:
 		return;
 	}
 
+	preempt_enable();
 	if (hp->grab_lock) {
-		preempt_enable();

Just because we may enable preemption in both if branches, the decision for which branch to take must still be determined under preempt disable, otherwise things may no longer apply.

That said, I'm not sure if it matters if we do enable preemption before the check or not. But I rather not blindly do so without looking at how that affects things. There's some subtle races between setting grab_lock and running the sync_task. It may not matter if we enabled preemption before the check, but it will take a bit of thought before that can be decided.

-- Steve

Quoted 7 lines
kernel/cpu.c +0 -1
 		hotplug_lock(hp);
 		hotplug_unlock(hp);
 	} else {
-		preempt_enable();
 		/*
 		 * Try to push this task off of this CPU.
 		 */