[CFR][CFT] counter(9): new API for faster and raceless counters

Pawel Jakub Dawidek pjd at FreeBSD.org
Tue Apr 2 23:24:11 UTC 2013

On Mon, Apr 01, 2013 at 03:51:28PM +0400, Gleb Smirnoff wrote:
>   Hi!
>   Together with Konstantin Belousov (kib@) we developed a new API that is
> initially purposed for (but not limited to) collecting statistical
> data in kernel.

Is there any plan to implement universal way of exporting those
statistics out of the kernel?

Solaris has a framework for in-kernel statistics, which are exported via
kstat tool. For ZFS I export them via sysctl. If you have ZFS loaded you
can try 'sysctl kstat'.

It would be nice for counter_u64_alloc() to take additional argument
'name' and to create sysctl for the counter automatically. We could then
slowly start migrating userland tools to use sysctls (or some wrapper
userland API), but we immediately make those statistics available for
use in scripts.

> o Tiny API for counter(9):
>      counter_u64_t
>      counter_u64_alloc(int wait);
>      void
>      counter_u64_free(counter_u64_t cnt);
>      void
>      counter_u64_add(counter_u64_t cnt, uint64_t inc);
>      uint64_t
>      counter_u64_fetch(counter_u64_t cnt);

Do you really expect other types in the future? If so, could we at least
create generic counter_t that internally keeps the type?

Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://tupytaj.pl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20130403/f574bb00/attachment.sig>

More information about the freebsd-arch mailing list