From owner-freebsd-hackers Sun Jan 20 15:56:40 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from prg.traveller.cz (prg.traveller.cz [193.85.2.77]) by hub.freebsd.org (Postfix) with ESMTP id 1833437B404; Sun, 20 Jan 2002 15:56:34 -0800 (PST) Received: from prg.traveller.cz (localhost [127.0.0.1]) by prg.traveller.cz (8.12.1[KQ-CZ](1)/8.12.1/pukvis) with ESMTP id g0KNuMg8095762; Mon, 21 Jan 2002 00:56:22 +0100 (CET) Received: from localhost (mime@localhost) by prg.traveller.cz (8.12.1[KQ-CZ](1)/pukvis) with ESMTP id g0KNuLrj095759; Mon, 21 Jan 2002 00:56:21 +0100 (CET) Date: Mon, 21 Jan 2002 00:56:21 +0100 (CET) From: Michal Mertl To: hackers@freebsd.org Cc: peter.jeremy@alcatel.com.au, , , , , , Subject: patch for network counter implementation (64bit/atomic) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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-hackers" in the body of the message