Re: test_and_set_bit implementation

From: Christoph Lameter <clameter_at_sgi.com>
Date: 2006-12-13 04:20:39
On Tue, 12 Dec 2006, Zoltan Menyhart wrote:

> Let's assume the bit test & set is already set, why is then the
> cmpxchg_acq() executed? Cannot we just return, e.g. like this?
> 
>        do {
>                old = *m;
> 		if (old & bit)
> 			return 1;
>                new = old | bit;
>        } while (cmpxchg_acq(m, old, new) != old);


I think this will work. However, usually you execute bit test and test 
because the bit is not set and you want to set it. This change would 
optimize a rarely taken path. Probably not worth it.


-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Wed Dec 13 04:21:00 2006

This archive was generated by hypermail 2.1.8 : 2006-12-13 04:21:11 EST