Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jan 2002 00:56:21 +0100 (CET)
From:      Michal Mertl <mime@traveller.cz>
To:        hackers@freebsd.org
Cc:        peter.jeremy@alcatel.com.au, <louie@TransSys.COM>, <wollman@khavrinen.lcs.mit.edu>, <marc@enginet.com>, <jhb@freebsd.org>, <julian@elischer.org>, <arch@freebsd.org>
Subject:   patch for network counter implementation (64bit/atomic)
Message-ID:  <Pine.BSF.4.41.0201210020110.94442-100000@prg.traveller.cz>

next in thread | raw e-mail | index | archive | help
After rather long discussion on arch with no apparent result I have my
patch for STABLE ready.

Sorry to repeat what has been already talked about but there may be people
on hackers who don't read arch.

I've posted 2 patches on
http://home.eunet.cz/mime/syscntr.diff.20020120.gz
and http://home.eunet.cz/mime/netstat.diff.gz (only modifies netstat to be
able to show 64 bit values).

The first one modifies lots of sources in kernel but I believe that most
changes are totally harmless. It modifies all network device driver
sources to use newly defined API for accessing counters (packets, bytes,
errors...). It also modifies some files in /sys/net* to use the same API.
The counters are defined in /sys/net/if.h and
/sys/netinet/{ip|tcp|udp|igmp|icmp}_var.h and their type is changed from
u_long to syscntr_t. The new API is defined in /sys/i386/include/syscntr.h
but is 99% MI - no problem should occur with Alpha and other ports. By
default the syscntr_t is u_int32_t and is accessed non-atomically. This is
probably incorrect but it's the same way it's been done for ages so no new
problem is created. Change of 2 defines in the file makes counters either
64 bit and/or atomic. Other API feature which may end up useless is that
the different counters can be accessed by different type of operation (the
size is always either 32 or 64 bit) - maybe even something not yet
implemented - per cpu.

Other change there is adding support for 64 bit atomic ops to X86 -
unfortunatelly the instruction required for this operation is only or
>=586. So atomic 64 bit operation is possible only on these computers -
but that's maybe also only on SMP machines (>=586) where the atomicity is
strictly needed.

As discussed to death on arch atomicity and 64 bit both add to cost of
accessing the counters. The most common operation is addition - on p3
non-atomic 32 bit cost about 2 clocks, atomic 32 bit 20 clocks, non-atomic
64 bit 7 clocks and atomic 64 bit 50 clocks. For each tcp packet we have
at least 5 counter updates.

The code is perfectly usable on CURRENT too. If there's single request
I'll make sure it fits there 100%.

There's one problem I'm aware of - NETGRAPH. It has some counters
defined in code too and I think it will benefit from the change too. But I
don't now if it's possible to change the types in there (are there NG
drivers not it tree?).

PS: After changing kernel counters from 32 to 64 bit, some of world has to
be rebuild too (to notice the change in structs which contain the
counters). Namely ifconfig, netstat, systat and probably others.

-- 
Michal Mertl
mime@traveller.cz












To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.41.0201210020110.94442-100000>