Subject: Re: inter-cpu coherency and kernel data structures
To: None <thorpej@zembu.com>
From: Chris G. Demetriou <cgd@sibyte.com>
List: tech-smp
Date: 08/14/2000 10:17:40
thorpej@zembu.com (Jason R Thorpe) writes:
> On Mon, Aug 14, 2000 at 09:58:50AM -0700, Matthew Jacob wrote:
> 
>  > Well, if your ldx_l/stX_c locking is using MBs, then, err, umm, you're
>  > covered.
> 
> I think the issue is that I need to do the instructions like this:
> 
> 	1. alpha_mb();
> 	2. alp->lock_data = 0;
> 	3. alpha_mb();

That's a bit overkill, according to the green book at least.

it says:

	WMB
	set lock variable to zero
	<nothing>

> Where:
> 
> 	1. Ensure that store that unlocks the data structure will not
> 	   happen before the data structure has actually been modified
> 	   in memory.

that can be accomplished with wmb.


> 	2. Release the lock.
> 
> 	3. Ensure that the lock is released before anything else happens.

the latter isn't really necessary, given my understanding of the
architecture.  write buffer data will eventually propagate to memory.

the question is do you want that to happen immediately at some cost to
the locally executing CPU, or at you willing to let it wait a few
cycles to the possible detriment of other CPUs who are actually
contending for the lock right thing?

I'd say that the right thing to do is use wmb/unlock/nothing, until
you know that you're actually suffering from lots of contention and
that the additional mb improves system performance.

at worst, it should be an mb rather than a wmb, too.  8-)



cgd