git: ebb93ce6d86e - main - iflib: don't update the admin status in if_media_status()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 31 Aug 2026 21:18:47 UTC
The branch main has been updated by gallatin:
URL: https://cgit.FreeBSD.org/src/commit/?id=ebb93ce6d86e6c6abd9d9fada21a3b107099db8f
commit ebb93ce6d86e6c6abd9d9fada21a3b107099db8f
Author: Andrew Gallatin <gallatin@FreeBSD.org>
AuthorDate: 2026-08-31 21:13:47 +0000
Commit: Andrew Gallatin <gallatin@FreeBSD.org>
CommitDate: 2026-08-31 21:17:44 +0000
iflib: don't update the admin status in if_media_status()
When _task_fn_admin() is active, it will regularly call
IFDI_UPDATE_ADMIN_STATUS(). So there is no need to do it in
iflib_media_status. This can be fairly expensive on some drivers (long
DELAY busywait loops waiting for a NIC command), and there is no need
to pause a userspace app in this DELAY() if it is happening
asynchronously anyway.
Note the logic to detect if _task_fn_admin() is regularly calling
IFDI_UPDATE_ADMIN_STATUS() was copied from that function.
Reviewed by: erj, kbowling
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D54096
---
sys/net/iflib.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index c8662b6b7e69..37f1218bbb17 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -2671,9 +2671,23 @@ static void
iflib_media_status(if_t ifp, struct ifmediareq *ifmr)
{
if_ctx_t ctx = if_getsoftc(ifp);
+ bool oactive, running;
+
+ STATE_LOCK(ctx);
+ running = (if_getdrvflags(ctx->ifc_ifp) & IFF_DRV_RUNNING);
+ oactive = (if_getdrvflags(ctx->ifc_ifp) & IFF_DRV_OACTIVE);
+ STATE_UNLOCK(ctx);
CTX_LOCK(ctx);
- IFDI_UPDATE_ADMIN_STATUS(ctx);
+ /*
+ * There is no need to update the admin status when it is done regularly by
+ * _task_fn_admin(), so only do it if that's not running. That can be quite
+ * expensive on some drivers.
+ */
+ if ((!running && !oactive) &&
+ !(ctx->ifc_sctx->isc_flags & IFLIB_ADMIN_ALWAYS_RUN)) {
+ IFDI_UPDATE_ADMIN_STATUS(ctx);
+ }
IFDI_MEDIA_STATUS(ctx, ifmr);
CTX_UNLOCK(ctx);
}