svn commit: r296880 - in head: share/man/man9 sys/kern sys/sys

Gleb Smirnoff glebius at FreeBSD.org
Tue Mar 15 19:12:45 UTC 2016


  Ravi,

On Mon, Mar 14, 2016 at 05:33:06PM -0700, Ravi Pokala wrote:
R> To make sure I'm reading this correctly:
R> 
R> (1) The sysctl operates on an opaque array of (uint64_t)s. The elements of the array are not individually accessible.

On array of counter_u64_t. The elements are individually accessible of course,
but not by this sysctl API.

R> (2) Reading the sysctl populates each element of the userspace array by calling counter_u64_fetch() on the corresponding element of the kernelspace array.

Right.

R> (3) Writing the sysctl clears the kernelspace array by calling counter_u64_zero() on each element.

Right.

R> For example, if you have a bunch of device statistics, this interface will let you get or clear them all in one shot, but they won't have distinct names. You would have to define an enum to set up names for the array indices.

Something what you want is already provided by VNET_PCPUSTAT* macros.
The idea is that you declare a struct, whose members all are uint64_t.
This struct becomes an API between userland and kernel.

The VNET_PCPUSTAT* macros then are used to allocate nameless arrays of
counter(9)s, with number of elements equal to number of members in the API
struct. Each counter array element accumulates statistics for its corresponding
struct member.

The only problem, is that VIMAGE is mixed into this set of macros. What needs
to be done is separate logic of making correspondence of array of counters to
struct members and VIMAGE, yielding in a more generic and network unaware KPI.
This KPI should be moved from vnet.h into counter.h, and in vnet.h there should
remain macros that summon VIMAGE awareness upon the new macros in counter.h.

See struct tcpstat as example usage of VNET_PCPUSTAT* macros. 

-- 
Totus tuus, Glebius.


More information about the svn-src-all mailing list