Polling and kern.polling.idle_poll

Barney Cordoba barney_cordoba at yahoo.com
Thu Jul 2 15:17:53 UTC 2009




--- On Thu, 7/2/09, Larry Baird <lab at gta.com> wrote:

> From: Larry Baird <lab at gta.com>
> Subject: Re: Polling and kern.polling.idle_poll
> To: "Paul Thornton" <prt at prt.org>
> Cc: freebsd-net at freebsd.org
> Date: Thursday, July 2, 2009, 10:21 AM
> Paul,
> 
> > Larry Baird wrote:
> > >The man page for polling states:
> > >    kern.polling.idle_poll
> > >     Controls if polling
> is enabled in the idle loop.  There are no
> > >     reasons (other than
> power saving or bugs in the scheduler's han-
> > >     dling of idle
> priority kernel threads) to disable this.
> > >
> > >So why is it now disabled by default? 
> Looking back through cvs the
> > >change was made by Luigi way back in August of
> 2002.  
> > >
> > >  
> > Did you ever get a reply for this question on the -net
> list?  I may have 
> > missed it, but I don't think you did.
> > I'm very interested in why this was changed too.
> I got some off list mail from Luigi.  In 4.x, the
> idle_poll() was called
> from idle.  Now it is its own thread.  CPU
> statistics will now show high 100%
> utilization if your set kern.polling.idle_poll.  He
> also has some concerns
> about if locking was in place for SMP.  Looking at the
> code locking appears
> to be in place.
> 
> The performance improvment is too great for me to ignore,
> so I made a few
> mods to my kernels.  I modified kern_poll to set
> P_NOLOAD for the idle_poll
> thread. I then modified CPU statistics to view all
> processes with P_NOLOAD
> as the idle process.  So far working great for
> me.  Patches below.
> 
> *** /sys/kern/kern_poll.c   
>    2006-06-16 18:11:55.000000000 -0400
> --- kern_poll.c 2009-07-02 10:03:07.000000000 -0400
> ***************
> *** 577,583 ****
> --- 577,587 ----
>   {
>         struct thread *td = curthread;
>         struct rtprio rtp;
> +       struct proc *p =
> td->td_proc;
>   
> +       PROC_LOCK(p);
> +       p->p_flag |= P_NOLOAD;
> +       PROC_UNLOCK(p);
>         rtp.prio = RTP_PRIO_MAX; 
>       /* lowest priority */
>         rtp.type = RTP_PRIO_IDLE;
>        
> mtx_lock_spin(&sched_lock);
> 
> *** /sys/kern/kern_clock.c      2008-06-04
> 06:31:41.000000000 -0400
> --- kern_clock.c        2009-07-02
> 10:05:01.000000000 -0400
> ***************
> *** 516,522 ****
>                
>                
> thread_statclock(0);
>                
>         td->td_sticks++;
>                
>         p->p_rux.rux_sticks++;
> !               
>        if (td !=
> PCPU_GET(idlethread)) {
>                
>                
> cp_time[CP_SYS]++;
>                
>                
> pcp_time[CP_SYS]++;
>                
>         } else {
> --- 516,522 ----
>                
>                
> thread_statclock(0);
>                
>         td->td_sticks++;
>                
>         p->p_rux.rux_sticks++;
> !               
>        if ( ! (p->p_flag &
> P_NOLOAD) ) {
>                
>                
> cp_time[CP_SYS]++;
>                
>                
> pcp_time[CP_SYS]++;
>                
>         } else {
> 

Curious as to why you don't simply lay out the $40 for a modern ethernet card that doesn't need polling to work well?

Barney


      


More information about the freebsd-net mailing list