Messages in this thread | | | Date | Mon, 28 Jan 2013 13:50:42 -0800 | From | Tejun Heo <> | Subject | Re: [PATCH] generic dynamic per cpu refcounting |
| |
Hello, Kent.
On Mon, Jan 28, 2013 at 01:45:06PM -0800, Kent Overstreet wrote: > Ahh. Bias value sounds... hacky (i.e. harder to convince myself it's > correct) but I see what you're getting at.
I don't think it's that hacky. Just push the base point to the opposite of zero - LLONG_MAX. The global counter can start biased so that it gets unbiased only once dying is confirmed and everything can blindly do atomic64_dec_and_test() and trust the result.
> Something to consider is wrapping; after we set state to dying but > before we've collected the percpu counters, the atomic counter may be > negative.
There's a reason why we use 64bit vars for this type of global counting. They virtually don't wrap. Here, you'll need 1<<63 for the counter to unintentionally reach 0, which we consider practically impossible.
Thanks.
-- tejun
| |