kern/100519: Suboptimal network polling

Arthur Hartwig arthur.hartwig at
Wed Jul 19 08:00:37 UTC 2006

>Number:         100519
>Category:       kern
>Synopsis:       Suboptimal network polling
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 19 08:00:34 GMT 2006
>Originator:     Arthur Hartwig
>Release:        6.0
FreeBSD 6.0-RELEASE FreeBSD 6.0-RELEASE #3: Wed Mar  1 10:46:02 EST 2006     hartwig at  i386

Network polling has unnecessary calls to the scheduler. These require acquiring the sched lock which imposes a variable delay depending on contention for this lock.

in netisr_pollmore() in kern/kern_poll.c there are two calls to schednetisrbits().  schednetisrbits is defined in net/netisr.h to set some bits in netisr and call legacy_setsoftnet(). legacy_setsoftnet() in net/netisr.c calls swi_sched(). swi_sched() in kern/kern_intr.c which calls ithread_schedule() in the same file. ithread_schedule() acquires and releases the sched_lock.


Since the netisr is running when netisr_pollmore() is executing and swi_net() the main netisr despatcher loops until netisr is zero, it is sufficient in netisr_pollmore() to just set the bits in netisr and not also call legacy_setsoftnet():

replace the two instances of:
    schednetisrbits(1 << NETISR_POLL | 1 << NETISR_POLLMORE);

in netisr_pollmore() by:
    atomic_set_rel_int(&netisr, (1 << NETISR_POLL | 1 << NETISR_POLLMORE));


More information about the freebsd-bugs mailing list