Re: [PATCH] percpu: preemptless __per_cpu_counter_add

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

 



On Thu, 21 Apr 2011, Tejun Heo wrote:

> The only difference between the two is the level of fuziness.  The
> former deviates only by the number of concurrent updaters (and maybe
> cacheline update latencies) while the latter may deviate in multiples
> of @batch.

I dont think multiple times of batch is such a concern. Either the per cpu
counter is high or the overflow has been folded into the global counter.

The interregnum is very short and since the counters are already fuzzy
this is tolerable. We do the same thing elsewhere for vmstats.

> If you wanna say that the difference in the level of fuzziness is
> irrelevant, the first patch of this series should be removing
> percpu_counter_sum() before making any other changes.

percpu_counter_sum() is more accurate since it considers the per cpu
counters. That is vastly different.

> > The local counter increment was already decoupled before. The shifting of
> > the overflow into the global counter was also not serialized before.
>
> No, it wasn't.

>
> 	...
> 	if (count >= batch || count <= -batch) {
> 		spin_lock(&fbc->lock);
> 		fbc->count += count;
> 		__this_cpu_write(*fbc->counters, 0);
> 		spin_unlock(&fbc->lock);
> 	} else {
> 	...
>
> percpu_counter_sum() would see either both the percpu and global
> counters updated or un-updated.  It will never see local counter reset
> with global counter not updated yet.

Sure there is a slight race there and there is no way to avoid that race
without a lock.

> > There was no total accuracy before either.
>
> It's not about total accuracy.  It's about different levels of
> fuzziness.  If it can be shown that the different levels of fuzziness
> doesn't matter and thus percpu_counter_sum() can be removed, I'll be a
> happy camper.

percpu_counter_sum() is a totally different animal since it considers the
per cpu differentials but while it does that the per cpu differentials can
be updated. So the fuzziness is much lower than just looking at the global
counter for wich all sorts of counters differentials on multiple cpus can
be outstanding over long time periods.

Look at mm/vmstat.c. There is __inc_zone_state() which does an analogous
thing. and include/linux/vmstat.h:zone_page_state_snapshot() which is
analoguous to percpu_counter_sum().

In fact as far as I can tell the percpu_counter stuff was cribbed from
that one. What I did is the same process as in mm/vmstat.c:mod_state.






--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]