Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 May 2003 11:44:28 -0400
From:      Don Bowman <don@sandvine.com>
To:        'Bruce Evans' <bde@zeta.org.au>, Don Bowman <don@sandvine.com>
Cc:        freebsd-net@freebsd.org
Subject:   RE: polling(4) and idle time/cpu usage percentages
Message-ID:  <FE045D4D9F7AED4CBFF1B3B813C8533701B3660D@mail.sandvine.com>

next in thread | raw e-mail | index | archive | help
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();



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