From nobody Mon Oct 12 21:27:36 2026 X-Original-To: dev-commits-src-main@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 4j3VtJ67xyz6vWnf for ; Mon, 12 Oct 2026 21:27:36 +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 4j3VtJ4Qh3z3K78 for ; Mon, 12 Oct 2026 21:27:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791840456; 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=vdY2zn2Ajkusr5tgkRhuni/jQPQBvzw3H35WE0wJCIgZggV+MvWNWCAtXhMMMR+2SZEwhU WQRrCOS4gd2tHYt/KbAAC2yUYYfW7Hp+YSN1LRhx3+wkrrHvYOdb/fdwvTpqGmE2gMCFpN 5jedLMeicoxcEa8GoiDbI3ptQZENI4hodBLRcICdGquoSL7r8+39NRfT9TSTqjWAZxkrx6 lu+xKlLq+/XO7KTzbAA47CxavY9pUvtzfb+FSKhg0RGTrapgFNysw5O7FVEkzNGIAOfIP7 /8n7g3SgVeygJtdjcfL3q1TqGJ549BAk3cezr+EJu2C3L/92J6kry15iHmIiTg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791840456; b=DR/XVy7bj3YwFJ0kJRRTkDnICeOLohcWUt0L1kdLPBFw/B+KwDap7bn/dlFOFyfmYckm1b 21PxuAkGQM9oTRomOtk6rAJpghCAXJ6QIRyqlI4OPFDrzvFJaU9lpbpEJ9NfuDduxWX1nQ 8m4XIIquCcju5p7sjjwVoE82AKg81brnmCJiSZZyiwioUOyUoajRdQok5U84hBNvD9N/2Y Knef3aq7BHn0a5bVNhKp8W2ZrLeocZAuYYCTWo7G49Kt4OVPscdCjdEo1DQje1UdcVp5EE DCKtmJE1H6G3neAwCr8KyuUSPfIEYSLfddvWfeF6L/8+pWqhy/Aobb2jAXx/Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791840456; 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=bV4iNceEIUP+wxa52DnRd/lnqvWGxPVfAh+z6vBMkfTD0CsXXkvG26MmuFxlhY/vObGYs3 fDQHNqdtzM7yTTz0oS4eHNsR7XWFsLOVkwjkOP47S+rFoeeED2SB7yxJguEMLyWuWCVDRu YoExeoGjLkaVQzBNTdQzDRMGhWrG409RWyWP627Nky8AZ7kfWL6F68joi0vccT1qdyIQs+ CEKuD7MGgltXqBMubpFNLbmReYkgU71cpBtU9nn223VulA3Ymxj/o54hhhc0zA9Rs+Prew Htda0uSyqEYXSumh3Z2qrqngr/CNOtaADGs/jwcuMqrtx138vk3DMkK7Lzm2dQ== 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 4j3VtJ3Vrwzm6Z for ; Mon, 12 Oct 2026 21:27:36 +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-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch 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) {