Re: test_and_set_bit implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matthew Wilcox wrote:
On Wed, Dec 13, 2006 at 11:02:48AM +0100, Zoltan Menyhart wrote:

I like this code with the following slight modifications:
- let's keep "m" as pointer to volatile

Why?  What benefit is there to doing an ld4.acq instead of a plain ld4?

It is not about the ld4.acq, but the volatile storage class (= don't
assume it wont be changed by someone else, do reload it each time).

Not using the volatile key word allows the compiler to optimize
out the actual load in loops like:

	while (test_and_set_bit(bitnum, addr))
		;


- let's keep on using "__u32" types

Why be so ugly?

- It has been like that for a while, I got used to it :-)
- grep-ing for "__u32" gives less false positives that grep-ing for "u32"

- return the old bit

I don't understand what you mean here.

In your code:
...
   while (!(old & bit)) {
...
           return 1;
...
   }
   return 0;

You return the inverse of the old bit, while the orig. code says:

" * test_and_set_bit - Set a bit and return its old value"

Thanks.

Zoltán Menyhárt

-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Sparc Linux]     [DCCP]     [Linux ARM]     [Yosemite News]     [Linux SCSI]     [Linux x86_64]     [Linux for Ham Radio]

  Powered by Linux