All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][2.5] Protect smp_call_function_data w/ spinlocks on Alpha
@ 2003-02-14 11:51 Zwane Mwaikambo
  2003-02-14 14:53 ` Ivan Kokshaysky
  0 siblings, 1 reply; 7+ messages in thread
From: Zwane Mwaikambo @ 2003-02-14 11:51 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Richard T Henderson, Linus Torvalds

Hi Richard,
	This is an untested patch to remove the custom mutex, however it 
doesn't maintain the same semantics wrt 'retry' and unconditionally 
blocks on contention. A version of this patch is in the 
smp_call_function_on_cpu patch i posted for Alpha so they are mutually 
exclusive.

Index: linux-2.5.60-uml/arch/alpha/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.60/arch/alpha/kernel/smp.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 smp.c
--- linux-2.5.60-uml/arch/alpha/kernel/smp.c	10 Feb 2003 22:14:47 -0000	1.1.1.1
+++ linux-2.5.60-uml/arch/alpha/kernel/smp.c	14 Feb 2003 11:49:53 -0000
@@ -668,38 +667,7 @@
 };
 
 static struct smp_call_struct *smp_call_function_data;
-
-/* Atomicly drop data into a shared pointer.  The pointer is free if
-   it is initially locked.  If retry, spin until free.  */
-
-static int
-pointer_lock (void *lock, void *data, int retry)
-{
-	void *old, *tmp;
-
-	mb();
- again:
-	/* Compare and swap with zero.  */
-	asm volatile (
-	"1:	ldq_l	%0,%1\n"
-	"	mov	%3,%2\n"
-	"	bne	%0,2f\n"
-	"	stq_c	%2,%1\n"
-	"	beq	%2,1b\n"
-	"2:"
-	: "=&r"(old), "=m"(*(void **)lock), "=&r"(tmp)
-	: "r"(data)
-	: "memory");
-
-	if (old == 0)
-		return 0;
-	if (! retry)
-		return -EBUSY;
-
-	while (*(void **)lock)
-		barrier();
-	goto again;
-}
+static spinlock_t call_lock = SPIN_LOCK_UNLOCKED;
 
 void
 handle_ipi(struct pt_regs *regs)
@@ -829,9 +797,8 @@
 	atomic_set(&data.unstarted_count, num_cpus_to_call);
 	atomic_set(&data.unfinished_count, num_cpus_to_call);
 
-	/* Acquire the smp_call_function_data mutex.  */
-	if (pointer_lock(&smp_call_function_data, &data, retry))
-		return -EBUSY;
+	spin_lock(&call_lock);
+	smp_call_function_data = &data;
 
 	/* Send a message to the requested CPUs.  */
 	send_ipi_message(to_whom, IPI_CALL_FUNC);
@@ -865,7 +832,8 @@
 
 	/* We either got one or timed out -- clear the lock. */
 	mb();
-	smp_call_function_data = 0;
+	smp_call_function_data = NULL;
+	spin_unlock(&call_lock);
 
 	/* 
 	 * If after both the initial and long timeout periods we still don't

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

end of thread, other threads:[~2003-02-17 14:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-14 11:51 [PATCH][2.5] Protect smp_call_function_data w/ spinlocks on Alpha Zwane Mwaikambo
2003-02-14 14:53 ` Ivan Kokshaysky
2003-02-14 17:16   ` Zwane Mwaikambo
2003-02-17  8:15     ` Richard Henderson
2003-02-17  8:32       ` Zwane Mwaikambo
2003-02-17 14:23         ` Ivan Kokshaysky
2003-02-17 14:31           ` Zwane Mwaikambo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.