From: dlg Date: Sun, 30 Jul 2023 05:39:52 +0000 (+0000) Subject: count the number of times a ring was marked as oactive. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6e7a640f0c3a307a38b7b910968d0bfb99e197f1;p=openbsd count the number of times a ring was marked as oactive. this is interesting as an indicator of how busy or overloaded a transmit queue is before the next indicator which is the number of qdrops. --- diff --git a/sys/net/ifq.c b/sys/net/ifq.c index 9010a3463d0..81aa5b9a61f 100644 --- a/sys/net/ifq.c +++ b/sys/net/ifq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifq.c,v 1.49 2023/01/09 03:39:14 dlg Exp $ */ +/* $OpenBSD: ifq.c,v 1.50 2023/07/30 05:39:52 dlg Exp $ */ /* * Copyright (c) 2015 David Gwynne @@ -147,6 +147,20 @@ ifq_start_task(void *p) ifp->if_qstart(ifq); } +void +ifq_set_oactive(struct ifqueue *ifq) +{ + if (ifq->ifq_oactive) + return; + + mtx_enter(&ifq->ifq_mtx); + if (!ifq->ifq_oactive) { + ifq->ifq_oactive = 1; + ifq->ifq_oactives++; + } + mtx_leave(&ifq->ifq_mtx); +} + void ifq_restart_task(void *p) { @@ -202,6 +216,7 @@ struct ifq_kstat_data { struct kstat_kv kd_qlen; struct kstat_kv kd_maxqlen; struct kstat_kv kd_oactive; + struct kstat_kv kd_oactives; }; static const struct ifq_kstat_data ifq_kstat_tpl = { @@ -218,6 +233,7 @@ static const struct ifq_kstat_data ifq_kstat_tpl = { KSTAT_KV_UNIT_INITIALIZER("maxqlen", KSTAT_KV_T_UINT32, KSTAT_KV_U_PACKETS), KSTAT_KV_INITIALIZER("oactive", KSTAT_KV_T_BOOL), + KSTAT_KV_INITIALIZER("oactives", KSTAT_KV_T_COUNTER32), }; int @@ -234,6 +250,7 @@ ifq_kstat_copy(struct kstat *ks, void *dst) kstat_kv_u32(&kd->kd_qlen) = ifq->ifq_len; kstat_kv_u32(&kd->kd_maxqlen) = ifq->ifq_maxlen; kstat_kv_bool(&kd->kd_oactive) = ifq->ifq_oactive; + kstat_kv_u32(&kd->kd_oactives) = ifq->ifq_oactives; return (0); } @@ -243,7 +260,7 @@ void ifq_init(struct ifqueue *ifq, struct ifnet *ifp, unsigned int idx) { ifq->ifq_if = ifp; - ifq->ifq_softnet = net_tq(ifp->if_index + idx); + ifq->ifq_softnet = net_tq(idx); ifq->ifq_softc = NULL; mtx_init(&ifq->ifq_mtx, IPL_NET); @@ -635,7 +652,7 @@ void ifiq_init(struct ifiqueue *ifiq, struct ifnet *ifp, unsigned int idx) { ifiq->ifiq_if = ifp; - ifiq->ifiq_softnet = net_tq(ifp->if_index + idx); + ifiq->ifiq_softnet = net_tq(idx); ifiq->ifiq_softc = NULL; mtx_init(&ifiq->ifiq_mtx, IPL_NET); diff --git a/sys/net/ifq.h b/sys/net/ifq.h index ac14eefe3c7..c32a635a835 100644 --- a/sys/net/ifq.h +++ b/sys/net/ifq.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ifq.h,v 1.37 2023/01/09 03:37:44 dlg Exp $ */ +/* $OpenBSD: ifq.h,v 1.38 2023/07/30 05:39:52 dlg Exp $ */ /* * Copyright (c) 2015 David Gwynne @@ -54,6 +54,7 @@ struct ifqueue { uint64_t ifq_qdrops; uint64_t ifq_errors; uint64_t ifq_mcasts; + uint32_t ifq_oactives; struct kstat *ifq_kstat; @@ -441,7 +442,7 @@ void *ifq_q_enter(struct ifqueue *, const struct ifq_ops *); void ifq_q_leave(struct ifqueue *, void *); void ifq_serialize(struct ifqueue *, struct task *); void ifq_barrier(struct ifqueue *); - +void ifq_set_oactive(struct ifqueue *); int ifq_deq_sleep(struct ifqueue *, struct mbuf **, int, int, const char *, volatile unsigned int *, @@ -457,12 +458,6 @@ ifq_is_priq(struct ifqueue *ifq) return (ifq->ifq_ops == ifq_priq_ops); } -static inline void -ifq_set_oactive(struct ifqueue *ifq) -{ - ifq->ifq_oactive = 1; -} - static inline void ifq_clr_oactive(struct ifqueue *ifq) {