From nobody Mon Oct 12 21:27:36 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4j3VtQ147Vz6vX4c for ; Mon, 12 Oct 2026 21:27:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4j3VtP72fKz3K7b for ; Mon, 12 Oct 2026 21:27:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791840462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wYQj/sw+l4Rq7XaXbW/BkNPJjOwJZHtenPkqk/129Bc=; b=psqKEHLdCE4bZzkdM0gLoyMSPT6gWw3Puz40N2LjaJBVQxReRtGezxRRzbQm+nqXtiqY1P uHX5R9FxcuX17ivEZ3zeh9jmb/aiKtKkdBG8Hd7bJTGISt+luJ9qYiyyYO+FswgWxthqO4 EqNq8KbboGzsnnHkkISCJn+TUPlp6O190PE7bw5TLohs7dozJGswXoE4n9/R5rWB+d+2Sm dgpO/1wwx4tQUDswz/YaxdKPJegQ0InrzIyUl1K641Iz6mHDyK0b5cICa/meuEMUIg1hum Gp9Vycbp+DdF+kLdqFg/6JFBuGb8wmcc+m/a+korfl8Y3de59ULmgF7YrpaPRw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791840462; b=pme9g2joiVPunsZiTzS5At+v6DyUhhbco8l4qAeHgJrPuDBJUCeYX7uAHhhUpNGkExMLom yJmoQMeDh5ejMvXUrsFenIyofLP0wZ8o/uMXc8MCUesPtLldFz3fFK2d6Q7yWdstB6a2UU Dmns4Y9sVoaJe7xfm2r5/3PzT2wTBfasUDu23nuJLiaqYVxIjI8Eze2aCJi+riGNjUBKaS X9S0qq9z6wkwUgXIoZagHqXJtrj/92sa4PaOwTvveI3T0kmDgn8Y2Z9IIgPQ+jez2U+LKA UKLagIwq9soL9D9iuqy1G5VR/CvxUYB9G37OTLcjWKJbdH4sNQPcqQ/WDerH2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791840462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wYQj/sw+l4Rq7XaXbW/BkNPJjOwJZHtenPkqk/129Bc=; b=qPXGOr4B6zX8M/B48y5X/HjeFvHT9Pe77BSWx1WE/DBcw6lWUvCkJZu2UYGkfAmuwGC29/ 00tfYQkuW1NDagI0ZtREmignQb7JXbUC47YopL2Du/e93q2GUc2gqWJJSmNP2j4+SeqYoC IWeJdMguo7aEnSd82JwR9HX1J5XiiJ+cpfXheP0/khWHdh66AZt8x4EufQ43E+AYElh3zV j3Mzh9sgZ0dPM8Yu5zgze/FQbLchNphEmsU3v159cBKkGT1Ry+RL0tCI6joLwY8DiV0MTJ ueMBx4nm3sCOIhzcR3jtsxBTQ26qJ35jJZ87Ri0ZWjGyd4dDRbRy8hcbehHTjQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4j3VtP5Xkkzm52 for ; Mon, 12 Oct 2026 21:27:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 19fae by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 12 Oct 2026 21:27:36 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Gallatin Subject: git: cdd95034d6f4 - main - iflib: unify prefetching List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gallatin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cdd95034d6f4b5a7abe7d21b2b1a568fa5e906a0 Auto-Submitted: auto-generated Date: Mon, 12 Oct 2026 21:27:36 +0000 Message-Id: <6acd50c8.19fae.6cac724c@gitrepo.freebsd.org> The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=cdd95034d6f4b5a7abe7d21b2b1a568fa5e906a0 commit cdd95034d6f4b5a7abe7d21b2b1a568fa5e906a0 Author: Andrew Gallatin AuthorDate: 2026-10-12 19:50:15 +0000 Commit: Andrew Gallatin CommitDate: 2026-10-12 21:27:26 +0000 iflib: unify prefetching This change makes all prefetching use the iflib prefetch wrappers, rather than using prefetch() in some places and __builtin_prefetch() in others. Note that __builtin_prefetch() does not work in the kernel on amd64 as clang disables it when -mnosse is specified, so we must use the asm directives there, and builtin_prefetch() elsewhere. This change enables prefetching on non-x86 (notably arm64), and it enables prefetching in netmap that has been there since day one, but which has never worked. This is a no-op on non-netmap amd64 and i386 Differential Revision: https://reviews.freebsd.org/D60602 Reviewed by: glebius, kbowling Sponsored by: Netflix --- sys/net/iflib.c | 58 +++++++++++++++++++++++++-------------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 358e2f03aded..9ca08eaee6e8 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -912,6 +912,25 @@ iflib_num_tx_descs(if_ctx_t ctx) return (scctx->isc_ntxd[first_txq]); } +static inline void +prefetch(void *x) +{ +#if defined(__i386__) || defined(__amd64__) + __asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x)); +#else + __builtin_prefetch(x); +#endif +} + +static inline void +prefetch2cachelines(void *x) +{ + prefetch(x); +#if (CACHE_LINE_SIZE < 128) + prefetch((char *)x + CACHE_LINE_SIZE); +#endif +} + #ifdef DEV_NETMAP #include #include @@ -1194,9 +1213,9 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags) pi.ipi_qsidx = kring->ring_id; nic_i = netmap_idx_k2n(kring, nm_i); - __builtin_prefetch(&ring->slot[nm_i]); - __builtin_prefetch(&txq->ift_sds.ifsd_m[nic_i]); - __builtin_prefetch(&txq->ift_sds.ifsd_map[nic_i]); + prefetch(&ring->slot[nm_i]); + prefetch(&txq->ift_sds.ifsd_m[nic_i]); + prefetch(&txq->ift_sds.ifsd_map[nic_i]); while (nm_i != head) { struct netmap_slot *slot = &ring->slot[nm_i]; @@ -1244,9 +1263,9 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags) } /* prefetch for next round */ - __builtin_prefetch(&ring->slot[nm_i + 1]); - __builtin_prefetch(&txq->ift_sds.ifsd_m[nic_i + 1]); - __builtin_prefetch(&txq->ift_sds.ifsd_map[nic_i + 1]); + prefetch(&ring->slot[nm_i + 1]); + prefetch(&txq->ift_sds.ifsd_m[nic_i + 1]); + prefetch(&txq->ift_sds.ifsd_map[nic_i + 1]); NM_CHECK_ADDR_LEN_OFF(na, len, offset); @@ -1548,33 +1567,6 @@ iflib_netmap_timer(void *arg) #define netmap_rx_irq(ifp, qid, budget) (0) #endif -#if defined(__i386__) || defined(__amd64__) -static __inline void -prefetch(void *x) -{ - __asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x)); -} - -static __inline void -prefetch2cachelines(void *x) -{ - __asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x)); -#if (CACHE_LINE_SIZE < 128) - __asm volatile("prefetcht0 %0" :: "m" (*(((unsigned long *)x) + CACHE_LINE_SIZE / (sizeof(unsigned long))))); -#endif -} -#else -static __inline void -prefetch(void *x) -{ -} - -static __inline void -prefetch2cachelines(void *x) -{ -} -#endif - static void iru_init(if_rxd_update_t iru, iflib_rxq_t rxq, uint8_t flid) {