Re: [PATCH][2.5] Protect smp_call_function_data w/ spinlocks on Alpha

From: Zwane Mwaikambo (zwane@holomorphy.com)
Date: Mon Feb 17 2003 - 03:32:09 EST


On Mon, 17 Feb 2003, Richard Henderson wrote:

> On Fri, Feb 14, 2003 at 12:16:12PM -0500, Zwane Mwaikambo wrote:
> > Ok the reason being is that the lock not only protects the
> > smp_call_function_data pointer but also acts as a lock for that critical
> > section. Without it you'll constantly be overwriting the pointer halfway
> > through IPI acceptance (or even worse whilst a remote CPU is assigning the
> > data members).
>
> Really. Show me the sequence there?

/* Acquire the smp_call_function_data mutex. */
if (pointer_lock(&smp_call_function_data, &data, retry))
        return -EBUSY;

say we remove the pointer lock there and do a single atomic assignment

...

if (atomic_read(&data.unstarted_count) > 0) {
        ...
}

we got at least one IPI

/* We either got one or timed out -- clear the lock. */
mb();
smp_call_function_data = 0;

We clear smp_call_function_data

...

cpuX receives the IPI

case IPI_CALL_FUNC:
{
        struct smp_call_struct *data;
        void (*func)(void *info);
        void *info;
        int wait;

        data = smp_call_function_data;
        func = data->func;
        info = data->info;
...

Assigns whatever the pointer happens to be at the time, be it NULL or the
next incoming message call.

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

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

        Zwane

-- 
function.linuxpower.ca
-
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/



This archive was generated by hypermail 2b29 : Sun Feb 23 2003 - 22:00:17 EST