From: dlg Date: Tue, 22 Nov 2022 03:40:53 +0000 (+0000) Subject: count how many times ifiqs enqueue and dequeue packets. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=df2795bfdedcb9e62cd76e2674f1cb00b1285cdf;p=openbsd count how many times ifiqs enqueue and dequeue packets. network cards try to enqueue a list of packets on an ifiq once per interrupt and ifiqs already count how many packets they're handling. this let's us see how well interrupt mitigation is working on a ring or interface. ifiqs are supposed to provide backpressure signalling to a driver if it enqueues a lot more work than it's able to process in softnet, so recording dequeues let's us see this ratio. --- diff --git a/sys/net/ifq.c b/sys/net/ifq.c index 26ac1701b9d..99777327d73 100644 --- a/sys/net/ifq.c +++ b/sys/net/ifq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifq.c,v 1.46 2022/04/30 21:13:57 bluhm Exp $ */ +/* $OpenBSD: ifq.c,v 1.47 2022/11/22 03:40:53 dlg Exp $ */ /* * Copyright (c) 2015 David Gwynne @@ -582,6 +582,9 @@ struct ifiq_kstat_data { struct kstat_kv kd_qdrops; struct kstat_kv kd_errors; struct kstat_kv kd_qlen; + + struct kstat_kv kd_enqueues; + struct kstat_kv kd_dequeues; }; static const struct ifiq_kstat_data ifiq_kstat_tpl = { @@ -595,6 +598,11 @@ static const struct ifiq_kstat_data ifiq_kstat_tpl = { KSTAT_KV_T_COUNTER64, KSTAT_KV_U_PACKETS), KSTAT_KV_UNIT_INITIALIZER("qlen", KSTAT_KV_T_UINT32, KSTAT_KV_U_PACKETS), + + KSTAT_KV_INITIALIZER("enqueues", + KSTAT_KV_T_COUNTER64), + KSTAT_KV_INITIALIZER("dequeues", + KSTAT_KV_T_COUNTER64), }; int @@ -610,6 +618,9 @@ ifiq_kstat_copy(struct kstat *ks, void *dst) kstat_kv_u64(&kd->kd_errors) = ifiq->ifiq_errors; kstat_kv_u32(&kd->kd_qlen) = ml_len(&ifiq->ifiq_ml); + kstat_kv_u64(&kd->kd_enqueues) = ifiq->ifiq_enqueues; + kstat_kv_u64(&kd->kd_dequeues) = ifiq->ifiq_dequeues; + return (0); } #endif @@ -721,8 +732,10 @@ ifiq_input(struct ifiqueue *ifiq, struct mbuf_list *ml) if (__predict_true(!ISSET(ifp->if_xflags, IFXF_MONITOR))) { if (len > ifiq_maxlen_drop) ifiq->ifiq_qdrops += ml_len(ml); - else + else { + ifiq->ifiq_enqueues++; ml_enlist(&ifiq->ifiq_ml, ml); + } } mtx_leave(&ifiq->ifiq_mtx); @@ -766,6 +779,7 @@ ifiq_process(void *arg) return; mtx_enter(&ifiq->ifiq_mtx); + ifiq->ifiq_dequeues++; ml = ifiq->ifiq_ml; ml_init(&ifiq->ifiq_ml); mtx_leave(&ifiq->ifiq_mtx); diff --git a/sys/net/ifq.h b/sys/net/ifq.h index 9764c9c5cc1..78180224932 100644 --- a/sys/net/ifq.h +++ b/sys/net/ifq.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ifq.h,v 1.34 2022/01/28 07:11:15 guenther Exp $ */ +/* $OpenBSD: ifq.h,v 1.35 2022/11/22 03:40:53 dlg Exp $ */ /* * Copyright (c) 2015 David Gwynne @@ -95,6 +95,11 @@ struct ifiqueue { uint64_t ifiq_mcasts; uint64_t ifiq_noproto; + /* number of times a list of packets were put on ifiq_ml */ + uint64_t ifiq_enqueues; + /* number of times a list of packets were pulled off ifiq_ml */ + uint64_t ifiq_dequeues; + struct kstat *ifiq_kstat; /* properties */