From nobody Thu Oct 29 06:03:28 2026 X-Original-To: dev-commits-src-branches@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 4jFYZ85tbNz6xrZZ for ; Thu, 29 Oct 2026 06:03:28 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jFYZ80rZhz4sp4 for ; Thu, 29 Oct 2026 06:03:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793253808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C7XX1+OdpmuNYFzfoykQtcXair7jidkfPjBa/Sl2ShQ=; b=mVpeJXCpYuMBvWgjKgxxhgNS+1rWGo1xe1OF1hYaBe7Ej3smMK3NTC2fR4tpfA11oCI3wg BFkHdhA3Qms9Un3ecVo81kiNHNn2tJK88Zg/DTqmK5ju2kH9UofNi7aQRzEe3W6naAk7Hb z7SXgXGOa+G/kCiKN/v62acGpS958mEC7ExjIbaH7G+Aua3toSaebfCq3AP78kOl0Km/oY 8VaQZpN7z9wfNfSPjK5xGh5HSd76fkXBwW9WIrovIEbKqGNYzpFkD4m1mz8/zBMOJDAOhK 7KqfzbrxYIkUAT9jiLf5Sn6vfPwk0PGxDwb+/4mIRMfQAB61H3r0dH9a4H9vJQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793253808; b=OOQokHE3+yIMDVsIf0JNMchT7ywjS9xaJtPtkIGCdiCDojWAPOWtCoD6l31xWjHbpQwBUe oqCt1GU+5UsKlVu1ZD5B7yPr3xsxiY6KA5OTtARViLUoqdPeAOOor9VKvCv4elOcOB0i+2 bxXQnXdpESWRBsaOujfwRKtecOdzn7/xPtGv+xnUfKNGljrBhKU2Drim65Myd8xqxPLf/+ gnKN/M9150jgARa1+Jy1WnXI/H3C+IzR0Zb++ypqkpfXjUoGhbFTz7gyvAVbDiwvAGL+TV 2CkwTyyfDAuLhgiCYnuZGxJhG5tfZs+hw/gJnpkFyGxYgE7YjcLgzXVkQ0p1qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793253808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C7XX1+OdpmuNYFzfoykQtcXair7jidkfPjBa/Sl2ShQ=; b=dI/ePIuvMqwaL5xU7DXghSmHoYryYbM47k7Itxi7Y575UZZKLtlZi36hpQfP9gedGT59Jg GOlCITZtIUfz/AX0lqS1hCqK8oPH0W0RmxMu5wLhKA2cuVAsC5p9V2n9qwePxKd6QwOQJI GTLFhbBfw9FdpsPOO8TzZpyxzquq8A8yv0HhZ5SnEgz1Tpgu8NUzZYzLtIeqq7MW4Y/ShK elRfb7KYKw3Z5OcL9eYhHpzpmooHtK8PNrM1Ob44wjTtQxR1EbWiWTg+oSg8luJKwt03RD HsnQb2ZAzH76b5LpvqkOCvYMC3CVmV4Y7EgQLUMk4a0+oMSC//Xn9LLngJVKtg== 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 4jFYZ805JzzR9c for ; Thu, 29 Oct 2026 06:03:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 39cdc by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 29 Oct 2026 06:03:28 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Andrew Gallatin From: Kevin Bowling Subject: git: 2b1402953095 - stable/15 - iflib: unify prefetching List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: Commits to the stable branches of the FreeBSD 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: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 2b1402953095861e87d40146b01c08e7c19a87e6 Auto-Submitted: auto-generated Date: Thu, 29 Oct 2026 06:03:28 +0000 Message-Id: <6ae2e1b0.39cdc.531d522@gitrepo.freebsd.org> The branch stable/15 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=2b1402953095861e87d40146b01c08e7c19a87e6 commit 2b1402953095861e87d40146b01c08e7c19a87e6 Author: Andrew Gallatin AuthorDate: 2026-10-12 19:50:15 +0000 Commit: Kevin Bowling CommitDate: 2026-10-29 05:42:09 +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 (cherry picked from commit cdd95034d6f4b5a7abe7d21b2b1a568fa5e906a0) --- 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 59b76974a3fc..104a7cbc658b 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -911,6 +911,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 @@ -1193,9 +1212,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]; @@ -1243,9 +1262,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); @@ -1547,33 +1566,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) {