[RFC][PATCH 2/4] res_counter check usage under val

Paul Menage menage at google.com
Wed Jul 30 04:41:26 PDT 2008


On Tue, Jul 29, 2008 at 7:09 PM, Pavel Emelyanov <xemul at openvz.org> wrote:
>> I get your point. Logically this lock is unnecessary.
>> (And seems this patch itself is buggy..(maybe refresh miss))
>>
>> BTW, I'm sorry if I misunderstand. unsigned long long (on x86-32)
>> can be compared safely ?
>
> Oops... Indeed.
> That discourages me, that we need a spinlock for simple comparisons :(
>

We could add a function to read a res_counter that only takes a
spinlock on architectures where a 64-bit value can't be read
atomically.

Also, for values that are monotonically increasing, I think it should
be possible to read a 64-bit value without locking by checking that
reading the value twice either side of an appropriate memory value
returns the same result both times.

Paul


More information about the Containers mailing list