lkml.org 
[lkml]   [2003]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH][2.5] Protect smp_call_function_data w/ spinlocks on Alpha
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:33    [W:0.080 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site