diff options
author | 2017-10-31 22:05:12 +0000 | |
---|---|---|
committer | 2017-10-31 22:05:12 +0000 | |
commit | 93865884b36eca9fa138a35d5f936254a8f76e4d (patch) | |
tree | 1ef47fbf8a7a65e26072cc8c3132773b58376a31 | |
parent | Replace usage of WSMUX_{ADD,REMOVE}_DEVICE compat macros. (diff) | |
download | wireguard-openbsd-93865884b36eca9fa138a35d5f936254a8f76e4d.tar.xz wireguard-openbsd-93865884b36eca9fa138a35d5f936254a8f76e4d.zip |
- add one more softnet taskq
NOTE: code still runs with single softnet task. change definition of
SOFTNET_TASKS in net/if.c, if you want to have more than one softnet task
OK mpi@, OK phessler@
-rw-r--r-- | sys/net/if.c | 38 | ||||
-rw-r--r-- | sys/net/if.h | 3 | ||||
-rw-r--r-- | sys/net/if_loop.c | 4 | ||||
-rw-r--r-- | sys/net/if_pflow.c | 10 | ||||
-rw-r--r-- | sys/net/if_var.h | 3 | ||||
-rw-r--r-- | sys/net/netisr.h | 4 | ||||
-rw-r--r-- | sys/net/pf.c | 4 | ||||
-rw-r--r-- | sys/net/pf_ioctl.c | 4 | ||||
-rw-r--r-- | sys/netinet/ip_input.c | 4 | ||||
-rw-r--r-- | sys/netinet6/ip6_input.c | 4 | ||||
-rw-r--r-- | sys/netinet6/nd6.c | 4 |
11 files changed, 49 insertions, 33 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index e9e9f07add1..35e16b372be 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.520 2017/10/26 15:13:40 mpi Exp $ */ +/* $OpenBSD: if.c,v 1.521 2017/10/31 22:05:12 sashan Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -224,7 +224,9 @@ int net_livelocked(void); int ifq_congestion; int netisr; -struct taskq *softnettq; + +#define SOFTNET_TASKS 1 +struct taskq *softnettq[SOFTNET_TASKS]; struct task if_input_task_locked = TASK_INITIALIZER(if_netisr, NULL); @@ -240,6 +242,8 @@ struct rwlock netlock = RWLOCK_INITIALIZER("netlock"); void ifinit(void) { + unsigned int i; + /* * most machines boot with 4 or 5 interfaces, so size the initial map * to accomodate this @@ -248,9 +252,11 @@ ifinit(void) timeout_set(&net_tick_to, net_tick, &net_tick_to); - softnettq = taskq_create("softnet", 1, IPL_NET, TASKQ_MPSAFE); - if (softnettq == NULL) - panic("unable to create softnet taskq"); + for (i = 0; i < SOFTNET_TASKS; i++) { + softnettq[i] = taskq_create("softnet", 1, IPL_NET, TASKQ_MPSAFE); + if (softnettq[i] == NULL) + panic("unable to create softnet taskq"); + } net_tick(&net_tick_to); } @@ -725,7 +731,7 @@ if_input(struct ifnet *ifp, struct mbuf_list *ml) #endif if (mq_enlist(&ifp->if_inputqueue, ml) == 0) - task_add(softnettq, ifp->if_inputtask); + task_add(net_tq(ifp->if_index), ifp->if_inputtask); } int @@ -1025,15 +1031,15 @@ if_detach(struct ifnet *ifp) ifp->if_watchdog = NULL; /* Remove the input task */ - task_del(softnettq, ifp->if_inputtask); + task_del(net_tq(ifp->if_index), ifp->if_inputtask); mq_purge(&ifp->if_inputqueue); /* Remove the watchdog timeout & task */ timeout_del(ifp->if_slowtimo); - task_del(softnettq, ifp->if_watchdogtask); + task_del(net_tq(ifp->if_index), ifp->if_watchdogtask); /* Remove the link state task */ - task_del(softnettq, ifp->if_linkstatetask); + task_del(net_tq(ifp->if_index), ifp->if_linkstatetask); #if NBPFILTER > 0 bpfdetach(ifp); @@ -1583,7 +1589,7 @@ if_linkstate(struct ifnet *ifp) void if_link_state_change(struct ifnet *ifp) { - task_add(softnettq, ifp->if_linkstatetask); + task_add(net_tq(ifp->if_index), ifp->if_linkstatetask); } /* @@ -1599,7 +1605,7 @@ if_slowtimo(void *arg) if (ifp->if_watchdog) { if (ifp->if_timer > 0 && --ifp->if_timer == 0) - task_add(softnettq, ifp->if_watchdogtask); + task_add(net_tq(ifp->if_index), ifp->if_watchdogtask); timeout_add(ifp->if_slowtimo, hz / IFNET_SLOWHZ); } splx(s); @@ -2881,3 +2887,13 @@ unhandled_af(int af) { panic("unhandled af %d", af); } + +struct taskq * +net_tq(unsigned int ifindex) +{ + struct taskq *t = NULL; + + t = softnettq[ifindex % SOFTNET_TASKS]; + + return (t); +} diff --git a/sys/net/if.h b/sys/net/if.h index 89867eac340..0ec3bb56021 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.186 2017/01/24 10:08:30 krw Exp $ */ +/* $OpenBSD: if.h,v 1.187 2017/10/31 22:05:12 sashan Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -489,6 +489,7 @@ void if_congestion(void); int if_congested(void); __dead void unhandled_af(int); int if_setlladdr(struct ifnet *, const uint8_t *); +struct taskq * net_tq(unsigned int); #endif /* _KERNEL */ diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 277e7f966a2..5f7b1cec165 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_loop.c,v 1.82 2017/10/19 11:02:42 bluhm Exp $ */ +/* $OpenBSD: if_loop.c,v 1.83 2017/10/31 22:05:12 sashan Exp $ */ /* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */ /* @@ -244,7 +244,7 @@ looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, m->m_pkthdr.ph_family = dst->sa_family; if (mq_enqueue(&ifp->if_inputqueue, m)) return ENOBUFS; - task_add(softnettq, ifp->if_inputtask); + task_add(net_tq(ifp->if_index), ifp->if_inputtask); return (0); } diff --git a/sys/net/if_pflow.c b/sys/net/if_pflow.c index 38efb02be7e..9fb8ecf0ade 100644 --- a/sys/net/if_pflow.c +++ b/sys/net/if_pflow.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pflow.c,v 1.84 2017/09/08 05:36:53 deraadt Exp $ */ +/* $OpenBSD: if_pflow.c,v 1.85 2017/10/31 22:05:12 sashan Exp $ */ /* * Copyright (c) 2011 Florian Obser <florian@narrans.de> @@ -286,7 +286,7 @@ pflow_clone_destroy(struct ifnet *ifp) if (timeout_initialized(&sc->sc_tmo_tmpl)) timeout_del(&sc->sc_tmo_tmpl); pflow_flush(sc); - task_del(softnettq, &sc->sc_outputtask); + task_del(net_tq(ifp->if_index), &sc->sc_outputtask); mq_purge(&sc->sc_outputqueue); m_freem(sc->send_nam); if (sc->so != NULL) { @@ -1087,7 +1087,7 @@ pflow_sendout_v5(struct pflow_softc *sc) h->time_sec = htonl(tv.tv_sec); /* XXX 2038 */ h->time_nanosec = htonl(tv.tv_nsec); if (mq_enqueue(&sc->sc_outputqueue, m) == 0) - task_add(softnettq, &sc->sc_outputtask); + task_add(net_tq(ifp->if_index), &sc->sc_outputtask); return (0); } @@ -1149,7 +1149,7 @@ pflow_sendout_ipfix(struct pflow_softc *sc, sa_family_t af) sc->sc_sequence += count; h10->observation_dom = htonl(PFLOW_ENGINE_TYPE); if (mq_enqueue(&sc->sc_outputqueue, m) == 0) - task_add(softnettq, &sc->sc_outputtask); + task_add(net_tq(ifp->if_index), &sc->sc_outputtask); return (0); } @@ -1191,7 +1191,7 @@ pflow_sendout_ipfix_tmpl(struct pflow_softc *sc) timeout_add_sec(&sc->sc_tmo_tmpl, PFLOW_TMPL_TIMEOUT); if (mq_enqueue(&sc->sc_outputqueue, m) == 0) - task_add(softnettq, &sc->sc_outputtask); + task_add(net_tq(ifp->if_index), &sc->sc_outputtask); return (0); } diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 85c4836255f..4d65644cfee 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.82 2017/10/12 09:14:16 mpi Exp $ */ +/* $OpenBSD: if_var.h,v 1.83 2017/10/31 22:05:12 sashan Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -298,7 +298,6 @@ int niq_enlist(struct niqueue *, struct mbuf_list *); sysctl_mq((_n), (_l), (_op), (_olp), (_np), (_nl), &(_niq)->ni_q) extern struct ifnet_head ifnet; -extern struct taskq *softnettq; void if_start(struct ifnet *); int if_enqueue_try(struct ifnet *, struct mbuf *); diff --git a/sys/net/netisr.h b/sys/net/netisr.h index 813ddd6d2bb..60c02e99f88 100644 --- a/sys/net/netisr.h +++ b/sys/net/netisr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: netisr.h,v 1.49 2017/05/28 12:51:34 yasuoka Exp $ */ +/* $OpenBSD: netisr.h,v 1.50 2017/10/31 22:05:12 sashan Exp $ */ /* $NetBSD: netisr.h,v 1.12 1995/08/12 23:59:24 mycroft Exp $ */ /* @@ -75,7 +75,7 @@ void pipexintr(void); #define schednetisr(anisr) \ do { \ atomic_setbits_int(&netisr, (1 << (anisr))); \ - task_add(softnettq, &if_input_task_locked); \ + task_add(net_tq(0), &if_input_task_locked); \ } while (/* CONSTCOND */0) #endif /* _KERNEL */ diff --git a/sys/net/pf.c b/sys/net/pf.c index 0133aeeb63c..27cd34c3b52 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.1042 2017/08/14 15:58:16 henning Exp $ */ +/* $OpenBSD: pf.c,v 1.1043 2017/10/31 22:05:12 sashan Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -1222,7 +1222,7 @@ pf_purge_expired_rules(void) void pf_purge_timeout(void *unused) { - task_add(softnettq, &pf_purge_task); + task_add(net_tq(0), &pf_purge_task); } void diff --git a/sys/net/pf_ioctl.c b/sys/net/pf_ioctl.c index f6ad2cb8c53..99aebe1087c 100644 --- a/sys/net/pf_ioctl.c +++ b/sys/net/pf_ioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_ioctl.c,v 1.323 2017/10/30 22:35:50 sashan Exp $ */ +/* $OpenBSD: pf_ioctl.c,v 1.324 2017/10/31 22:05:12 sashan Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -2463,7 +2463,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) pf_default_rule_new.timeout[i]; if (pf_default_rule.timeout[i] == PFTM_INTERVAL && pf_default_rule.timeout[i] < old) - task_add(softnettq, &pf_purge_task); + task_add(net_tq(0), &pf_purge_task); } pfi_xcommit(); pf_trans_set_commit(); diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index ec0fff49ef3..836891f878a 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.326 2017/10/29 14:58:39 florian Exp $ */ +/* $OpenBSD: ip_input.c,v 1.327 2017/10/31 22:05:12 sashan Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -1839,5 +1839,5 @@ void ip_send(struct mbuf *m) { mq_enqueue(&ipsend_mq, m); - task_add(softnettq, &ipsend_task); + task_add(0, &ipsend_task); } diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index d62aa8a429b..2acac128fe9 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_input.c,v 1.205 2017/10/26 15:13:40 mpi Exp $ */ +/* $OpenBSD: ip6_input.c,v 1.206 2017/10/31 22:05:12 sashan Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -1477,5 +1477,5 @@ void ip6_send(struct mbuf *m) { mq_enqueue(&ip6send_mq, m); - task_add(softnettq, &ip6send_task); + task_add(0, &ip6send_task); } diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 9a94a753a6d..f87036bd428 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.220 2017/10/26 15:05:41 mpi Exp $ */ +/* $OpenBSD: nd6.c,v 1.221 2017/10/31 22:05:13 sashan Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -486,7 +486,7 @@ nd6_expire(void *unused) void nd6_expire_timer(void *unused) { - task_add(softnettq, &nd6_expire_task); + task_add(net_tq(0), &nd6_expire_task); } /* |