Deleted Added
full compact
kern_poll.c (150968) kern_poll.c (157815)
1/*-
2 * Copyright (c) 2001-2002 Luigi Rizzo
3 *
4 * Supported by: the Xorp Project (www.xorp.org)
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2002 Luigi Rizzo
3 *
4 * Supported by: the Xorp Project (www.xorp.org)
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/kern/kern_poll.c 150968 2005-10-05 10:09:17Z glebius $");
29__FBSDID("$FreeBSD: head/sys/kern/kern_poll.c 157815 2006-04-17 18:20:38Z jhb $");
30
31#include "opt_device_polling.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>
36#include <sys/socket.h> /* needed by net/if.h */
37#include <sys/sockio.h>

--- 534 unchanged lines hidden (view full) ---

572 return (0);
573}
574
575static void
576poll_idle(void)
577{
578 struct thread *td = curthread;
579 struct rtprio rtp;
30
31#include "opt_device_polling.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>
36#include <sys/socket.h> /* needed by net/if.h */
37#include <sys/sockio.h>

--- 534 unchanged lines hidden (view full) ---

572 return (0);
573}
574
575static void
576poll_idle(void)
577{
578 struct thread *td = curthread;
579 struct rtprio rtp;
580 int pri;
581
582 rtp.prio = RTP_PRIO_MAX; /* lowest priority */
583 rtp.type = RTP_PRIO_IDLE;
584 mtx_lock_spin(&sched_lock);
585 rtp_to_pri(&rtp, td->td_ksegrp);
580
581 rtp.prio = RTP_PRIO_MAX; /* lowest priority */
582 rtp.type = RTP_PRIO_IDLE;
583 mtx_lock_spin(&sched_lock);
584 rtp_to_pri(&rtp, td->td_ksegrp);
586 pri = td->td_priority;
587 mtx_unlock_spin(&sched_lock);
588
589 for (;;) {
590 if (poll_in_idle_loop && poll_handlers > 0) {
591 idlepoll_sleeping = 0;
592 ether_poll(poll_each_burst);
593 mtx_lock_spin(&sched_lock);
594 mi_switch(SW_VOL, NULL);
595 mtx_unlock_spin(&sched_lock);
596 } else {
597 idlepoll_sleeping = 1;
585 mtx_unlock_spin(&sched_lock);
586
587 for (;;) {
588 if (poll_in_idle_loop && poll_handlers > 0) {
589 idlepoll_sleeping = 0;
590 ether_poll(poll_each_burst);
591 mtx_lock_spin(&sched_lock);
592 mi_switch(SW_VOL, NULL);
593 mtx_unlock_spin(&sched_lock);
594 } else {
595 idlepoll_sleeping = 1;
598 tsleep(&idlepoll_sleeping, pri, "pollid", hz * 3);
596 tsleep(&idlepoll_sleeping, 0, "pollid", hz * 3);
599 }
600 }
601}
602
603static struct proc *idlepoll;
604static struct kproc_desc idlepoll_kp = {
605 "idlepoll",
606 poll_idle,
607 &idlepoll
608};
609SYSINIT(idlepoll, SI_SUB_KTHREAD_VM, SI_ORDER_ANY, kproc_start, &idlepoll_kp)
597 }
598 }
599}
600
601static struct proc *idlepoll;
602static struct kproc_desc idlepoll_kp = {
603 "idlepoll",
604 poll_idle,
605 &idlepoll
606};
607SYSINIT(idlepoll, SI_SUB_KTHREAD_VM, SI_ORDER_ANY, kproc_start, &idlepoll_kp)