[CFR][CFT] counter(9): new API for faster and raceless counters
Gleb Smirnoff
glebius at FreeBSD.org
Wed Apr 3 21:45:39 UTC 2013
On Wed, Apr 03, 2013 at 02:05:33PM -0500, Brooks Davis wrote:
B> > o Tiny API for counter(9):
B> >
B> > counter_u64_t
B> > counter_u64_alloc(int wait);
B> >
B> > void
B> > counter_u64_free(counter_u64_t cnt);
B> >
B> > void
B> > counter_u64_add(counter_u64_t cnt, uint64_t inc);
B> >
B> > uint64_t
B> > counter_u64_fetch(counter_u64_t cnt);
B>
B> I wonder if there might be value in an interface to retrieve the per-cpu
B> values individually. The use case I have in mind is interrupt counters
B> on our BERI CPU. Similar to the Sibyte MIPS SoCs, our PIC always routes
B> each interrupt to a specific hardware thread. I'd ideally like to be able
B> to look at at hardware interrupts on a per-thread basis and avoid the
B> cache trashing behavior we'd get if we allocated current interrupt
B> counters to each one, but we probably want to be able to preserve
B> something like the current behavior.
You can just utilize directly the per-CPU UMA zones, that will come together
with counter(9).
So, the code will look like:
critical_enter();
foo = (foo *)zpcpu_get(base); /* get private to CPU data */
do smth with foo
critical_exit();
--
Totus tuus, Glebius.
More information about the freebsd-arch
mailing list