linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -mm 6/6] cpu_relax(): ptrace.c coding style fix
@ 2006-06-21 21:00 Andreas Mohr
  2006-06-22 14:32 ` Nathan Lynch
  2006-06-22 15:08 ` Pavel Machek
  0 siblings, 2 replies; 4+ messages in thread
From: Andreas Mohr @ 2006-06-21 21:00 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel


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


Tested on 2.6.17-mm1.

Signed-off-by: Andreas Mohr <andi@lisas.de>


diff -urN linux-2.6.17-mm1.orig/kernel/ptrace.c linux-2.6.17-mm1.my/kernel/ptrace.c
--- linux-2.6.17-mm1.orig/kernel/ptrace.c	2006-06-21 14:28:20.000000000 +0200
+++ linux-2.6.17-mm1.my/kernel/ptrace.c	2006-06-21 14:43:24.000000000 +0200
@@ -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;
 	}
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -mm 6/6] cpu_relax(): ptrace.c coding style fix
  2006-06-21 21:00 [PATCH -mm 6/6] cpu_relax(): ptrace.c coding style fix Andreas Mohr
@ 2006-06-22 14:32 ` Nathan Lynch
  2006-06-22 15:53   ` Andreas Mohr
  2006-06-22 15:08 ` Pavel Machek
  1 sibling, 1 reply; 4+ messages in thread
From: Nathan Lynch @ 2006-06-22 14:32 UTC (permalink / raw)
  To: Andreas Mohr; +Cc: Andrew Morton, linux-kernel

Andreas Mohr wrote:
> 
> Fix existing cpu_relax() loop to have proper kernel style.
> 

...

> @@ -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.)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -mm 6/6] cpu_relax(): ptrace.c coding style fix
  2006-06-21 21:00 [PATCH -mm 6/6] cpu_relax(): ptrace.c coding style fix Andreas Mohr
  2006-06-22 14:32 ` Nathan Lynch
@ 2006-06-22 15:08 ` Pavel Machek
  1 sibling, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2006-06-22 15:08 UTC (permalink / raw)
  To: Andreas Mohr; +Cc: Andrew Morton, linux-kernel

Hi!

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

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

> @@ -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.

-- 
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -mm 6/6] cpu_relax(): ptrace.c coding style fix
  2006-06-22 14:32 ` Nathan Lynch
@ 2006-06-22 15:53   ` Andreas Mohr
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Mohr @ 2006-06-22 15:53 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: Andrew Morton, linux-kernel

On Thu, Jun 22, 2006 at 09:32:23AM -0500, Nathan Lynch wrote:
> Andreas Mohr wrote:
> > 
> > Fix existing cpu_relax() loop to have proper kernel style.
> > 
> 
> ...
> 
> > @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-06-22 19:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-21 21:00 [PATCH -mm 6/6] cpu_relax(): ptrace.c coding style fix Andreas Mohr
2006-06-22 14:32 ` Nathan Lynch
2006-06-22 15:53   ` Andreas Mohr
2006-06-22 15:08 ` Pavel Machek

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).