One use for reference-count biases...
Posted Jun 9, 2009 5:39 UTC (Tue) by
neilbrown (subscriber, #359)
In reply to:
One use for reference-count biases... by PaulMcKenney
Parent article:
Linux kernel design patterns - part 1
Yes, I wouldn't be surprised if reference counts that are spread across multiple per-cpu variables would have very different trade-offs and hence different Patterns to the more traditional kinds!
I'm having trouble picturing exactly how the counters you describe would work (and particularly exactly what happens when the per-cpu counter hits zero) but it seems possible that the "one bit of information" that I claim a bias stores would, in this case, be the bit "Someone cares about a precise total value" and that one bit could conceivably be stored in a read-mostly
cache line that could be easily shared among multiple processors.
So the code might look like:
if (dec_and_test(per_cpu_counter))
if (__test_bit(flag_name, &flag_variable))
do some costly cross-cpu thing;
Is there any chance that would achieve the same result?
It may well be a case where you don't want to pay the price of an
extra bit though.
(
Log in to post comments)