netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] ipvs: force read of atomic_t in while loop
@ 2007-08-08  9:33 Heiko Carstens
  2007-08-08  9:45 ` Horms
  2007-08-08 10:21 ` David Miller
  0 siblings, 2 replies; 13+ messages in thread
From: Heiko Carstens @ 2007-08-08  9:33 UTC (permalink / raw)
  To: Andrew Morton, David Miller
  Cc: linux-kernel, netdev, Martin Schwidefsky, Wensong Zhang,
	Simon Horman

From: Heiko Carstens <heiko.carstens@de.ibm.com>

For architectures that don't have a volatile atomic_ts constructs like
while (atomic_read(&something)); might result in endless loops since a
barrier() is missing which forces the compiler to generate code that
actually reads memory contents.
Fix this in ipvs by using the IP_VS_WAIT_WHILE macro which resolves to
while (expr) { cpu_relax(); }
(why isn't this open coded btw?)

Cc: Wensong Zhang <wensong@linux-vs.org>
Cc: Simon Horman <horms@verge.net.au>
Cc: David Miller <davem@davemloft.net>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---

Just saw this while grepping for atomic_reads in a while loops.
Maybe we should re-add the volatile to atomic_t. Not sure.

 net/ipv4/ipvs/ip_vs_ctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/net/ipv4/ipvs/ip_vs_ctl.c
===================================================================
--- linux-2.6.orig/net/ipv4/ipvs/ip_vs_ctl.c
+++ linux-2.6/net/ipv4/ipvs/ip_vs_ctl.c
@@ -909,7 +909,7 @@ ip_vs_edit_dest(struct ip_vs_service *sv
 	write_lock_bh(&__ip_vs_svc_lock);
 
 	/* Wait until all other svc users go away */
-	while (atomic_read(&svc->usecnt) > 1) {};
+	IP_VS_WAIT_WHILE(atomic_read(&svc->usecnt) > 1);
 
 	/* call the update_service, because server weight may be changed */
 	svc->scheduler->update_service(svc);

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

end of thread, other threads:[~2007-08-09 13:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-08  9:33 [patch] ipvs: force read of atomic_t in while loop Heiko Carstens
2007-08-08  9:45 ` Horms
2007-08-08 10:21 ` David Miller
2007-08-08 10:28   ` Heiko Carstens
2007-08-08 21:08     ` Chris Snook
2007-08-08 21:31       ` Andrew Morton
2007-08-08 22:27         ` Heiko Carstens
2007-08-08 22:38           ` Chris Snook
2007-08-09  0:15       ` Andi Kleen
2007-08-09 12:35         ` Michael Buesch
2007-08-09 12:40           ` Chris Snook
2007-08-09 12:49             ` Martin Schwidefsky
2007-08-09 13:36           ` Andi Kleen

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