lkml.org 
[lkml]   [2003]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH][2.5] Protect smp_call_function_data w/ spinlocks on Alpha
On Mon, Feb 17, 2003 at 03:32:09AM -0500, Zwane Mwaikambo wrote:
> Assigns whatever the pointer happens to be at the time, be it NULL or the
> next incoming message call.

No, the pointer is guaranteed to be valid.

> Therefore we'd need a lock to protect both the variable and critical
> section.

But smp_call_function_data pointer itself is exactly such a lock -
other CPUs can't enter the section between 'if (pointer_lock())' and
'smp_call_function_data = 0', so there is no need for extra lock
variable. Additionally, pointer_lock() with retry = 0 acts as spin_trylock.

> > I happen to like the pointer_lock a lot, and think we should
> > make more use of it on systems known to have cmpxchg. It
> > saves on the number of cache lines that have to get bounced
> > between processors.
>
> I have to agree there, it would save on locked operations per
> 'acquisition' which can be a win on a lot of systems.

Here's cmpxchg version for illustration (untested).

Ivan.

--- linux/arch/alpha/kernel/smp.c.orig Mon Feb 10 21:38:15 2003
+++ linux/arch/alpha/kernel/smp.c Mon Feb 17 17:05:47 2003
@@ -680,17 +680,7 @@ pointer_lock (void *lock, void *data, in
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");
-
+ old = cmpxchg(lock, 0, data);
if (old == 0)
return 0;
if (! retry)
-
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.036 / U:1.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site