From d16c94f78cebc0575c12c822443ecce6a3cf1b42 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Thu, 1 May 2008 02:03:28 +0000 Subject: [PATCH] - Promote em(4) polling begin/end ktr into polling(4) - Add crit section around if_poll --- share/man/man4/ktr.4 | 6 +++++- sys/conf/options | 3 ++- sys/config/LINT | 3 ++- sys/dev/netif/em/if_em.c | 9 +-------- sys/kern/kern_poll.c | 22 ++++++++++++++++++++-- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/share/man/man4/ktr.4 b/share/man/man4/ktr.4 index fdfa3339a8..9fa56267e8 100644 --- a/share/man/man4/ktr.4 +++ b/share/man/man4/ktr.4 @@ -23,7 +23,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD: src/share/man/man4/ktr.4,v 1.9 2003/09/08 19:57:19 ru Exp $ -.\" $DragonFly: src/share/man/man4/ktr.4,v 1.6 2008/04/30 09:15:08 swildner Exp $ +.\" $DragonFly: src/share/man/man4/ktr.4,v 1.7 2008/05/01 02:03:28 sephe Exp $ .\" .Dd April 30, 2008 .Dt KTR 4 @@ -41,6 +41,7 @@ .Cd options KTR_IF_EM .Cd options KTR_IPIQ .Cd options KTR_MEMORY +.Cd options KTR_POLLING .Cd options KTR_SERIALIZER .Cd options KTR_SPIN_CONTENTION .\".Cd options KTR_TCP @@ -88,6 +89,9 @@ IPI related data (IPI requests, CPU synchronization etc.) and .Xr kfree 9 events +.It Dv KTR_POLLING +.Xr polling 4 +begins and ends .It Dv KTR_SERIALIZER .Xr serializer 9 related events diff --git a/sys/conf/options b/sys/conf/options index b1ee395138..5228eb685d 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -1,5 +1,5 @@ # $FreeBSD: src/sys/conf/options,v 1.191.2.53 2003/06/04 17:56:58 sam Exp $ -# $DragonFly: src/sys/conf/options,v 1.82 2008/04/29 16:00:12 sephe Exp $ +# $DragonFly: src/sys/conf/options,v 1.83 2008/05/01 02:03:28 sephe Exp $ # # On the handling of kernel options # @@ -526,6 +526,7 @@ KTR_IF_BGE opt_ktr.h KTR_IF_EM opt_ktr.h KTR_TESTLOG opt_ktr.h KTR_SERIALIZER opt_ktr.h +KTR_POLLING opt_ktr.h # bce driver BCE_DEBUG opt_bce.h diff --git a/sys/config/LINT b/sys/config/LINT index 63c4e0be18..87d9427951 100644 --- a/sys/config/LINT +++ b/sys/config/LINT @@ -3,7 +3,7 @@ # as much of the source tree as it can. # # $FreeBSD: src/sys/i386/conf/LINT,v 1.749.2.144 2003/06/04 17:56:59 sam Exp $ -# $DragonFly: src/sys/config/LINT,v 1.158 2008/04/30 09:15:08 swildner Exp $ +# $DragonFly: src/sys/config/LINT,v 1.159 2008/05/01 02:03:28 sephe Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -2750,6 +2750,7 @@ options KTR #options KTR_IPIQ #options KTR_MEMORY #options KTR_SERIALIZER +#options KTR_POLLING #options KTR_SPIN_CONTENTION #options KTR_TESTLOG #options KTR_TOKENS diff --git a/sys/dev/netif/em/if_em.c b/sys/dev/netif/em/if_em.c index d62b42362b..9442d1781e 100644 --- a/sys/dev/netif/em/if_em.c +++ b/sys/dev/netif/em/if_em.c @@ -64,7 +64,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/dev/netif/em/if_em.c,v 1.68 2008/04/03 12:55:15 sephe Exp $ + * $DragonFly: src/sys/dev/netif/em/if_em.c,v 1.69 2008/05/01 02:03:28 sephe Exp $ * $FreeBSD$ */ /* @@ -396,10 +396,6 @@ TUNABLE_INT("hw.em.smart_pwr_down", &em_smart_pwr_down); KTR_INFO_MASTER(if_em); KTR_INFO(KTR_IF_EM, if_em, intr_beg, 0, "intr begin", 0); KTR_INFO(KTR_IF_EM, if_em, intr_end, 1, "intr end", 0); -#ifdef DEVICE_POLLING -KTR_INFO(KTR_IF_EM, if_em, poll_beg, 2, "poll begin", 0); -KTR_INFO(KTR_IF_EM, if_em, poll_end, 3, "poll end", 0); -#endif KTR_INFO(KTR_IF_EM, if_em, pkt_receive, 4, "rx packet", 0); KTR_INFO(KTR_IF_EM, if_em, pkt_txqueue, 5, "tx packet", 0); KTR_INFO(KTR_IF_EM, if_em, pkt_txclean, 6, "tx clean", 0); @@ -1156,8 +1152,6 @@ em_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) struct adapter *adapter = ifp->if_softc; uint32_t reg_icr; - logif(poll_beg); - ASSERT_SERIALIZED(ifp->if_serializer); switch(cmd) { @@ -1188,7 +1182,6 @@ em_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) } break; } - logif(poll_end); } #endif /* DEVICE_POLLING */ diff --git a/sys/kern/kern_poll.c b/sys/kern/kern_poll.c index 5db31ed560..a1f21d9ad8 100644 --- a/sys/kern/kern_poll.c +++ b/sys/kern/kern_poll.c @@ -25,13 +25,14 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/kern_poll.c,v 1.2.2.4 2002/06/27 23:26:33 luigi Exp $ - * $DragonFly: src/sys/kern/kern_poll.c,v 1.45 2008/04/30 09:30:59 sephe Exp $ + * $DragonFly: src/sys/kern/kern_poll.c,v 1.46 2008/05/01 02:03:28 sephe Exp $ */ #include "opt_polling.h" #include #include +#include #include /* needed by net/if.h */ #include @@ -194,6 +195,18 @@ static void schedpoll_oncpu(struct pollctx *, struct netmsg *, netisr_fn_t); void init_device_poll_pcpu(int); /* per-cpu init routine */ +#define POLL_KTR_STRING "ifp=%p" +#define POLL_KTR_ARG_SIZE (sizeof(void *)) + +#ifndef KTR_POLLING +#define KTR_POLLING KTR_ALL +#endif +KTR_INFO_MASTER(poll); +KTR_INFO(KTR_POLLING, poll, beg, 0, POLL_KTR_STRING, POLL_KTR_ARG_SIZE); +KTR_INFO(KTR_POLLING, poll, end, 1, POLL_KTR_STRING, POLL_KTR_ARG_SIZE); + +#define logpoll(name, arg) KTR_LOG(poll_ ## name, arg) + static __inline void poll_reset_state(struct pollctx *pctx) { @@ -606,8 +619,13 @@ netisr_poll(struct netmsg *msg) continue; if ((ifp->if_flags & (IFF_UP|IFF_RUNNING|IFF_POLLING)) - == (IFF_UP|IFF_RUNNING|IFF_POLLING)) + == (IFF_UP|IFF_RUNNING|IFF_POLLING)) { + logpoll(beg, ifp); + crit_enter(); ifp->if_poll(ifp, arg, cycles); + crit_exit(); + logpoll(end, ifp); + } lwkt_serialize_exit(ifp->if_serializer); } -- 2.41.0