Skip to contentSkip to conversation

cpu_relax(): ptrace.c coding style fix

PATCH In review Andreas Mohr 3 participants 4 messages Jun 21, 2006 – Jun 22, 2006 ptrace support

lore
Share & tools
lore
#0 lore raw

PATCH 6/6 cpu_relax(): ptrace.c coding style fix

Fix existing cpu_relax() loop to have proper kernel style.

Tested on 2.6.17-mm1.

kernel/ptrace.c +1 -2
diff -urN linux-2.6.17-mm1.orig/kernel/ptrace.c linux-2.6.17-mm1.my/kernel/ptrace.c
@@ -182,9 +182,8 @@
 	if (!write_trylock(&tasklist_lock)) {
 		local_irq_enable();
 		task_unlock(task);
-		do {
+		while (!write_can_lock(&tasklist_lock))
 			cpu_relax();
-		} while (!write_can_lock(&tasklist_lock));
 		goto repeat;
 	}
 
#1 lore raw
Quoted 3 lines · Andreas Mohr

Fix existing cpu_relax() loop to have proper kernel style.

...

kernel/ptrace.c line 187

Quoted 8 lines
kernel/ptrace.c +1 -2
@@ -182,9 +182,8 @@
 	if (!write_trylock(&tasklist_lock)) {
 		local_irq_enable();
 		task_unlock(task);
-		do {
+		while (!write_can_lock(&tasklist_lock))
 			cpu_relax();
-		} while (!write_can_lock(&tasklist_lock));

This is a change in behavior, not just style. (And there is nothing wrong with the current style.)

#2 lore raw
Quoted 7 lines · Nathan Lynch
Quoted 3 lines · Andreas Mohr

Fix existing cpu_relax() loop to have proper kernel style.

...

Quoted 11 lines

kernel/ptrace.c line 187

Quoted 8 lines
kernel/ptrace.c +1 -2
@@ -182,9 +182,8 @@
 	if (!write_trylock(&tasklist_lock)) {
 		local_irq_enable();
 		task_unlock(task);
-		do {
+		while (!write_can_lock(&tasklist_lock))
 			cpu_relax();
-		} while (!write_can_lock(&tasklist_lock));

This is a change in behavior, not just style. (And there is nothing wrong with the current style.)

Ick, right, this could cause the new state to be visible in the 2nd iteration only.

Thanks! Discard this change please.

Andreas Mohr

#3 lore raw
In reply to Andreas Mohr

Hi!

Quoted 1 line

Fix existing cpu_relax() loop to have proper kernel style.

..but you change the code, not its style.

kernel/ptrace.c line 188

Quoted 10 lines
kernel/ptrace.c +1 -2
@@ -182,9 +182,8 @@
 	if (!write_trylock(&tasklist_lock)) {
 		local_irq_enable();
 		task_unlock(task);
-		do {
+		while (!write_can_lock(&tasklist_lock))
 			cpu_relax();
-		} while (!write_can_lock(&tasklist_lock));
 		goto repeat;
 	}

I guess that barrier was needed before write_can_lock can succeed. => your version does one unneccessary test.

Signature · 1 line
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms