From owner-freebsd-net@FreeBSD.ORG Sun May 11 08:44:30 2003 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9D60237B401 for ; Sun, 11 May 2003 08:44:30 -0700 (PDT) Received: from mail.sandvine.com (sandvine.com [199.243.201.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id E0E1343F93 for ; Sun, 11 May 2003 08:44:29 -0700 (PDT) (envelope-from don@sandvine.com) Received: by mail.sandvine.com with Internet Mail Service (5.5.2653.19) id ; Sun, 11 May 2003 11:44:29 -0400 Message-ID: From: Don Bowman To: 'Bruce Evans' , Don Bowman Date: Sun, 11 May 2003 11:44:28 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" cc: freebsd-net@freebsd.org Subject: RE: polling(4) and idle time/cpu usage percentages X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 May 2003 15:44:30 -0000 From: Bruce Evans [mailto:bde@zeta.org.au] > On Sat, 10 May 2003, Don Bowman wrote: > > [accounting for the details of idle time] > > > > The former. It's hard for it to work better without > wasting too many > > > cycles for the accounting. In RELENG_4, everything done > in the "idle" > > > loop is counted as idle time using the single counter > > > cp_time[CP_IDLE]. > > > This is very efficient. > > > > I tried this on my system, but I still end up with 0 system time. > > Did you try my hack? I tried the hack, as below. The other thing that makes idle wildly inaccurate is the symmetric multi-threading on the xeon (aka hyperthreading). Index: kern_clock.c =================================================================== RCS file: /usr/cvs/src/sys/kern/kern_clock.c,v retrieving revision 1.105.2.9.1000.2 diff -U3 -r1.105.2.9.1000.2 kern_clock.c --- kern_clock.c 13 Feb 2003 23:05:58 -0000 1.105.2.9.1000.2 +++ kern_clock.c 10 May 2003 23:41:47 -0000 @@ -68,6 +68,7 @@ #endif #ifdef DEVICE_POLLING +extern int in_polling; extern void init_device_poll(void); extern void hardclock_device_poll(void); #endif /* DEVICE_POLLING */ @@ -550,6 +551,11 @@ } else if (p != NULL) { p->p_sticks++; cp_time[CP_SYS]++; +#if defined(DEVICE_POLLING) + } else if (in_polling) { + p->p_sticks++; + cp_time[CP_SYS]++; +#endif } else cp_time[CP_IDLE]++; } Index: kern_poll.c =================================================================== RCS file: /usr/cvs/src/sys/kern/kern_poll.c,v retrieving revision 1.2.2.4.1000.1 diff -U3 -r1.2.2.4.1000.1 kern_poll.c --- kern_poll.c 10 Feb 2003 16:49:19 -0000 1.2.2.4.1000.1 +++ kern_poll.c 10 May 2003 23:37:11 -0000 @@ -54,6 +54,8 @@ void ether_poll(int); /* polling while in trap */ int idle_poll(void); /* poll while in idle loop */ +int in_polling; + /* * Polling support for [network] device drivers. * @@ -268,11 +270,13 @@ { if (poll_in_idle_loop && poll_handlers > 0) { int s = splimp(); + in_polling = 1; enable_intr(); ether_poll(poll_each_burst); disable_intr(); splx(s); vm_page_zero_idle(); + in_polling = 0; return 1; } else return vm_page_zero_idle();